Example #1
0
        bool searchForImages(List <Scraper> lScrapers, ScraperResultsCache resultsCache, ThumbSearchType searchType, out string image1, out string image2)
        {
            image1 = null;
            image2 = null;
            foreach (Scraper scraper in lScrapers)
            {
                string        l1, l2;
                ScraperResult result = resultsCache.GetResult(scraper);
                if (!doWork())
                {
                    return(false);
                }
                if (result != null)
                {
                    if (searchType == ThumbSearchType.Fanart)
                    {
                        scraper.GetFanartUrls(result, out image1);
                    }
                    else
                    {
                        if (searchType == ThumbSearchType.Covers)
                        {
                            scraper.GetCoverUrls(result, out l1, out l2);
                        }
                        else
                        {
                            scraper.GetScreenUrls(result, out l1, out l2);
                        }
                        if (image1 == null)
                        {
                            image1 = l1;
                        }
                        if (image2 == null)
                        {
                            image2 = l2;
                        }
                    }

                    if (image1 != null && (image2 != null || searchType == ThumbSearchType.Fanart))
                    {
                        break;
                    }
                    if (!doWork())
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Example #2
0
        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 (scrapers)
            {
                coversScraper  = this.coversScraper;
                screensScraper = this.screensScraper;
                fanartScraper  = this.fanartScraper;
            }

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

            resultsCache.Add(defaultScraper, result);

            string         image1, image2;
            List <Scraper> searchScrapers = getSearchScrapers(coversScraper, defaultScraper);

            if (!searchForImages(searchScrapers, resultsCache, ThumbSearchType.Covers, out image1, out image2))
            {
                return(null); //doWork is false
            }
            scraperGame.BoxFrontUrl = image1;
            scraperGame.BoxBackUrl  = image2;

            searchScrapers = getSearchScrapers(screensScraper, defaultScraper);
            if (!searchForImages(searchScrapers, resultsCache, ThumbSearchType.Screens, out image1, out image2))
            {
                return(null);
            }
            scraperGame.TitleScreenUrl = image1;
            scraperGame.InGameUrl      = image2;

            searchScrapers = getSearchScrapers(fanartScraper, defaultScraper);
            searchForImages(searchScrapers, resultsCache, ThumbSearchType.Fanart, out image1, out image2);
            scraperGame.FanartUrl = image1;

            return(scraperGame);
        }