diff --git a/internal/api/api.go b/internal/api/api.go index 8569a0b..f7f9f01 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -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": diff --git a/internal/commands/commands.go b/internal/commands/commands.go index 4937472..ceb354b 100644 --- a/internal/commands/commands.go +++ b/internal/commands/commands.go @@ -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 {