Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="artist"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public LFMArtist GetArtistInfo(String artist, String mbid)
        {
            artist = System.Web.HttpUtility.UrlEncode(artist);

            String append = String.Empty;

            if (!String.IsNullOrEmpty(mbid))
            {
                append += "&mbid=" + mbid;
            }
            if (!String.IsNullOrEmpty(artist))
            {
                append += "&artist=" + artist;
            }

            String          endpoint   = String.Format("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&api_key=b25b959554ed76058ac220b7b2e0a026&limit=10{0}", append);
            HttpWebRequest  request    = (HttpWebRequest)HttpWebRequest.Create(endpoint);
            HttpWebResponse response   = (HttpWebResponse)request.GetResponse();
            XmlSerializer   serializer = new XmlSerializer(typeof(ArtistNS.lfm));

            ArtistNS.lfm lastfm = (ArtistNS.lfm)serializer.Deserialize(response.GetResponseStream());

            LFMArtist lfmArtist = new LFMArtist()
            {
                Name            = lastfm.artist.name,
                UrlLink         = lastfm.artist.url,
                ImageLinkSmall  = Array.Find(lastfm.artist.image, img => img.size.Equals("small")).Value,
                ImageLinkMedium = Array.Find(lastfm.artist.image, img => img.size.Equals("medium")).Value,
                ImageLinkLarge  = Array.Find(lastfm.artist.image, img => img.size.Equals("large")).Value,
                Summary         = lastfm.artist.bio.summary,
                Content         = lastfm.artist.bio.content
            };

            Array.ForEach(lastfm.artist.similar, sim => lfmArtist.SimilarArtist.Add(
                              new LFMArtist()
            {
                Name            = sim.name,
                UrlLink         = sim.url,
                ImageLinkSmall  = Array.Find(sim.image, img => img.size.Equals("small")).Value,
                ImageLinkMedium = Array.Find(sim.image, img => img.size.Equals("medium")).Value,
                ImageLinkLarge  = Array.Find(sim.image, img => img.size.Equals("large")).Value
            }));

            return(lfmArtist);
        }
Example #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="artist"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public LFMArtist GetArtistInfo(String artist, String mbid)
        {
            artist = System.Web.HttpUtility.UrlEncode(artist);

            String append = String.Empty;
            if (!String.IsNullOrEmpty(mbid))
                append += "&mbid=" + mbid;
            if (!String.IsNullOrEmpty(artist))
                append += "&artist=" + artist;

            String endpoint = String.Format("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&api_key=b25b959554ed76058ac220b7b2e0a026&limit=10{0}", append);
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(endpoint);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            XmlSerializer serializer = new XmlSerializer(typeof(ArtistNS.lfm));
            ArtistNS.lfm lastfm = (ArtistNS.lfm)serializer.Deserialize(response.GetResponseStream());

            LFMArtist lfmArtist = new LFMArtist()
                                    {
                                        Name = lastfm.artist.name,
                                        UrlLink = lastfm.artist.url,
                                        ImageLinkSmall = Array.Find(lastfm.artist.image, img => img.size.Equals("small")).Value,
                                        ImageLinkMedium = Array.Find(lastfm.artist.image, img => img.size.Equals("medium")).Value,
                                        ImageLinkLarge = Array.Find(lastfm.artist.image, img => img.size.Equals("large")).Value,
                                        Summary = lastfm.artist.bio.summary,
                                        Content = lastfm.artist.bio.content
                                    };

            Array.ForEach(lastfm.artist.similar, sim => lfmArtist.SimilarArtist.Add(
                                    new LFMArtist()
                                    {
                                        Name = sim.name,
                                        UrlLink = sim.url,
                                        ImageLinkSmall = Array.Find(sim.image, img => img.size.Equals("small")).Value,
                                        ImageLinkMedium = Array.Find(sim.image, img => img.size.Equals("medium")).Value,
                                        ImageLinkLarge = Array.Find(sim.image, img => img.size.Equals("large")).Value
                                    }));

            return lfmArtist;
        }