public ScraperResult GetResult(Scraper scraper)
 {
     ScraperResult result;
     if (!cachedResults.TryGetValue(scraper, out result))
     {
         result = scraper.GetFirstMatch(searchParams);
         if (result != null && result.SearchDistance > 2)
             result = null;
         cachedResults[scraper] = result;
     }
     return result;
 }
 List<Scraper> getSearchScrapers(Scraper preferredScraper, Scraper defaultScraper)
 {
     List<Scraper> lScrapers;
     if (thoroughThumbSearch)
     {
         lock (scraperSync)
             lScrapers = new List<Scraper>(scrapers);
         int offset = 0;
         if (preferredScraper != null)
         {
             lScrapers.Remove(preferredScraper);
             lScrapers.Insert(0, preferredScraper);
             offset = 1;
         }
         if (defaultScraper != preferredScraper)
         {
             lScrapers.Remove(defaultScraper);
             lScrapers.Insert(offset, defaultScraper);
         }
     }
     else
     {
         lScrapers = new List<Scraper>();
         if (preferredScraper != null)
             lScrapers.Add(preferredScraper);
         if (defaultScraper != preferredScraper)
             lScrapers.Add(defaultScraper);
     }
     return lScrapers;
 }
        public ScraperGame DownloadInfo(ScraperResult result)
        {
            Scraper defaultScraper = result.DataProvider;
            ScraperGame scraperGame = defaultScraper.GetDetails(result);
            if (scraperGame == null || !doWork())
                return null;

            Scraper coversScraper, screensScraper, fanartScraper;
            lock (scraperSync)
            {
                coversScraper = this.coversScraper;
                screensScraper = this.screensScraper;
                fanartScraper = this.fanartScraper;
            }

            ScraperResultsCache resultsCache = new ScraperResultsCache(result.Title, result.SearchParams);
            resultsCache.Add(defaultScraper, result);

            List<Scraper> searchScrapers = getSearchScrapers(coversScraper, defaultScraper);
            if (!searchForImages(searchScrapers, resultsCache, ThumbSearchType.Covers, scraperGame))
                return null; //doWork is false

            searchScrapers = getSearchScrapers(screensScraper, defaultScraper);
            if (!searchForImages(searchScrapers, resultsCache, ThumbSearchType.Screens, scraperGame))
                return null;

            searchScrapers = getSearchScrapers(fanartScraper, defaultScraper);
            searchForImages(searchScrapers, resultsCache, ThumbSearchType.Fanart, scraperGame);

            return scraperGame;
        }
        public void Update()
        {
            Options options = EmulatorsCore.Options;
            options.EnterReadLock();
            importTop = options.ImportTop;
            importExact = options.ImportExact;
            thoroughThumbSearch = options.TryAndFillMissingArt;
            string coversScraperId = options.PriorityCoversScraper;
            string screensScraperId = options.PriorityScreensScraper;
            string fanartScraperId = options.PriorityFanartScraper;
            options.ExitReadLock();

            lock (scraperSync)
            {
                scrapers = GetScrapers();
                foreach (Scraper scraper in scrapers)
                {
                    if (scraper.IdString == coversScraperId)
                        coversScraper = scraper;
                    if (scraper.IdString == screensScraperId)
                        screensScraper = scraper;
                    if (scraper.IdString == fanartScraperId)
                        fanartScraper = scraper;
                }
            }
        }
 public void Add(Scraper scraper, ScraperResult result)
 {
     cachedResults[scraper] = result;
 }