Exemplo n.º 1
0
        void matchUrlToImageType(List<string> urls, ScraperGame scraperGame, ThumbSearchType thumbType)
        {
            string image1, image2;
            string[] tags;
            if (thumbType == ThumbSearchType.Covers)
            {
                image1 = scraperGame.BoxFrontUrl;
                image2 = scraperGame.BoxBackUrl;
                tags = new string[] { FRONT_IMAGE_TAG, BACK_IMAGE_TAG };
            }
            else
            {
                image1 = scraperGame.TitleScreenUrl;
                image2 = scraperGame.InGameUrl;
                tags = new string[] { TITLE_IMAGE_TAG, null };
            }

            bool found1 = !string.IsNullOrEmpty(image1);
            bool found2 = !string.IsNullOrEmpty(image2);

            bool checkTag1 = !string.IsNullOrEmpty(tags[0]);
            bool checkTag2 = !string.IsNullOrEmpty(tags[1]);

            for (int x = 0; x < urls.Count; x++)
            {
                string url = urls[x].ToLower();
                if (checkTag1 && !found1 && url.Contains(tags[0]))
                {
                    image1 = urls[x];
                    found1 = true;
                }
                else if (checkTag2 && !found2 && url.Contains(tags[1]))
                {
                    image2 = urls[x];
                    found2 = true;
                }
                else if (string.IsNullOrEmpty(image1))
                {
                    image1 = urls[x];
                }
                else if (string.IsNullOrEmpty(image2))
                {
                    image2 = urls[x];
                }

                if (found1 && found2)
                    break;
            }

            if (thumbType == ThumbSearchType.Covers)
            {
                scraperGame.BoxFrontUrl = image1;
                scraperGame.BoxBackUrl = image2;
            }
            else
            {
                scraperGame.TitleScreenUrl = image1;
                scraperGame.InGameUrl = image2;
            }
        }
Exemplo n.º 2
0
        bool searchForImages(List<Scraper> lScrapers, ScraperResultsCache resultsCache, ThumbSearchType searchType, ScraperGame scraperGame)
        {
            foreach (Scraper scraper in lScrapers)
            {
                ScraperResult result = resultsCache.GetResult(scraper);
                if (!doWork())
                    return false;
                if (result == null)
                    continue;

                if (searchType == ThumbSearchType.Fanart)
                {
                    if (scraper.PopulateFanart(result, scraperGame))
                        break;
                }
                else if (searchType == ThumbSearchType.Covers)
                {
                    if (scraper.PopulateCovers(result, scraperGame))
                        break;
                }
                else if (searchType == ThumbSearchType.Screens)
                {
                    if (scraper.PopulateScreens(result, scraperGame))
                        break;
                }
            }
            return true;
        }
Exemplo n.º 3
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);
        }