Esempio n. 1
0
        /// <summary>
        /// Get an artists Twitter Handle.
        /// </summary>
        /// <param name="artist">An artists EchoNest Entity.</param>
        /// <returns>A twitter handle.</returns>
        public async Task <string> GetArtistsTwitterHandle(EchoNest.Artist artist)
        {
            try
            {
                var echonestClient = new HttpClient();
                var response       =
                    await echonestClient.GetStringAsync(
                        new Uri(
                            string.Format("http://developer.echonest.com/api/v4/artist/twitter?api_key={0}&id={1}", ApiKey, artist.Id)));

                var artistTwitterResult = JsonConvert.DeserializeObject <Twitter>(response);
                if (artistTwitterResult == null)
                {
                    return(null);
                }
                if (artistTwitterResult.Response.Artist == null)
                {
                    return(null);
                }
                var topResult = artistTwitterResult.Response.Artist;
                return(topResult == null ? null : topResult.Twitter);
            }
            catch (Exception)
            {
                Debug.WriteLine("Error parsing echonest data.");
            }
            return(null);
        }
Esempio n. 2
0
        /// <summary>
        /// Get an artists music videos.
        /// </summary>
        /// <param name="artist">The artists EchoNest Entity.</param>
        /// <returns>A list of music videos.</returns>
        public async Task <List <Video> > GetArtistsVideos(EchoNest.Artist artist)
        {
            try
            {
                var echonestClient = new HttpClient();
                var response       =
                    await echonestClient.GetStringAsync(
                        new Uri(
                            string.Format("http://developer.echonest.com/api/v4/artist/video?api_key={0}&id={1}&format=json&start=0", ApiKey, artist.Id)));

                var artistVideos = JsonConvert.DeserializeObject <Videos>(response);
                if (artistVideos == null)
                {
                    return(null);
                }
                return(artistVideos.Response == null ? null : artistVideos.Response.Video.ToList());
            }
            catch (Exception)
            {
                Debug.WriteLine("Error parsing echonest data.");
            }
            return(null);
        }