Skip to content

Commit

Permalink
Merge pull request #187 from dvdmuckle/dev
Browse files Browse the repository at this point in the history
Release 1.2.0
  • Loading branch information
dvdmuckle authored Jan 28, 2024
2 parents 7de57f6 + 1d1cca7 commit a80687f
Show file tree
Hide file tree
Showing 29 changed files with 151 additions and 45 deletions.
2 changes: 1 addition & 1 deletion cmd/auth.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/completion.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/docs.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/helper/authHelp.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/helper/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/helper/errorLog.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/helper/playback.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/helper/structs.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/next.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 3 additions & 2 deletions cmd/pause.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -29,6 +29,7 @@ var pauseCmd = &cobra.Command{
helper.SetClient(&conf)
helper.Pause(&conf)
},
Aliases: []string{"stop"},
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/play.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/previous.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
10 changes: 5 additions & 5 deletions cmd/saveWeekly.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -67,16 +67,16 @@ only save the current playlist`,
break
}
}
discoverPlaylistTracks := func() spotify.PlaylistTrackPage {
playlistTracks, err := conf.Client.GetPlaylistTracks(ctx, discoverPlaylist)
discoverPlaylistTracks := func() spotify.PlaylistItemPage {
playlistTracks, err := conf.Client.GetPlaylistItems(ctx, discoverPlaylist)
if err != nil {
helper.LogErrorAndExit(err)
}
return *playlistTracks
}
var discoverPlaylistTrackIDs []spotify.ID
for _, track := range discoverPlaylistTracks().Tracks {
discoverPlaylistTrackIDs = append(discoverPlaylistTrackIDs, track.Track.ID)
for _, track := range discoverPlaylistTracks().Items {
discoverPlaylistTrackIDs = append(discoverPlaylistTrackIDs, track.Track.Track.ID)
}
conf.Client.AddTracksToPlaylist(ctx, newPlaylist.ID, discoverPlaylistTrackIDs...)
fmt.Printf("Discover Weekly saved as %s\n", playlistName)
Expand Down
2 changes: 1 addition & 1 deletion cmd/search.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/seek.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
49 changes: 49 additions & 0 deletions cmd/shuffle.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd

import (
"context"

"github.com/dvdmuckle/spc/cmd/helper"
"github.com/spf13/cobra"
)

// shuffleCmd represents the shuffle command
var shuffleCmd = &cobra.Command{
Use: "shuffle",
Short: "Toggle Spotify shuffle",
Long: `Will toggle shuffle on or off depending on its previous state`,
Run: func(cmd *cobra.Command, args []string) {
helper.SetClient(&conf)
ctx := context.Background()
forceSetShuffle, _ := cmd.Flags().GetBool("set")
if forceSetShuffle {
conf.Client.Shuffle(ctx, true)
return
}
state, err := conf.Client.PlayerState(ctx)
if err != nil {
helper.LogErrorAndExit("Error getting player state: ", err)
}
conf.Client.Shuffle(ctx, !state.ShuffleState)
},
}

func init() {
rootCmd.AddCommand(shuffleCmd)
shuffleCmd.Flags().BoolP("set", "s", false, "Set the shuffle state to on regardless of current state")
}
2 changes: 1 addition & 1 deletion cmd/status.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions cmd/switch.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -67,7 +67,7 @@ and can also switch playback to the already configured device.`,
transferPlayback(&conf, shouldPlay)
}
if err := viper.WriteConfigAs(cfgFile); err != nil {
helper.LogErrorAndExit("Error writing config:", err)
helper.LogErrorAndExit("Error writing config: ", err)
}
fmt.Println("Switched to", conf.DeviceID.String())

Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/volume.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021 David Muckle <[email protected]>
Copyright © 2024 David Muckle <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
8 changes: 8 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
spc (1.2.0-1) jammy; urgency=medium

* Add shuffle command
* Update copyright
* Update dependencies

-- David Muckle <[email protected]> Sun, 28 Jan 2024 16:17:28 -0500

spc (1.1.7-1) jammy; urgency=medium

* Update dependencies
Expand Down
1 change: 1 addition & 0 deletions docs/spc.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ scope, and is best when paired with another more complicated tool.
* [spc save-weekly](spc_save-weekly.md) - Saves the current Spotify Discover Weekly playlist
* [spc search](spc_search.md) - Search for and play a track, album, playlist, or artist
* [spc seek](spc_seek.md) - Seek to a specific position in the currently playing song from Spotify
* [spc shuffle](spc_shuffle.md) - Toggle Spotify shuffle
* [spc status](spc_status.md) - Get the currently playing song from Spotify
* [spc switch](spc_switch.md) - Set device to use for all callbacks
* [spc version](spc_version.md) - Print the version of spc
Expand Down
30 changes: 30 additions & 0 deletions docs/spc_shuffle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## spc shuffle

Toggle Spotify shuffle

### Synopsis

Will toggle shuffle on or off depending on its previous state

```
spc shuffle [flags]
```

### Options

```
-h, --help help for shuffle
-s, --set Set the shuffle state to on regardless of current state
```

### Options inherited from parent commands

```
--config string Config file (default is $HOME/.config/spc/config.yaml)
-v, --verbose verbose error logging
```

### SEE ALSO

* [spc](spc.md) - Command line tool to control Spotify

10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ require (
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.18.2
github.com/zalando/go-keyring v0.2.3
github.com/zmb3/spotify/v2 v2.4.0
golang.org/x/oauth2 v0.15.0
github.com/zmb3/spotify/v2 v2.4.1
golang.org/x/oauth2 v0.16.0
)

require (
Expand Down Expand Up @@ -44,9 +44,9 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
Expand Down
Loading

0 comments on commit a80687f

Please sign in to comment.