Skip to content

Commit f08b3e9

Browse files
authored
Remove jump / audio analysis feature (#562)
* Remove jump / audio analysis feature * Move smithy files to another module * workflows
1 parent e07887a commit f08b3e9

File tree

13 files changed

+36
-173
lines changed

13 files changed

+36
-173
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
run: sbt '++ ${{ matrix.scala }}' test
5555

5656
- name: Compress target directories
57-
run: tar cf targets.tar target app/.jvm/target app/.native/target project/target
57+
run: tar cf targets.tar app/.jvm/target target app/.native/target smithy-models/.native/target smithy-models/.jvm/target project/target
5858

5959
- name: Upload target directories
6060
uses: actions/upload-artifact@v4

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

+2-5
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ import cats.implicits.*
1313
import com.kubukoz.next.Spotify.DeviceInfo
1414
import com.kubukoz.next.api.sonos
1515
import com.kubukoz.next.sonos.SonosApi
16-
import com.kubukoz.next.sonos.SonosApiGen
1716
import com.kubukoz.next.spotify.SpotifyApi
18-
import com.kubukoz.next.spotify.SpotifyApiGen
1917
import com.kubukoz.next.util.Config
2018
import com.kubukoz.next.util.Config.Token
2119
import com.kubukoz.next.util.middlewares
@@ -107,8 +105,8 @@ object Program {
107105
val spotifyBaseUri = com.kubukoz.next.api.spotify.baseUri
108106

109107
for {
110-
given SpotifyApi[F] <- SimpleRestJsonBuilder(SpotifyApiGen).client[F](spotifyClient).uri(spotifyBaseUri).make.liftTo[F]
111-
given SonosApi[F] <- SimpleRestJsonBuilder(SonosApiGen).client[F](sonosClient).uri(sonos.baseUri).make.liftTo[F]
108+
given SpotifyApi[F] <- SimpleRestJsonBuilder(SpotifyApi).client[F](spotifyClient).uri(spotifyBaseUri).make.liftTo[F]
109+
given SonosApi[F] <- SimpleRestJsonBuilder(SonosApi).client[F](sonosClient).uri(sonos.baseUri).make.liftTo[F]
112110
result <- makeSpotifyInternal[F]
113111
} yield result
114112
}
@@ -128,7 +126,6 @@ object Program {
128126

129127
for {
130128
given Spotify.Playback[F] <- SpotifyChoice.choose[F].map(Spotify.Playback.makeFromChoice[F])
131-
given Analysis[F] <- Analysis.cached(Analysis.instance[F])
132129
} yield Spotify.instance[F]
133130
}
134131

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})"

build.sbt

+16-5
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,23 @@ val front = project
116116
.dependsOn(core)
117117
*/
118118

119+
lazy val smithyModels = crossProject(JVMPlatform, NativePlatform)
120+
.crossType(CrossType.Pure)
121+
.in(file("smithy-models"))
122+
.settings(
123+
commonSettings,
124+
libraryDependencies ++= Seq(
125+
"com.disneystreaming.smithy4s" %%% "smithy4s-core" % smithy4sVersion.value
126+
)
127+
)
128+
.enablePlugins(Smithy4sCodegenPlugin)
129+
.settings(
130+
Compile / smithy4sInputDirs := Seq((ThisBuild / baseDirectory).value / "smithy-models" / "src" / "main" / "smithy")
131+
)
132+
119133
val app = crossProject(JVMPlatform, NativePlatform)
120134
.crossType(CrossType.Pure)
135+
.dependsOn(smithyModels)
121136
.settings(commonSettings)
122137
.settings(
123138
libraryDependencies ++= Seq(
@@ -139,10 +154,6 @@ val app = crossProject(JVMPlatform, NativePlatform)
139154
)
140155
.settings(name := "spotify-next")
141156
.enablePlugins(BuildInfoPlugin)
142-
.settings(
143-
Compile / smithy4sInputDirs := Seq((ThisBuild / baseDirectory).value / "app" / "src" / "main" / "smithy")
144-
)
145-
.enablePlugins(Smithy4sCodegenPlugin)
146157
.jvmConfigure(
147158
_.settings(
148159
libraryDependencies ++= Seq(
@@ -162,4 +173,4 @@ val root =
162173
project
163174
.in(file("."))
164175
.enablePlugins(NoPublishPlugin)
165-
.aggregate(app.componentProjects.map(p => p: ProjectReference): _*)
176+
.aggregate(List(app, smithyModels).flatMap(_.componentProjects).map(p => p: ProjectReference): _*)

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
;;

smithy-build.json

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
{
2-
"version": "1.0",
3-
"sources": ["app/src/main/smithy"],
4-
"maven": {
5-
"dependencies": [
6-
"com.disneystreaming.alloy:alloy-core:0.3.13",
7-
"com.disneystreaming.smithy4s:smithy4s-protocol:0.18.31"
2+
"version" : "1.0",
3+
"sources" : [
4+
"smithy-models/src/main/smithy"
85
],
9-
"repositories": []
10-
}
11-
}
6+
"maven" : {
7+
"dependencies" : [
8+
"com.disneystreaming.alloy:alloy-core:0.3.13",
9+
"com.disneystreaming.smithy4s:smithy4s-protocol:0.18.31"
10+
],
11+
"repositories" : [
12+
]
13+
}
14+
}
File renamed without changes.

app/src/main/smithy/spotify.smithy smithy-models/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 {

0 commit comments

Comments
 (0)