@@ -2,7 +2,6 @@ package com.kubukoz.next
2
2
3
3
import cats .FlatMap
4
4
import cats .MonadError
5
- import cats .data .OptionT
6
5
import cats .effect .Concurrent
7
6
import cats .implicits .*
8
7
import com .kubukoz .next .client .spotify .Item
@@ -26,7 +25,6 @@ trait Spotify[F[_]] {
26
25
percentage : Int
27
26
): F [Unit ]
28
27
29
- def jumpSection : F [Unit ]
30
28
def switch : F [Unit ]
31
29
def move : F [Unit ]
32
30
}
@@ -59,7 +57,7 @@ object Spotify {
59
57
60
58
import Error .*
61
59
62
- def instance [F [_]: Playback : UserOutput : Concurrent : SpotifyApi : Switch : Analysis : ConfigLoader ]: Spotify [F ] =
60
+ def instance [F [_]: Playback : UserOutput : Concurrent : SpotifyApi : Switch : ConfigLoader ]: Spotify [F ] =
63
61
new Spotify [F ] {
64
62
private val getPlayer = SpotifyApi [F ].getPlayer().map(Player .fromApiPlayer)
65
63
@@ -129,38 +127,6 @@ object Spotify {
129
127
Playback [F ].seek(desiredProgress)
130
128
}
131
129
132
- def jumpSection : F [Unit ] = getPlayer
133
- .flatMap(requireTrack)
134
- .flatMap { player =>
135
- val track = player.item
136
-
137
- val currentLength = player.progress
138
-
139
- Analysis [F ]
140
- .getAnalysis(track.uri)
141
- .flatMap { analysis =>
142
- analysis
143
- .sections
144
- .zipWithIndex
145
- .find { case (section, _) => section.startSeconds.seconds > (currentLength + 1 .second) }
146
- .traverse { case (section, index) =>
147
- val percentage = (section.startSeconds.seconds * 100 / track.duration).toInt
148
-
149
- UserOutput [F ].print(
150
- UserMessage .Jumping (
151
- sectionNumber = index + 1 ,
152
- sectionsTotal = analysis.sections.length,
153
- percentTotal = percentage
154
- )
155
- ) *>
156
- Playback [F ].seek(section.startSeconds.seconds)
157
- }
158
- .pipe(OptionT (_))
159
- .getOrElseF(UserOutput [F ].print(UserMessage .TooCloseToEnd ) *> Playback [F ].seek(0 .millis))
160
- }
161
- }
162
- .void
163
-
164
130
val switch : F [Unit ] = Switch [F ].switch
165
131
166
132
val move : F [Unit ] = getPlayer.flatMap(requireContext).flatMap(requireTrack).flatMap { player =>
0 commit comments