gitea
This commit is contained in:
parent
a6d53b28ae
commit
ba0830c6f4
@ -4,10 +4,12 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"math/rand"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"gospt/ctx"
|
"gospt/ctx"
|
||||||
|
|
||||||
@ -47,6 +49,40 @@ func PlayUrl(ctx *ctx.Context, client *spotify.Client, args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Radio(ctx *ctx.Context, client *spotify.Client) error {
|
||||||
|
rand.Seed(time.Now().Unix())
|
||||||
|
current_song, err := client.PlayerCurrentlyPlaying(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
seed := spotify.Seeds{
|
||||||
|
Tracks: []spotify.ID{current_song.Item.ID},
|
||||||
|
}
|
||||||
|
recomendations, err := client.GetRecommendations(ctx, seed, &spotify.TrackAttributes{}, spotify.Limit(100))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, song := range recomendations.Tracks {
|
||||||
|
fmt.Println(song.Name)
|
||||||
|
}
|
||||||
|
fmt.Println("QUEUED")
|
||||||
|
for i := 0; i < 4; i++ {
|
||||||
|
seed_track := recomendations.Tracks[3]
|
||||||
|
seed := spotify.Seeds{
|
||||||
|
Tracks: []spotify.ID{seed_track.ID},
|
||||||
|
}
|
||||||
|
recomendations, err = client.GetRecommendations(ctx, seed, &spotify.TrackAttributes{}, spotify.Limit(100))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, song := range recomendations.Tracks {
|
||||||
|
fmt.Println(song.Name)
|
||||||
|
}
|
||||||
|
fmt.Println("QUEUED")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func Devices(ctx *ctx.Context, client *spotify.Client) error {
|
func Devices(ctx *ctx.Context, client *spotify.Client) error {
|
||||||
devices, err := client.PlayerDevices(ctx)
|
devices, err := client.PlayerDevices(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -30,6 +30,8 @@ func Run(ctx *ctx.Context, client *spotify.Client, args []string) error {
|
|||||||
return commands.Skip(ctx, client)
|
return commands.Skip(ctx, client)
|
||||||
case "shuffle":
|
case "shuffle":
|
||||||
return commands.Shuffle(ctx, client)
|
return commands.Shuffle(ctx, client)
|
||||||
|
case "radio":
|
||||||
|
return commands.Radio(ctx, client)
|
||||||
case "tracks":
|
case "tracks":
|
||||||
return tui.DisplayList(ctx, client)
|
return tui.DisplayList(ctx, client)
|
||||||
case "status":
|
case "status":
|
||||||
|
Loading…
Reference in New Issue
Block a user