diff --git a/go.mod b/go.mod index 0089d06..a112d37 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/internal/status/status.go b/internal/status/status.go index 2058e3a..a8e85d7 100644 --- a/internal/status/status.go +++ b/internal/status/status.go @@ -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) @@ -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++ { @@ -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 } diff --git a/main.go b/main.go index e91cab0..6cb7e23 100644 --- a/main.go +++ b/main.go @@ -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" @@ -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})