Ejemplo n.º 1
0
    // End: GetArtistFanart

    // Begin: GetArtistThumbs (Fanart.TV, htBackdrops, Last.FM)
    public int GetArtistThumbs(string artist, DatabaseManager dbm, bool onlyMissing)
    {
      var res = 0;
      var flag = true;
      var mbid = (string) null;

      if (string.IsNullOrEmpty(artist))
        return res ;

      if (!Utils.ScrapeThumbnails)
      {
        logger.Debug("Artist Thumbnails - Disabled.");
        return res ;
      }

      if (Utils.GetDbm().HasArtistThumb(Utils.GetArtist(artist, Utils.Category.MusicFanartScraped)) && onlyMissing)
        return 1;

      logger.Debug("--- Thumb --- " + artist + " ---");
      logger.Debug("Trying to find Thumbs for Artist: " + artist);

      // *** MusicBrainzID
      mbid = GetMusicBrainzID(artist, null) ;
      if (string.IsNullOrEmpty(mbid) || (mbid.Length < 10))
        // *** Get MBID & Search result from htBackdrop
        if (alSearchResults == null)
          flag = GethtBackdropsSearchResult(artist,"5");
      //
      while (true)
      {
        // *** Fanart.TV
        if (flag) 
          {
            if (alSearchResults != null) 
              if ((alSearchResults.Count > 0) && (string.IsNullOrEmpty(mbid) || (mbid.Length < 10)))
                mbid = ((SearchResults) alSearchResults[0]).MBID ;
            if ((mbid != null) && (mbid.Length > 10))
              res = FanartTVGetPictures(Utils.Category.MusicArtistThumbScraped, mbid, artist, null, 1, false, false, true) ;
          }
        if (dbm.StopScraper)
          break;

        // ** Get MBID & Search result from htBackdrop
        if (alSearchResults == null)
          flag = GethtBackdropsSearchResult(artist,"5");

        // *** htBackdrops
        if (res == 0)
        {
          if (flag)
            res = HtBackdropGetThumbsImages(artist, dbm, onlyMissing) ;
        }
        if (dbm.StopScraper)
          break;

        // *** Last.FM
        if (res == 0) 
        {
          res = LastFMGetTumbnails(Utils.Category.MusicArtistThumbScraped, artist, null, false);
        }
        break;
      } // while

      // *** Dummy
      if (res == 0)
      {
        if (alSearchResults != null) 
          if ((alSearchResults.Count > 0) && (string.IsNullOrEmpty(mbid) || (mbid.Length < 10)))
            mbid = ((SearchResults) alSearchResults[0]).MBID ;
        if ((mbid != null) && (mbid.Length < 10))
          mbid = string.Empty;
        dbm.InsertDummyItem(Utils.GetArtist(artist, Utils.Category.MusicFanartScraped), null, mbid, Utils.Category.MusicArtistThumbScraped);
      }
      // 
      if (alSearchResults != null)
      {
        alSearchResults.Clear();
        ObjectMethods.SafeDispose(alSearchResults);
      }
      alSearchResults = null;
      //
      return res;
    }
Ejemplo n.º 2
0
    // Begin: GetArtistFanart (Fanart.TV, htBackdrops)
    public int GetArtistFanart(string artist, int iMax, DatabaseManager dbm, bool reportProgress, bool doTriggerRefresh, bool externalAccess, bool doScrapeFanart, bool onlyClearArt=false)
    {
      var res = 0;
      var flag = true;
      var mbid = (string) null;

      if (!doScrapeFanart)
        return 0;

      logger.Debug("--- Fanart --- " + artist + " ---");
      logger.Debug("Trying to find " + (onlyClearArt ? "Art from Fanart.tv" : "Fanart") + " for Artist: " + artist);

      if (dbm.TotArtistsBeingScraped == 0)
        ReportProgress (6.0, dbm, reportProgress, externalAccess) ;

      // *** MusicBrainzID
      mbid = GetMusicBrainzID(artist, null) ;
      if (string.IsNullOrEmpty(mbid) || (mbid.Length < 10))
        // *** Get MBID & Search result from htBackdrop
        if (alSearchResults == null)
          flag = GethtBackdropsSearchResult(artist, "1,5");

      ReportProgress (0.0, dbm, reportProgress, externalAccess) ;
      while (true)
      {
        // *** Fanart.TV
        if (flag) 
          {
            if (alSearchResults != null) 
              if ((alSearchResults.Count > 0) && (string.IsNullOrEmpty(mbid) || (mbid.Length < 10)))
                mbid = ((SearchResults) alSearchResults[0]).MBID ;
            if ((mbid != null) && (mbid.Length > 10))
                res = FanartTVGetPictures(Utils.Category.MusicFanartScraped, mbid, artist, null, iMax, doTriggerRefresh, externalAccess, doScrapeFanart, null, onlyClearArt) ;
          }
        ReportProgress (0.0, dbm, reportProgress, externalAccess) ;
        if (dbm.StopScraper)
          break;
        if (onlyClearArt)
          break;

        // ** Get MBID & Search result from htBackdrop
        if (alSearchResults == null)
          flag = GethtBackdropsSearchResult(artist, "1,5");
        ReportProgress (0.0, dbm, reportProgress, externalAccess) ;

        // *** htBackdrops
        if ((res == 0) || (res < iMax))
        {
          if (flag)
            res = HtBackdropGetFanart(artist, iMax, dbm, doTriggerRefresh, externalAccess, doScrapeFanart);
        }
        ReportProgress (0.0, dbm, reportProgress, externalAccess) ;
        if (dbm.StopScraper)
          break;

        // *** Dummy
        if (res == 0)
        {
          if (alSearchResults != null) 
            if ((alSearchResults.Count > 0) && (string.IsNullOrEmpty(mbid) || (mbid.Length < 10)))
              mbid = ((SearchResults) alSearchResults[0]).MBID ;
          if ((mbid != null) && (mbid.Length < 10))
            mbid = string.Empty;
          dbm.InsertDummyItem(Utils.GetArtist(artist, Utils.Category.MusicFanartScraped), null, mbid, Utils.Category.MusicFanartScraped);
        }
        ReportProgress (0.0, dbm, reportProgress, externalAccess) ;
        if (dbm.StopScraper)
          break;

        // *** Get Thumbs for Artist
        if (Utils.ScrapeThumbnails)
        {
          GetArtistThumbs(artist, dbm, true) ;
        }
        ReportProgress (0.0, dbm, reportProgress, externalAccess) ;
        break ;
      } // while
      //
      if (alSearchResults != null)
      {
        alSearchResults.Clear();
        ObjectMethods.SafeDispose(alSearchResults);
      }
      alSearchResults = null;
      //
      return res;
    }