public int DoScrapeThumbs(string artist, bool onlyMissing)
 {
     if (!StopScraper)
     {
         try
         {
             var num = 0;
             if (artist != null && artist.Trim().Length > 0)
             {
                 var dbartist = Utils.GetArtist(artist, Utils.Category.MusicFanartScraped);
                 if (!HasArtistThumb(dbartist) || !onlyMissing)
                 {
                     scraper = new Scraper();
                     lock (lockObject)
                         dbClient.Execute("BEGIN TRANSACTION;");
                     num = scraper.GetArtistThumbs(artist, this, onlyMissing);
                     lock (lockObject)
                         dbClient.Execute("COMMIT;");
                     if (num == 0)
                         logger.Info("No Thumbs found for Artist: " + artist + ".");
                     scraper = null;
                 }
             }
             return num;
         }
         catch (Exception ex)
         {
             scraper = null;
             logger.Error("DoScrapeThumbs: " + ex);
             lock (lockObject)
                 dbClient.Execute("ROLLBACK;");
         }
     }
     return 0;
 }
        public int DoScrapeNew(string artist, string album, bool externalAccess)
        {
            if (!MediaPortal.Util.Win32API.IsConnectedToInternet())
            {
              logger.Debug("No internet connection detected. Cancelling new scrape.");
              return 0 ;
            }

            if (!StopScraper)
            {
                try
                {
                    var GetImages = 0;
                    if (artist != null && artist.Trim().Length > 0)
                    {
                    #region NowPlaying Artist
                        var dbartist = Utils.GetArtist(artist, Utils.Category.MusicFanartScraped);
                        var dbalbum = Utils.GetAlbum(album, Utils.Category.MusicFanartScraped);
                        var MaxImages = checked(Convert.ToInt32(Utils.ScraperMaxImages,CultureInfo.CurrentCulture));
                        var numberOfFanartImages = GetNumberOfFanartImages(dbartist);
                        var doTriggerRefresh = (numberOfFanartImages == 0 && !externalAccess);

                        if (checked (MaxImages - numberOfFanartImages) <= 0)
                          GetImages = 8888 ;
                        else
                          {
                            scraper = new Scraper();
                            lock (lockObject)
                                dbClient.Execute("BEGIN TRANSACTION;");
                            GetImages = scraper.GetArtistFanart(artist, MaxImages, this, false, doTriggerRefresh, externalAccess, true);
                            lock (lockObject)
                                dbClient.Execute("COMMIT;");
                            scraper = null;
                          }
                        switch (GetImages)
                        {
                            case 0:
                                if (GetNumberOfFanartImages(dbartist) == 0)
                                  logger.Info("No fanart found for Artist: " + artist + ".");
                                break;
                            case 8888:
                                UpdateTimeStamp(dbartist, null, Utils.Category.MusicFanartScraped) ;
                                logger.Info("Artist: " + artist + " has already maximum number of images. Will not download anymore images for this artist.");
                                break;
                        }
                        if (StopScraper)
                            return GetImages;
                    #endregion
                    #region NowPlaying Artist Thumb
                        if (Utils.ScrapeThumbnails)
                          if (!Utils.GetDbm().HasArtistThumb(dbartist))
                          {
                            scraper = new Scraper();
                            lock (lockObject)
                                dbClient.Execute("BEGIN TRANSACTION;");
                            scraper.GetArtistThumbs(artist, this, true);
                            lock (lockObject)
                                dbClient.Execute("COMMIT;");
                            scraper = null;
                          }
                          else
                            UpdateTimeStamp(dbartist, null, Utils.Category.MusicArtistThumbScraped) ;
                        if (StopScraper)
                            return GetImages;
                    #endregion
                    #region NowPlaying Album Thumb
                        if ((album != null && album.Trim().Length > 0) && Utils.ScrapeThumbnailsAlbum)
                          if (!Utils.GetDbm().HasAlbumThumb(dbartist,dbalbum))
                          {
                            scraper = new Scraper();
                            lock (lockObject)
                                dbClient.Execute("BEGIN TRANSACTION;");
                            scraper.GetArtistAlbumThumbs(artist, album, false, externalAccess);
                            lock (lockObject)
                                dbClient.Execute("COMMIT;");
                            scraper = null;
                          }
                          else
                            UpdateTimeStamp(dbartist, dbalbum, Utils.Category.MusicAlbumThumbScraped) ;
                        if (StopScraper)
                            return GetImages;
                    #endregion
                    } // if (artist != null && artist.Trim().Length > 0)
                    return GetImages;
                }
                catch (Exception ex)
                {
                    scraper = null;
                    logger.Error("DoScrapeNew: " + ex);
                    lock (lockObject)
                        dbClient.Execute("ROLLBACK;");
                }
            }
            return 0;
        }