like and unlike

This commit is contained in:
jjohnstondev 2023-01-08 00:00:29 -08:00
parent 2c0543383b
commit 5be7be1682
2 changed files with 30 additions and 0 deletions

View File

@ -26,6 +26,10 @@ func Run(ctx *gctx.Context, client *spotify.Client, args []string) error {
return commands.PlayUrl(ctx, client, args)
case "pause":
return commands.Pause(ctx, client)
case "like":
return commands.Like(ctx, client)
case "unlike":
return commands.Unlike(ctx, client)
case "next":
return commands.Skip(ctx, client)
case "shuffle":

View File

@ -231,6 +231,32 @@ func Pause(ctx *gctx.Context, client *spotify.Client) error {
return nil
}
func Like(ctx *gctx.Context, client *spotify.Client) error {
playing, err := client.PlayerCurrentlyPlaying(ctx)
if err != nil {
return err
}
err = client.AddTracksToLibrary(ctx, playing.Item.ID)
if err != nil {
return err
}
ctx.Println("Pausing!")
return nil
}
func Unlike(ctx *gctx.Context, client *spotify.Client) error {
playing, err := client.PlayerCurrentlyPlaying(ctx)
if err != nil {
return err
}
err = client.RemoveTracksFromLibrary(ctx, playing.Item.ID)
if err != nil {
return err
}
ctx.Println("Pausing!")
return nil
}
func Skip(ctx *gctx.Context, client *spotify.Client) error {
err := client.Next(ctx)
if err != nil {