Skip to content

Commit

Permalink
Adds playlist command, with list and detail subcommands. Upgrades API…
Browse files Browse the repository at this point in the history
… version
  • Loading branch information
twexler committed Jun 30, 2021
1 parent e9f1af4 commit bae6d85
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ module spotify

go 1.16


require (
github.com/blang/semver v3.5.1+incompatible
github.com/brianstrauch/spotify v0.3.1
github.com/brianstrauch/spotify v0.3.2
github.com/pkg/browser v0.0.0-20210606212950-a7b7a6107d32
github.com/rhysd/go-github-selfupdate v1.2.3
github.com/spf13/cobra v1.1.3
Expand Down
8 changes: 4 additions & 4 deletions internal/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func Show(playback *spotify.Playback) string {
isPlayingEmoji = "⏸"
}

progressBar := showProgressBar(playback.ProgressMs, playback.Item.DurationMs)
progressBar := showProgressBar(playback.ProgressMs, playback.Item.Duration)

status := prefixLineWithEmoji("🎵", playback.Item.Name)
status += prefixLineWithEmoji("🎤", artistLine)
Expand All @@ -77,9 +77,9 @@ func joinArtists(artists []spotify.Artist) string {
return list
}

func showProgressBar(progress, duration int) string {
func showProgressBar(progress int, duration *spotify.Duration) string {
const length = 16
bars := length * progress / duration
bars := length * progress / int(duration.Milliseconds())

status := fmt.Sprintf("%s [", formatTime(progress))
for i := 0; i < bars; i++ {
Expand All @@ -88,7 +88,7 @@ func showProgressBar(progress, duration int) string {
for i := bars; i < length; i++ {
status += " "
}
status += fmt.Sprintf("] %s", formatTime(duration))
status += fmt.Sprintf("] %s", formatTime(int(duration.Milliseconds())))

return status
}
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"spotify/internal/p"
"spotify/internal/pause"
"spotify/internal/play"
"spotify/internal/playlist"
"spotify/internal/queue"
"spotify/internal/repeat"
"spotify/internal/save"
Expand Down Expand Up @@ -50,6 +51,7 @@ func main() {
root.AddCommand(status.NewCommand())
root.AddCommand(unsave.NewCommand())
root.AddCommand(update.NewCommand())
root.AddCommand(playlist.NewCommand())

// Hide help command
root.SetHelpCommand(&cobra.Command{Hidden: true})
Expand Down

0 comments on commit bae6d85

Please # to comment.