Exemple #1
0
        /// <summary>
        /// Get an artist
        /// </summary>
        /// <returns></returns>
        public static async Task <Artist> GetArtist(string artistId)
        {
            var json = await HttpHelper.GetSpotify("https://api.spotify.com/v1/artists/" + artistId);

            var obj = JsonConvert.DeserializeObject <artist>(json, new JsonSerializerSettings
            {
                TypeNameHandling       = TypeNameHandling.All,
                TypeNameAssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple
            });

            return(obj.ToPOCO());
        }
Exemple #2
0
        /// <summary>
        /// Get an artist's top tracks
        /// </summary>
        /// <param name="trackIds"></param>
        /// <returns></returns>
        public static async Task <List <Track> > GetArtistTopTracks(string artistId, string countryCode = "US")
        {
            var json = await HttpHelper.GetSpotify("https://api.spotify.com/v1/artists/" + artistId + "/top-tracks?country=" + countryCode);

            var obj = JsonConvert.DeserializeObject <trackarray>(json, new JsonSerializerSettings
            {
                TypeNameHandling       = TypeNameHandling.All,
                TypeNameAssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple
            });

            List <Track> tracks = new List <Track>();

            foreach (var item in obj.tracks)
            {
                tracks.Add(item.ToPOCO());
            }

            return(tracks);
        }
Exemple #3
0
        /// <summary>
        /// Get an artist's related artists
        /// </summary>
        /// <param name="artistId"></param>
        /// <returns></returns>
        public static async Task <List <Artist> > GetRelatedArtists(string artistId)
        {
            var json = await HttpHelper.GetSpotify("https://api.spotify.com/v1/artists/" + artistId + "/related-artists");

            var obj = JsonConvert.DeserializeObject <artistarray>(json, new JsonSerializerSettings
            {
                TypeNameHandling       = TypeNameHandling.All,
                TypeNameAssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple
            });

            List <Artist> artists = new List <Artist>();

            foreach (var item in obj.artists)
            {
                artists.Add(item.ToPOCO());
            }

            return(artists);
        }