public void AddArtist(Artist artist) { lastArtistPlayed.Add(artist); }
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); }
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); } }
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(); }
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); }
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); }