Esempio n. 1
0
        public static List<Album> DoFindAlbums(string artistId, string artistName)
        {
            string uri = string.Format("http://musicbrainz.org/ws/1/artist/{0}?type=xml&inc=sa-Official+release-events", artistId);
              XPathDocument doc = new XPathDocument(uri);
              XPathNavigator nav = doc.CreateNavigator();
              XmlNamespaceManager nsmgr = new XmlNamespaceManager(nav.NameTable);
              string ns = "http://musicbrainz.org/ns/mmd-1.0#";
              nsmgr.AddNamespace("mb", ns);
              XPathNodeIterator ni = nav.Select("//mb:release", nsmgr);
              List<Album> albums = new List<Album>();
              while (ni.MoveNext())
              {
            XPathNavigator current = ni.Current;
            Album album = new Album();
            album.Artist = artistName;
            album.Id = current.GetAttribute("id", string.Empty);
            current.MoveToChild("title", ns);
            album.Title = HttpUtility.HtmlDecode(current.InnerXml);

            current.MoveToParent();
            if (current.MoveToChild("asin", ns))
              album.Asin = current.InnerXml;

            current.MoveToParent();
            if (current.MoveToChild("release-event-list", ns))
            {
              current.MoveToChild("event", ns);
              string s = current.GetAttribute("date", string.Empty); // month and day may be missing
              album.Date = GetDate(s);
            }
            current.MoveToChild("title", ns);
            albums.Add(album);
              }
              return albums;
        }
Esempio n. 2
0
        public void ShowInfo(Album theAlbum)
        {
            album = theAlbum;

              ShowDetails();
              ShowCoverArt();
              ShowTracks();

              textBoxLyrics.Text = string.Empty;
        }
Esempio n. 3
0
        public static void DoGetAlbumDetails(Album album)
        {
            if (AreCredentialsMissing)
              {
            if (errorMessageShown) return;
            errorMessageShown = true;  // so we don't show the message again
            MessageBox.Show("To retrieve album details, Music Explorer requires access to the Amazon Associates Web Service. " +
                        "This service is free, but requires you to register for an associates account. " +
                        "See http://aws.amazon.com/associates for details. Once you have an account, enter " +
                        "your Account Number and Access Key ID in the Options->Amazon Credentials dialog box.",
                        "Not all album details available");
            return;
              }

              ItemLookup search = new ItemLookup();
              search.AssociateTag = Properties.Settings.Default.AmazonAwsAccountNumber;
              search.AWSAccessKeyId = Properties.Settings.Default.AmazonAwsAccessKeyId;

              ItemLookupRequest request = new ItemLookupRequest();
              request.ItemId = new string[] { album.Asin };
              request.IdType = ItemLookupRequestIdType.ASIN;
              request.ResponseGroup = new string[] { "Images", "ItemAttributes", "BrowseNodes" };
              search.Request = new ItemLookupRequest[] { request };

              ItemLookupResponse response = amazonWebService.ItemLookup(search);

              AmazonAws.Items items = response.Items[0];
              if (items.Item == null) return;
              if (items.Item.Length == 0) return;
              AmazonAws.Item item = items.Item[0];
              if (item == null) return;

              if (item.MediumImage == null)
            album.ImageUrl = null;
              else
            album.ImageUrl = item.MediumImage.URL;

              if (item.ItemAttributes != null)
            album.Label = item.ItemAttributes.Label;

              if (item.ItemAttributes.NumberOfDiscs != null)
            album.Discs = int.Parse(item.ItemAttributes.NumberOfDiscs);

              album.Genre = GetGenre(item);
        }
Esempio n. 4
0
 public static void GetAlbumDetails(Album album)
 {
     try
       {
     DoGetAlbumDetails(album);
       }
       catch (WebException wex)
       {
     MessageBox.Show(string.Format("A communication error occurred ({0}). The Amazon server might be down.", wex.Status), "Couldn't retrieve album details");
       }
       catch (Exception ex)
       {
     MessageBox.Show(string.Format("An error occurred ({0}). The error may have been caused by bad data from the Amazon server.", ex.Message), "Couldn't retrieve album details");
       }
 }