add force argument to now playing
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
abs3nt 2023-10-14 09:47:03 -07:00
parent e39355fb69
commit 95c64ebd70
Signed by: abs3nt
GPG Key ID: FDC6662313FA9386
2 changed files with 14 additions and 2 deletions

View File

@ -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)
},
}

View File

@ -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 {