public async Task <List <BasicSong> > GetPlaylistTracks(string playlist) { Console.WriteLine($"Getting tracks for playlist {playlist}"); List <BasicSong> final = new List <BasicSong>(); Paging <PlaylistTrack <IPlayableItem> > firstPage = await this.spotify.Playlists.GetItems(playlist); await foreach (var item in spotify.Paginate(firstPage)) { if (item.Track is FullTrack track) { final.Add(new BasicSong(track.Artists[0].Name, track.Name, track.Album.Name)); } } return(final); }
private static async Task <List <FullTrack> > GetPlaylistSongs(SpotifyClient spotifyClient, string spotifyPlaylistId) { var playlistSongsRequest = await spotifyClient.Playlists.GetItems(spotifyPlaylistId).ConfigureAwait(false); var items = new List <FullTrack>(); await foreach (var item in spotifyClient.Paginate(playlistSongsRequest).ConfigureAwait(false)) { items.Add((FullTrack)item.Track); await Task.Delay(10).ConfigureAwait(false); } return(items); }
private static async Task <List <SavedTrack> > GetLibrarySongs(SpotifyClient spotifyClient) { var librarySongsRequest = await spotifyClient.Library.GetTracks().ConfigureAwait(false); var items = new List <SavedTrack>(); await foreach (var item in spotifyClient.Paginate(librarySongsRequest).ConfigureAwait(false)) { items.Add(item); await Task.Delay(10).ConfigureAwait(false); } return(items); }