add force argument to now playing
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
e39355fb69
commit
95c64ebd70
@ -13,7 +13,8 @@ var nowPlayingCmd = &cobra.Command{
|
||||
Aliases: []string{"now"},
|
||||
Short: "Shows song and artist of currently playing song",
|
||||
Long: `Shows song and artist of currently playing song, useful for scripting`,
|
||||
Args: cobra.MatchAll(cobra.RangeArgs(0, 1)),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
commands.NowPlaying(ctx)
|
||||
commands.NowPlaying(ctx, args)
|
||||
},
|
||||
}
|
||||
|
@ -962,7 +962,18 @@ func (c *Commands) LinkContext(ctx *gctx.Context) (string, error) {
|
||||
return state.PlaybackContext.ExternalURLs["spotify"], nil
|
||||
}
|
||||
|
||||
func (c *Commands) NowPlaying(ctx *gctx.Context) error {
|
||||
func (c *Commands) NowPlaying(ctx *gctx.Context, args []string) error {
|
||||
if len(args) > 0 {
|
||||
if args[0] == "force" {
|
||||
current, err := c.Client().PlayerCurrentlyPlaying(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
str := FormatSong(current)
|
||||
fmt.Println(str)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
song, err := cache.DefaultCache().GetOrDo("now_playing", func() (string, error) {
|
||||
current, err := c.Client().PlayerCurrentlyPlaying(ctx)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user