Esempio n. 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="artistName"></param>
        /// <param name="albumName"></param>
        /// <returns></returns>
        public LFMAlbum GetAlbumInfo(String artistName, String albumName, String mbid)
        {
            artistName = System.Web.HttpUtility.UrlEncode(artistName);
            albumName = System.Web.HttpUtility.UrlEncode(albumName);

            String append = String.Empty;
            if (!String.IsNullOrEmpty(mbid))
                append += "&mbid=" + mbid;
            else
                append += "&album=" + albumName;

            String endpoint = String.Format("http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=b25b959554ed76058ac220b7b2e0a026&artist={0}&limit=10{1}", artistName, append);
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(endpoint);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            XmlSerializer serializer = new XmlSerializer(typeof(AlbumNS.lfm));
            AlbumNS.lfm lastfm = (AlbumNS.lfm)serializer.Deserialize(response.GetResponseStream());
            LFMAlbum lfmAlbum = new LFMAlbum()
            {
                Name = lastfm.album.name,
                UrlLink = lastfm.album.url,
                ImageLinkSmall = Array.Find(lastfm.album.image, img => img.size.Equals("small")).Value,
                ImageLinkMedium = Array.Find(lastfm.album.image, img => img.size.Equals("medium")).Value,
                ImageLinkLarge = Array.Find(lastfm.album.image, img => img.size.Equals("large")).Value,
                ImageLinkXLarge = Array.Find(lastfm.album.image, img => img.size.Equals("extralarge")).Value,
                Summary = lastfm.album.wiki.summary,
                Content = lastfm.album.wiki.content
            };

            return lfmAlbum;
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="artistName"></param>
        /// <param name="albumName"></param>
        /// <returns></returns>
        public LFMAlbum GetAlbumInfo(String artistName, String albumName, String mbid)
        {
            artistName = System.Web.HttpUtility.UrlEncode(artistName);
            albumName  = System.Web.HttpUtility.UrlEncode(albumName);

            String append = String.Empty;

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

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

            AlbumNS.lfm lastfm   = (AlbumNS.lfm)serializer.Deserialize(response.GetResponseStream());
            LFMAlbum    lfmAlbum = new LFMAlbum()
            {
                Name            = lastfm.album.name,
                UrlLink         = lastfm.album.url,
                ImageLinkSmall  = Array.Find(lastfm.album.image, img => img.size.Equals("small")).Value,
                ImageLinkMedium = Array.Find(lastfm.album.image, img => img.size.Equals("medium")).Value,
                ImageLinkLarge  = Array.Find(lastfm.album.image, img => img.size.Equals("large")).Value,
                ImageLinkXLarge = Array.Find(lastfm.album.image, img => img.size.Equals("extralarge")).Value,
                Summary         = lastfm.album.wiki.summary,
                Content         = lastfm.album.wiki.content
            };

            return(lfmAlbum);
        }