public void AddAlbum(Album album)
        {
            AlbumTrackList albumTrackList = _client.GetAlbumTracks(album);

            _client.AddTracksToPlaylist(_playlist, albumTrackList.Tracks);
            RefreshPlaylist();
        }
Beispiel #2
0
        public void OnPlaylistChooserClosed(object sender, EventArgs e)
        {
            PlaylistChooser chooser = (PlaylistChooser)sender;

            if (chooser.SelectedPlaylist != null)
            {
                AlbumTrackList albumTrackList = SpotifyClientService.Client.GetAlbumTracks(_newReleaseItem.Album);
                SpotifyClientService.Client.AddTracksToPlaylist(chooser.SelectedPlaylist, albumTrackList.Tracks);
            }
        }
        public IEnumerable <Track> AddArtistSongsToPlaylist(Artist artist)
        {
            const int    numSongsPerArtist = 3; //TODO: Expose this to the user.
            TrackList    popularSongs      = _client.GetArtistTopTracks(artist);
            List <Track> songsToAdd        = new List <Track>(numSongsPerArtist);

            foreach (Track popularTrack in popularSongs.Tracks)
            {
                if (!this.ContainsTrack(popularTrack))
                {
                    songsToAdd.Add(popularTrack);

                    if (songsToAdd.Count >= numSongsPerArtist)
                    {
                        break;
                    }
                }
            }

            if (!songsToAdd.Any())
            {
                AlbumInfoList albumList = _client.GetArtistAlbums(artist);

                foreach (AlbumInfo album in albumList.Items)
                {
                    AlbumTrackList      albumTrackList          = _client.GetAlbumTracks(album);
                    IEnumerable <Track> albumTracksByPopularity = albumTrackList.Tracks.OrderByDescending(track => track.Popularity);
                    foreach (Track albumTrack in albumTracksByPopularity)
                    {
                        if (!this.ContainsTrack(albumTrack))
                        {
                            songsToAdd.Add(albumTrack);

                            if (songsToAdd.Count >= numSongsPerArtist)
                            {
                                break;
                            }
                        }
                    }

                    if (songsToAdd.Count >= numSongsPerArtist)
                    {
                        break;
                    }
                }
            }


            _client.AddTracksToPlaylist(_playlist, songsToAdd);

            return(songsToAdd);
        }
Beispiel #4
0
        public AlbumTrackList GetAlbumTracks(AlbumInfo album)
        {
            AlbumTrackList trackList = GetPagedRequest <AlbumTrackList>(Endpoints.GetAlbumTracks(album.ID), true);

            return(trackList);
        }