コード例 #1
0
    protected virtual void ShowArtistInfo(string artistName, string albumName)
    {
      Log.Debug("Looking up Artist: {0}", albumName);

      var dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);
      var pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);

      var errorEncountered = true;
      var artist = new ArtistInfo();
      var artistInfo = new MusicArtistInfo();
      if (m_database.GetArtistInfo(artistName, ref artist))
      { // we already have artist info in database so just use that
        artistInfo.Set(artist);
        errorEncountered = false;
      }
      else
      { // lookup artist details

        if (null != pDlgOK && !Win32API.IsConnectedToInternet())
        {
          pDlgOK.SetHeading(703);
          pDlgOK.SetLine(1, 703);
          pDlgOK.SetLine(2, string.Empty);
          pDlgOK.DoModal(GetID);
          return;
        }

        // show dialog box indicating we're searching the artist
        if (dlgProgress != null)
        {
          dlgProgress.Reset();
          dlgProgress.SetHeading(320);
          dlgProgress.SetLine(1, artistName);
          dlgProgress.SetLine(2, string.Empty);
          dlgProgress.SetPercentage(0);
          dlgProgress.StartModal(GetID);
          dlgProgress.Progress();
          dlgProgress.ShowProgressBar(true);
        }

        var scraper = new AllmusicSiteScraper();
        List<AllMusicArtistMatch> artists;
        if(scraper.GetArtists(artistName, out artists))
        {
          var selectedMatch = new AllMusicArtistMatch();
          if (artists.Count == 1)
          { // only have single match so no need to ask user
            Log.Debug("Single Artist Match Found");
            selectedMatch = artists[0];
            errorEncountered = false;
          }
          else
          {
            // need to get user to choose which one to use
            Log.Debug("Muliple Artist Match Found ({0}) prompting user", artists.Count);
            var pDlg = (GUIDialogSelect2) GUIWindowManager.GetWindow((int) Window.WINDOW_DIALOG_SELECT2);
            if (null != pDlg)
            {
              pDlg.Reset();
              pDlg.SetHeading(GUILocalizeStrings.Get(1303));
              foreach (var i in artists.Select(artistMatch => new GUIListItem
                                                                {
                                                                  Label = artistMatch.Artist + " - " + artistMatch.Genre,
                                                                  Label2 = artistMatch.YearsActive,
                                                                  Path = artistMatch.ArtistUrl,
                                                                  IconImage = artistMatch.ImageUrl
                                                                }))
              {
                pDlg.Add(i);
              }
              pDlg.DoModal(GetID);

              // and wait till user selects one
              var iSelectedMatch = pDlg.SelectedLabel;
              if (iSelectedMatch < 0)
              {
                return;
              }
              selectedMatch = artists[iSelectedMatch];
            }

            if (null != dlgProgress)
            {
              dlgProgress.Reset();
              dlgProgress.SetHeading(320);
              dlgProgress.SetLine(1, artistName);
              dlgProgress.SetLine(2, string.Empty);
              dlgProgress.SetPercentage(40);
              dlgProgress.StartModal(GetID);
              dlgProgress.ShowProgressBar(true);
              dlgProgress.Progress();
            }
          }
          string strHtml;
          if (scraper.GetArtistHtml(selectedMatch, out strHtml))
          {
            if (null != dlgProgress)
            {
              dlgProgress.SetPercentage(60);
              dlgProgress.Progress();
            }
            if (artistInfo.Parse(strHtml))
            {
              if (null != dlgProgress)
              {
                dlgProgress.SetPercentage(80);
                dlgProgress.Progress();
              }
              m_database.AddArtistInfo(artistInfo.Get());
              errorEncountered = false;
            }
          }
        }
      }

      if (null != dlgProgress)
      {
        dlgProgress.SetPercentage(100);
        dlgProgress.Progress();
        dlgProgress.Close();
        dlgProgress = null;
      }

      if (!errorEncountered)
      {
        var pDlgArtistInfo = (GUIMusicArtistInfo)GUIWindowManager.GetWindow((int)Window.WINDOW_ARTIST_INFO);
        if (null != pDlgArtistInfo)
        {
          pDlgArtistInfo.Artist = artistInfo;
          pDlgArtistInfo.DoModal(GetID);

          if (pDlgArtistInfo.NeedsRefresh)
          {
            m_database.DeleteArtistInfo(artistInfo.Artist);
            ShowArtistInfo(artistName, albumName);
          }
        }
      }
      else
      {
        Log.Debug("Unable to get artist details");

        if (null != pDlgOK)
        {
          pDlgOK.SetHeading(702);
          pDlgOK.SetLine(1, 702);
          pDlgOK.SetLine(2, string.Empty);
          pDlgOK.DoModal(GetID);
        }
      }    
    }
コード例 #2
0
    protected override void OnPageDestroy(int newWindowId)
    {
      //if (m_bRunning)
      //{
      //  m_bRunning = false;
      //  m_pParentWindow = null;
      //  GUIWindowManager.UnRoute();
      //}

      artistInfo = null;
      if (coverArtTexture != null)
      {
        coverArtTexture.Dispose();
        coverArtTexture = null;
      }
      base.OnPageDestroy(newWindowId);
    }
コード例 #3
0
 protected override void OnPageDestroy(int newWindowId)
 {
   artistInfo = null;
   base.OnPageDestroy(newWindowId);
 }
コード例 #4
0
        /// <summary>
        /// Get the details of the track
        /// </summary>
        /// <param name="trackObject"></param>
        private void GetDVDDetails(DBTrackInfo trackObject)
        {
            string strArtistHTML;
              string strAlbumHTML;
              string strArtistURL;
              bool songFound = false;

              List<DBTrackInfo> results = new List<DBTrackInfo>();

              string artist = trackObject.ArtistInfo[0].Artist;

              if (GetArtistHTML(artist, out strArtistHTML, out strArtistURL))
              {
            var artistInfo = new MusicArtistInfo();
            if (artistInfo.Parse(strArtistHTML))
            {
              artistInfo.Artist = artist;
              if (GetDVDURLList(strArtistURL))
              {
            // we have some albums - now check the tracks in each album
            foreach (string albumURL in _albumUrlList)
            {
              if (GetPageHTMLOnly(albumURL, out strAlbumHTML))
              {
                var albumInfo = new MusicAlbumInfo();
                if (albumInfo.Parse(strAlbumHTML))
                {
                  string[] tracksOnAlbum = albumInfo.Tracks.Split('|');
                  foreach (string track in tracksOnAlbum)
                  {
                    if (!string.IsNullOrEmpty(track.Trim()))
                    {
                      string[] trackData = track.Split('@');
                      if (trackObject.Track == trackData[1])
                      {
                        songFound = getTrackComposers(trackObject, strAlbumHTML, trackData[3]);
                        break;
                      }
                    }
                  }
                }
              }
            }
              }
            }
              }
        }
コード例 #5
0
        /// <summary>
        /// Get the details of the track
        /// </summary>
        /// <param name="trackObject"></param>
        private void GetTrackDetails(DBTrackInfo trackObject)
        {
            string strArtistHTML;
              string strAlbumHTML;
              string strArtistURL;
              bool songFound = false;
              const int trackName = 1;
              const int trackURL = 3;

              List<DBTrackInfo> results = new List<DBTrackInfo>();

              string strAlbumArtist = trackObject.ArtistInfo[0].Artist;

              if (GetArtistHTML(strAlbumArtist, out strArtistHTML, out strArtistURL))
              {
            var artistInfo = new MusicArtistInfo();
            if (artistInfo.Parse(strArtistHTML))
            {
              artistInfo.Artist = strAlbumArtist;
              if (GetAlbumURLList(strArtistURL))
              {
            // we have some albums - now check the tracks in each album
            foreach (string albumURL in _albumUrlList)
            {
              // If we found the song then exit...
              if (songFound)
                break;

              if (GetPageHTMLOnly(albumURL, out strAlbumHTML))
              {
                string strAlbum = Regex.Match(albumURL, "[^/]+-", RegexOptions.Singleline | RegexOptions.IgnoreCase).Value;
                strAlbum = Regex.Replace(strAlbum, "[-?*]", " ", RegexOptions.Singleline | RegexOptions.IgnoreCase);

                var albumInfo = AMGHTMLParser.ParseAlbumHTML(strAlbumHTML, strAlbum.Trim(), strAlbumArtist);

                if (albumInfo != null)
                {
                  string[] tracksOnAlbum = albumInfo.Tracks.Split('|');
                  foreach (string track in tracksOnAlbum)
                  {
                    if (!string.IsNullOrEmpty(track.Trim()))
                    {
                      string[] trackData = track.Split('@');

                      if (string.Equals(trackObject.Track, trackData[trackName], StringComparison.CurrentCultureIgnoreCase))
                      {
                        Logger.Debug("Get Composers for Track {0} by {1}", trackObject.Track, strAlbumArtist);
                        songFound = getTrackComposers(trackObject, strAlbumHTML, trackData[trackURL]);
                        Logger.Debug("Composers for Track {0} by {1} are {2}", trackObject.Track, strAlbumArtist, trackObject.Composers);
                        break;
                      }
                    }
                  }
                }
              }
            }
              }
            }
              }
        }
コード例 #6
0
    protected virtual void ShowArtistInfo(string artistName, string albumName)
    {
      GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK);
      GUIDialogProgress dlgProgress =
        (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);

      bool bSaveDb = true;
      bool bDisplayErr = false;

      ArtistInfo artist = new ArtistInfo();
      MusicArtistInfo artistInfo = new MusicArtistInfo();
      if (m_database.GetArtistInfo(artistName, ref artist))
      {
        artistInfo.Set(artist);
      }
      else
      {
        if (null != pDlgOK && !Win32API.IsConnectedToInternet())
        {
          pDlgOK.SetHeading(703);
          pDlgOK.SetLine(1, 703);
          pDlgOK.SetLine(2, string.Empty);
          pDlgOK.DoModal(GetID);
          return;
        }

        // show dialog box indicating we're searching the artist
        if (dlgProgress != null)
        {
          dlgProgress.Reset();
          dlgProgress.SetHeading(320);
          dlgProgress.SetLine(1, artistName);
          dlgProgress.SetLine(2, string.Empty);
          dlgProgress.SetPercentage(0);
          dlgProgress.StartModal(GetID);
          dlgProgress.Progress();
          dlgProgress.ShowProgressBar(true);
        }

        // find artist info
        AllmusicSiteScraper scraper = new AllmusicSiteScraper();
        if (scraper.FindInfo(AllmusicSiteScraper.SearchBy.Artists, artistName))
        {
          // did we find at least 1 artist?
          if (scraper.IsMultiple())
          {
            // let user choose one
            int iSelectedArtist = 0;
            string szText = GUILocalizeStrings.Get(181);
            GUIDialogSelect pDlg = (GUIDialogSelect)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_SELECT);
            if (null != pDlg)
            {
              pDlg.Reset();
              pDlg.SetHeading(szText);
              foreach (string selectedArtist in scraper.GetItemsFound())
              {
                pDlg.Add(selectedArtist);
              }
              pDlg.DoModal(GetID);

              // and wait till user selects one
              iSelectedArtist = pDlg.SelectedLabel;
              if (iSelectedArtist < 0)
              {
                return;
              }
            }

            // ok, now show dialog we're downloading the artist info
            if (null != dlgProgress)
            {
              dlgProgress.Reset();
              dlgProgress.SetHeading(320);
              dlgProgress.SetLine(1, artistName);
              dlgProgress.SetLine(2, string.Empty);
              dlgProgress.SetPercentage(40);
              dlgProgress.StartModal(GetID);
              dlgProgress.ShowProgressBar(true);
              dlgProgress.Progress();
            }

            // download the artist info
            if (!scraper.FindInfoByIndex(iSelectedArtist))
            {
              if (null != dlgProgress)
              {
                dlgProgress.Close();
              }
              return;
            }
          }

          if (null != dlgProgress)
          {
            dlgProgress.SetPercentage(60);
            dlgProgress.Progress();
          }

          // Now we have either a Single hit or a selected Artist
          // Parse it
          if (artistInfo.Parse(scraper.GetHtmlContent()))
          {
            // if the artist selected from allmusic.com does not match
            // the one from the file, override the one from the allmusic
            // with the one from the file so the info is correct in the
            // database...
            if (!artistInfo.Artist.Equals(artistName))
            {
              artistInfo.Artist = artistName;
            }

            if (bSaveDb)
            {
              // save to database
              m_database.AddArtistInfo(artistInfo.Get());
            }

            if (null != dlgProgress)
            {
              dlgProgress.SetPercentage(100);
              dlgProgress.Progress();
              dlgProgress.Close();
              dlgProgress = null;
            }
          }
          else
          {
            bDisplayErr = true;
          }
        }
        else
        {
          bDisplayErr = true;
        }
      }

      if (null != dlgProgress)
      {
        dlgProgress.Close();
      }

      if (!bDisplayErr)
      {
        // ok, show Artist info
        GUIMusicArtistInfo pDlgArtistInfo =
          (GUIMusicArtistInfo)GUIWindowManager.GetWindow((int)Window.WINDOW_ARTIST_INFO);
        if (null != pDlgArtistInfo)
        {
          pDlgArtistInfo.Artist = artistInfo;
          pDlgArtistInfo.DoModal(GetID);

          if (pDlgArtistInfo.NeedsRefresh)
          {
            m_database.DeleteArtistInfo(artistInfo.Artist);
            ShowArtistInfo(artistName, albumName);
            return;
          }
        }
      }
      else
      {
        if (null != dlgProgress)
        {
          dlgProgress.Close();
        }
        if (null != pDlgOK)
        {
          pDlgOK.SetHeading(702);
          pDlgOK.SetLine(1, 702);
          pDlgOK.SetLine(2, string.Empty);
          pDlgOK.DoModal(GetID);
        }
      }
    }
コード例 #7
0
        public bool GetDetails(ArtistItem artistItem)
        {
            if (string.IsNullOrEmpty(artistItem.Name))
            return false;
              string strArtistHTML;
              string strAlbumHTML;
              string strArtistURL;
              string artist = artistItem.Name;
              if (GetArtistHTML(artist, out strArtistHTML, out strArtistURL))
              {
            var artistInfo = new MusicArtistInfo();
            if (artistInfo.Parse(strArtistHTML))
            {
              artistInfo.Artist = artist;

              artistItem.Bio = artistInfo.AMGBiography;
              if (!string.IsNullOrEmpty(artistInfo.ImageURL))
            artistItem.Img_url = artistInfo.ImageURL;
              //setMusicVideoArtist(ref mv1, artistInfo, strArtistHTML);
              //GetArtistArt((DBArtistInfo)mv);
              return true;
            }
              }
              return false;
        }
コード例 #8
0
 /// <summary>
 /// Set the Artist information
 /// </summary>
 /// <param name="mv"></param>
 /// <param name="artistInfo"></param>
 private void setMusicVideoArtist(ref DBArtistInfo mv, MusicArtistInfo artistInfo)
 {
 }