artists albums and albums tracks
This commit is contained in:
parent
d06e95cdb7
commit
84a68c38b2
@ -56,6 +56,22 @@ func UserArtists(ctx *gctx.Context, client *spotify.Client, page int) (*spotify.
|
|||||||
return artists, nil
|
return artists, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ArtistAlbums(ctx *gctx.Context, client *spotify.Client, artist spotify.ID, page int) (*spotify.SimpleAlbumPage, error) {
|
||||||
|
albums, err := client.GetArtistAlbums(ctx, artist, []spotify.AlbumType{1, 2, 3, 4}, spotify.Market(spotify.CountryUSA), spotify.Limit(50), spotify.Offset((page-1)*50))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return albums, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func AlbumTracks(ctx *gctx.Context, client *spotify.Client, album spotify.ID, page int) (*spotify.SimpleTrackPage, error) {
|
||||||
|
tracks, err := client.GetAlbumTracks(ctx, album, spotify.Limit(50), spotify.Offset((page-1)*50), spotify.Market(spotify.CountryUSA))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return tracks, nil
|
||||||
|
}
|
||||||
|
|
||||||
func UserAlbums(ctx *gctx.Context, client *spotify.Client, page int) (*spotify.SavedAlbumPage, error) {
|
func UserAlbums(ctx *gctx.Context, client *spotify.Client, page int) (*spotify.SavedAlbumPage, error) {
|
||||||
albums, err := client.CurrentUsersAlbums(ctx, spotify.Limit(50), spotify.Offset((page-1)*50))
|
albums, err := client.CurrentUsersAlbums(ctx, spotify.Limit(50), spotify.Offset((page-1)*50))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -127,9 +127,10 @@ func (m *mainModel) LoadMoreItems() {
|
|||||||
items := []list.Item{}
|
items := []list.Item{}
|
||||||
for _, artist := range artists.Artists {
|
for _, artist := range artists.Artists {
|
||||||
items = append(items, mainItem{
|
items = append(items, mainItem{
|
||||||
Name: artist.Name,
|
Name: artist.Name,
|
||||||
ID: artist.ID,
|
ID: artist.ID,
|
||||||
Desc: fmt.Sprintf("%d followers, genres: %s, popularity: %d", artist.Followers.Count, artist.Genres, artist.Popularity),
|
Desc: fmt.Sprintf("%d followers, genres: %s, popularity: %d", artist.Followers.Count, artist.Genres, artist.Popularity),
|
||||||
|
SpotifyItem: artist.SimpleArtist,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
@ -146,9 +147,10 @@ func (m *mainModel) LoadMoreItems() {
|
|||||||
items := []list.Item{}
|
items := []list.Item{}
|
||||||
for _, album := range albums.Albums {
|
for _, album := range albums.Albums {
|
||||||
items = append(items, mainItem{
|
items = append(items, mainItem{
|
||||||
Name: album.Name,
|
Name: album.Name,
|
||||||
ID: album.ID,
|
ID: album.ID,
|
||||||
Desc: fmt.Sprintf("%s, %d tracks", album.Artists[0].Name, album.Tracks.Total),
|
Desc: fmt.Sprintf("%s, %d tracks", album.Artists[0].Name, album.Tracks.Total),
|
||||||
|
SpotifyItem: album.SimpleAlbum,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
@ -313,6 +315,9 @@ func (m mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
m.list.ResetSelected()
|
m.list.ResetSelected()
|
||||||
m.list.NewStatusMessage("Setting view to tracks")
|
m.list.NewStatusMessage("Setting view to tracks")
|
||||||
}
|
}
|
||||||
|
case "albums":
|
||||||
|
album := m.list.SelectedItem().(mainItem).SpotifyItem.(spotify.SimpleAlbum)
|
||||||
|
m.list.NewStatusMessage("Opening " + album.Name)
|
||||||
case "playlist":
|
case "playlist":
|
||||||
currentlyPlaying = m.list.SelectedItem().FilterValue()
|
currentlyPlaying = m.list.SelectedItem().FilterValue()
|
||||||
m.list.NewStatusMessage("Playing " + currentlyPlaying)
|
m.list.NewStatusMessage("Playing " + currentlyPlaying)
|
||||||
@ -440,9 +445,10 @@ func ArtistsView(ctx *gctx.Context, client *spotify.Client) ([]list.Item, error)
|
|||||||
}
|
}
|
||||||
for _, artist := range artists.Artists {
|
for _, artist := range artists.Artists {
|
||||||
items = append(items, mainItem{
|
items = append(items, mainItem{
|
||||||
Name: artist.Name,
|
Name: artist.Name,
|
||||||
ID: artist.ID,
|
ID: artist.ID,
|
||||||
Desc: fmt.Sprintf("%d followers, genres: %s, popularity: %d", artist.Followers.Count, artist.Genres, artist.Popularity),
|
Desc: fmt.Sprintf("%d followers, genres: %s, popularity: %d", artist.Followers.Count, artist.Genres, artist.Popularity),
|
||||||
|
SpotifyItem: artist.SimpleArtist,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return items, nil
|
return items, nil
|
||||||
@ -456,9 +462,10 @@ func AlbumsView(ctx *gctx.Context, client *spotify.Client) ([]list.Item, error)
|
|||||||
}
|
}
|
||||||
for _, album := range albums.Albums {
|
for _, album := range albums.Albums {
|
||||||
items = append(items, mainItem{
|
items = append(items, mainItem{
|
||||||
Name: album.Name,
|
Name: album.Name,
|
||||||
ID: album.ID,
|
ID: album.ID,
|
||||||
Desc: fmt.Sprintf("%s, %d tracks", album.Artists[0].Name, album.Tracks.Total),
|
Desc: fmt.Sprintf("%s, %d tracks", album.Artists[0].Name, album.Tracks.Total),
|
||||||
|
SpotifyItem: album.SimpleAlbum,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return items, nil
|
return items, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user