public static SpotifyAlbum DownloadAlbumInfo(string albumId) { var uri = GetAlbumUri(albumId); var spotifyAlbum = new SpotifyAlbum(); HttpHelper.DownloadString(uri, (response) => { dynamic album = JsonConvert.DeserializeObject(response); spotifyAlbum.Name = album["name"].ToString(); var songCount = album["total_tracks"].ToString(); spotifyAlbum.SongCollection = new SpotifySong[int.Parse(songCount)]; for (var i = 0; i < spotifyAlbum.SongCollection.Length; i++) { var songData = album["tracks"]["items"][i].href.ToString(); songData = Path.GetFileName(songData); spotifyAlbum.SongCollection[i] = SpotifySong.DownloadSongInfo(songData); } spotifyAlbum.Artwork = spotifyAlbum.SongCollection[0].Artwork; }); return(spotifyAlbum); }
private static IEnumerable <SpotifySong> GetSet(dynamic setData) { var songCollection = new List <SpotifySong>(); var items = setData["items"]; var index = 0; for (index = 0; index < items.Count; index++) { var songUri = items[index]["track"].href.ToString(); SpotifySong song = SpotifySong.DownloadSongInfo(Path.GetFileName(songUri)); songCollection.Add(song); } return(songCollection); }