예제 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            var checkedArtists = new List <SpotifyArtist>();

            // Adds any checked albums to database
            foreach (TreeNode node in treeView1.Nodes)
            {
                if (node.Checked)
                {
                    var newArtist = new SpotifyArtist();
                    newArtist.Name      = node.Text;
                    newArtist.SpotifyID = (string)node.Tag;
                    checkedArtists.Add(newArtist);
                }
            }

            List <SpotifyAlbum> allSpotifyAlbums = new List <SpotifyAlbum>();

            foreach (SpotifyArtist artist in checkedArtists)
            {
                var albumQuery = _musicLog.GetSpotifyAlbums(artist);
                _musicLog.AddAlbums(albumQuery, artist);
                allSpotifyAlbums.AddRange(albumQuery);
            }

            foreach (SpotifyAlbum album in allSpotifyAlbums)
            {
                var trackQuery = _musicLog.GetSpotifyTracks(album);
                _musicLog.AddTracks(trackQuery, album);
            }

            _musicLog.Save();
        }
예제 #2
0
        public void RetrieveMissingAlbums(SpotifyArtist artist)
        {
            List <SpotifyAlbum> spotifyAlbumRetrieval = GetSpotifyAlbums(artist);

            AddAlbums(spotifyAlbumRetrieval.Cast <IAlbum>().ToList(), artist);
            foreach (var album in spotifyAlbumRetrieval)
            {
                AddTracks(GetSpotifyTracks(album).Cast <ITrack>().ToList(), album);
            }
        }
예제 #3
0
        public static List <SimpleAlbum> SearchAlbums(SpotifyArtist artistObj, SpotifyWebAPI authObj)
        {
            Paging <SimpleAlbum> PagingObj       = authObj.GetArtistsAlbums(artistObj.SpotifyID, AlbumType.Album);
            List <SimpleAlbum>   SimpleAlbumList = new List <SimpleAlbum>();

            foreach (SimpleAlbum album in PagingObj.Items)
            {
                SimpleAlbumList.Add(album);
            }
            return(SimpleAlbumList);
        }
예제 #4
0
        private IArtist ArtistInDBConfirmation(SpotifyArtist artist)
        {
            // Makes sure artist exist, if not then adds to database
            // Returns instance of artist in the database
            SpotifyArtist foundArtist = (SpotifyArtist)_database.FindArtist(artist);

            if (foundArtist == null)
            {
                _database.AddArtist(artist);
                return(artist);
            }
            return(foundArtist);
        }
예제 #5
0
        public List <SpotifyAlbum> GetSpotifyAlbums(SpotifyArtist artistObj)
        {
            List <SimpleAlbum>  SimpleAlbumList = SpotifyApi.SearchAlbums(artistObj, _spotifyAuth);
            List <SpotifyAlbum> AlbumList       = new List <SpotifyAlbum>();

            foreach (SimpleAlbum album in SimpleAlbumList)
            {
                SpotifyAlbum newAlbum = new SpotifyAlbum
                {
                    Name      = album.Name,
                    SpotifyID = album.Id
                };
                AlbumList.Add(newAlbum);
            }
            return(GetUniqueSpotifyAlbums(AlbumList));
        }
예제 #6
0
        public List <SpotifyArtist> GetSpotifyArtists(string query)
        {
            List <FullArtist>    items      = SpotifyApi.SearchArtists(query, _spotifyAuth);
            List <SpotifyArtist> artistList = new List <SpotifyArtist>();

            foreach (FullArtist artist in items)
            {
                SpotifyArtist newArtist = new SpotifyArtist
                {
                    Name      = artist.Name,
                    SpotifyID = artist.Id
                };
                artistList.Add(newArtist);
            }
            return(artistList);
        }