Skip to content

Commit fc37b84

Browse files
committed
Remove jump / audio analysis feature
1 parent e07887a commit fc37b84

File tree

9 files changed

+5
-154
lines changed

9 files changed

+5
-154
lines changed

README.md

-6
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@ Usage:
4444
spotify-next skip
4545
spotify-next drop
4646
spotify-next forward
47-
spotify-next jump
4847
spotify-next s
4948
spotify-next d
5049
spotify-next f
51-
spotify-next j
5250
spotify-next repl
5351
5452
spotify-next: Gather great music.
@@ -68,16 +66,12 @@ Subcommands:
6866
Drop current track from the current playlist and skip to the next track
6967
forward
7068
Fast forward the current track by a percentage of its length (10% by default)
71-
jump
72-
Fast forward the current track to the next section
7369
s
7470
Alias for `skip`
7571
d
7672
Alias for `drop`
7773
f
7874
Alias for `forward`
79-
j
80-
Alias for `jump`
8175
repl
8276
Run application in interactive mode
8377
```

app/src/main/scala/com/kubukoz/next/Analysis.scala

-64
This file was deleted.

app/src/main/scala/com/kubukoz/next/Main.scala

-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ enum Choice {
3232
percentage: Int
3333
)
3434

35-
case JumpSection
3635
case Switch
3736
case Move
3837
}
@@ -53,11 +52,9 @@ object Choice {
5352
),
5453
Opts.subcommand("switch", "Switch device (Spotify/Sonos)")(Opts(Switch)),
5554
Opts.subcommand("move", "Move song to playlist A")(Opts(Move)),
56-
Opts.subcommand("jump", "Fast forward the current track to the next section")(Opts(JumpSection)),
5755
Opts.subcommand("s", "Alias for `skip`")(Opts(SkipTrack)),
5856
Opts.subcommand("d", "Alias for `drop`")(Opts(DropTrack)),
5957
Opts.subcommand("f", "Alias for `forward`")(ffOpts),
60-
Opts.subcommand("j", "Alias for `jump`")(Opts(JumpSection)),
6158
Opts.subcommand("w", "Alias for `switch`")(Opts(Switch)),
6259
Opts.subcommand("m", "Alias for `move`")(Opts(Move))
6360
)

app/src/main/scala/com/kubukoz/next/Program.scala

-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ object Program {
128128

129129
for {
130130
given Spotify.Playback[F] <- SpotifyChoice.choose[F].map(Spotify.Playback.makeFromChoice[F])
131-
given Analysis[F] <- Analysis.cached(Analysis.instance[F])
132131
} yield Spotify.instance[F]
133132
}
134133

app/src/main/scala/com/kubukoz/next/Runner.scala

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ object Runner {
2121
case Choice.SkipTrack => Spotify[F].skipTrack
2222
case Choice.DropTrack => Spotify[F].dropTrack
2323
case Choice.FastForward(p) => Spotify[F].fastForward(p)
24-
case Choice.JumpSection => Spotify[F].jumpSection
2524
case Choice.Switch => Spotify[F].switch
2625
case Choice.Move => Spotify[F].move
2726
}

app/src/main/scala/com/kubukoz/next/Spotify.scala

+1-35
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.kubukoz.next
22

33
import cats.FlatMap
44
import cats.MonadError
5-
import cats.data.OptionT
65
import cats.effect.Concurrent
76
import cats.implicits.*
87
import com.kubukoz.next.client.spotify.Item
@@ -26,7 +25,6 @@ trait Spotify[F[_]] {
2625
percentage: Int
2726
): F[Unit]
2827

29-
def jumpSection: F[Unit]
3028
def switch: F[Unit]
3129
def move: F[Unit]
3230
}
@@ -59,7 +57,7 @@ object Spotify {
5957

6058
import Error.*
6159

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] =
6361
new Spotify[F] {
6462
private val getPlayer = SpotifyApi[F].getPlayer().map(Player.fromApiPlayer)
6563

@@ -129,38 +127,6 @@ object Spotify {
129127
Playback[F].seek(desiredProgress)
130128
}
131129

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-
164130
val switch: F[Unit] = Switch[F].switch
165131

166132
val move: F[Unit] = getPlayer.flatMap(requireContext).flatMap(requireTrack).flatMap { player =>

app/src/main/scala/com/kubukoz/next/UserMessage.scala

+4-12
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ enum UserMessage {
6060
target: PlaybackTarget
6161
)
6262

63-
case Jumping(
64-
sectionNumber: Int,
65-
sectionsTotal: Int,
66-
percentTotal: Int
67-
)
68-
6963
case Seeking(
7064
desiredProgressPercent: Int
7165
)
@@ -152,12 +146,10 @@ object UserOutput {
152146
.name}" (${player.item.uri.toFullUri}) to playlist ${targetPlaylist.playlist}"""
153147
case TooCloseToEnd => "Too close to song's ending, rewinding to beginning"
154148
case Seeking(desiredProgressPercent) => show"Seeking to $desiredProgressPercent%"
155-
case Jumping(sectionNumber, sectionsTotal, percentTotal) =>
156-
show"Jumping to section $sectionNumber/$sectionsTotal ($percentTotal%)"
157-
case CheckingSonos => show"Checking if Sonos API is available at $sonosBaseUrl..."
158-
case SonosNotFound => "Sonos not found, using fallback"
159-
case NoDevices => "No Spotify devices found, can't switch playback"
160-
case SwitchingPlayback(target) =>
149+
case CheckingSonos => show"Checking if Sonos API is available at $sonosBaseUrl..."
150+
case SonosNotFound => "Sonos not found, using fallback"
151+
case NoDevices => "No Spotify devices found, can't switch playback"
152+
case SwitchingPlayback(target) =>
161153
val targetString = target match {
162154
case PlaybackTarget.Spotify(device) => show"Spotify (${device.name}, ID: ${device.id.map(_.value)})"
163155
case PlaybackTarget.Sonos(group) => show"Sonos (${group.name}, ID: ${group.id})"

app/src/main/smithy/spotify.smithy

-26
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ service SpotifyApi {
1212
NextTrack
1313
Seek
1414
RemoveTrack
15-
GetAudioAnalysis
1615
TransferPlayback
1716
GetAvailableDevices
1817
GetPlayer
@@ -95,31 +94,6 @@ structure Track {
9594
uri: String
9695
}
9796

98-
@http(method: "GET", uri: "/v1/audio-analysis/{trackId}")
99-
@readonly
100-
operation GetAudioAnalysis {
101-
input := {
102-
@httpLabel
103-
@required
104-
trackId: String
105-
}
106-
107-
output := {
108-
@required
109-
sections: Sections
110-
}
111-
}
112-
113-
list Sections {
114-
member: Section
115-
}
116-
117-
structure Section {
118-
@required
119-
@jsonName("start")
120-
startSeconds: Double
121-
}
122-
12397
@http(method: "GET", uri: "/v1/me/player")
12498
@readonly
12599
operation GetPlayer {

completions.zsh

-6
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ function _sn() {
88
'skip:Skip to next track without any changes'
99
'drop:Drop current track from the current playlist and skip to the next track'
1010
'forward:Fast forward the current track by a percentage of its length (10% by default)'
11-
'jump:Fast forward the current track to the next section'
1211
'switch:Switch device (Spotify/Sonos)'
1312
'move:Move song to playlist A'
1413
's:alias for `skip`'
1514
'd:alias for `drop`'
1615
'f:alias for `forward`'
17-
'j:alias for `jump`'
1816
'w:alias for `switch`'
1917
'm:alias for `move`'
2018
'repl:Run application in interactive mode'
@@ -42,10 +40,6 @@ function _sn() {
4240
_arguments -C $help
4341
;;
4442

45-
jump)
46-
_arguments -C $help
47-
;;
48-
4943
move)
5044
_arguments -C $help
5145
;;

0 commit comments

Comments
 (0)