nowplaying
This commit is contained in:
parent
c23e246017
commit
ecef56c4f0
@ -54,6 +54,8 @@ func Run(ctx *gctx.Context, client *spotify.Client, args []string) error {
|
|||||||
return commands.Status(ctx, client)
|
return commands.Status(ctx, client)
|
||||||
case "devices":
|
case "devices":
|
||||||
return commands.Devices(ctx, client)
|
return commands.Devices(ctx, client)
|
||||||
|
case "nowplaying":
|
||||||
|
return commands.NowPlaying(ctx, client)
|
||||||
case "setdevice":
|
case "setdevice":
|
||||||
return tui.DisplayDevices(ctx, client)
|
return tui.DisplayDevices(ctx, client)
|
||||||
default:
|
default:
|
||||||
|
@ -325,6 +325,14 @@ func Status(ctx *gctx.Context, client *spotify.Client) error {
|
|||||||
return PrintState(state)
|
return PrintState(state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NowPlaying(ctx *gctx.Context, client *spotify.Client) error {
|
||||||
|
current, err := client.PlayerCurrentlyPlaying(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return PrintPlaying(current)
|
||||||
|
}
|
||||||
|
|
||||||
func Shuffle(ctx *gctx.Context, client *spotify.Client) error {
|
func Shuffle(ctx *gctx.Context, client *spotify.Client) error {
|
||||||
state, err := client.PlayerState(ctx)
|
state, err := client.PlayerState(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -361,6 +369,10 @@ func TrackList(ctx *gctx.Context, client *spotify.Client, page int) (*spotify.Sa
|
|||||||
return client.CurrentUsersTracks(ctx, spotify.Limit(50), spotify.Offset((page-1)*50))
|
return client.CurrentUsersTracks(ctx, spotify.Limit(50), spotify.Offset((page-1)*50))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetQueue(ctx *gctx.Context, client *spotify.Client) (*spotify.Queue, error) {
|
||||||
|
return client.GetQueue(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
func Playlists(ctx *gctx.Context, client *spotify.Client, page int) (*spotify.SimplePlaylistPage, error) {
|
func Playlists(ctx *gctx.Context, client *spotify.Client, page int) (*spotify.SimplePlaylistPage, error) {
|
||||||
return client.CurrentUsersPlaylists(ctx, spotify.Limit(50), spotify.Offset((page-1)*50))
|
return client.CurrentUsersPlaylists(ctx, spotify.Limit(50), spotify.Offset((page-1)*50))
|
||||||
}
|
}
|
||||||
@ -380,6 +392,11 @@ func PrintState(state *spotify.PlayerState) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func PrintPlaying(current *spotify.CurrentlyPlaying) error {
|
||||||
|
fmt.Println(fmt.Sprintf("%s by %s", current.Item.Name, current.Item.Artists[0].Name))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func PrintDevices(devices []spotify.PlayerDevice) error {
|
func PrintDevices(devices []spotify.PlayerDevice) error {
|
||||||
out, err := json.MarshalIndent(devices, "", " ")
|
out, err := json.MarshalIndent(devices, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user