예제 #1
0
 public void AddArtist(Artist artist)
 {
     lastArtistPlayed.Add(artist);
 }
예제 #2
0
        public static void ShowTopSongs(Artist artist)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            int i = 1;
            foreach (var song in artist.topSongs)
            {
                Console.WriteLine("#" + i + song.title);
                i++;
            }

            Console.WriteLine("#0. Exit");
            Console.ResetColor();
            Console.WriteLine("What would you like to do?");
            string answer = Console.ReadLine();
            int num = 0;
            int.TryParse(answer, out num);
            if (num == 0)
                return;
            else
                System.Diagnostics.Process.Start(artist.topSongs[num - 1].url);
        }
예제 #3
0
 public static void ShowAlbums(Artist artist)
 {
     int i = 1;
     Console.ForegroundColor = ConsoleColor.Green;
     foreach (var album in artist.albums)
     {
         Console.WriteLine("#"+ i + " " + album.title);
         i++;
     }
     Console.ResetColor();
     Console.WriteLine("\nWhat album would you like to browse?");
     string albumNo = Console.ReadLine();
     int num = 0;
     int.TryParse(albumNo, out num);
     if (num > 0)
     {
         var album = artist.albums[num - 1];
             history.AddAlbum(album);
         string url = "https://api.spotify.com/v1/albums/" + album.id;
         var dyn = MakeRequest(url);
         GetAlbumSongs(album,dyn);
     }
 }
예제 #4
0
 public static void HandleArtist(dynamic obj)
 {
     foreach (var data in obj.artists.items)
     {
         var artist = new Artist();
         artist.name = data.name;
         artist.id = data.id;
         artist.url = data.external_urls.spotify;
         artists.Add(artist);
     }
     string next = obj.artists.next;
     if (!string.IsNullOrEmpty(next))
         HandleArtist(MakeRequest(next));
     else
         ShowResults();
 }
예제 #5
0
        public static void GetTopSongInfo(Artist artist, dynamic dyn)
        {
            if (artist.topSongs == null)
                artist.topSongs = new List<Song>();

            foreach (var song in dyn.tracks)
            {
                var newSong = new Song();
                newSong.title = song.name;
                newSong.id = song.id;
                newSong.url = song.external_urls.spotify;
                artist.topSongs.Add(newSong);
            }

            ShowTopSongs(artist);
        }
예제 #6
0
        public static void GetArtistInfo(Artist artist, dynamic dyn)
        {
            if(artist.albums==null)
            artist.albums = new List<Album>();

            foreach (var data in dyn.items)
            {
                var album = new Album();
                album.title = data.name;
                album.id = data.id;
                album.url = data.external_urls.spotify;
                artist.albums.Add(album);
            }

            string next = dyn.next;
            if (!string.IsNullOrEmpty(next))
                GetArtistInfo(artist, MakeRequest(next));
            else
                ShowAlbums(artist);
        }