예제 #1
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;
        }
예제 #2
0
        public override bool PopulateFanart(ScraperResult result, ScraperGame scraperGame)
        {
            bool isPopulated = base.PopulateFanart(result, scraperGame);
            if (isPopulated)
                return true;

            List<string> urls = GetFanartUrls(result);
            if (urls.Count > 0 && !string.IsNullOrEmpty(urls[0]))
                scraperGame.FanartUrl = urls[0];

            return base.PopulateFanart(result, scraperGame);
        }
예제 #3
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;
            }
        }
예제 #4
0
        public override bool PopulateScreens(ScraperResult result, ScraperGame scraperGame)
        {
            Dictionary<string, string> imageResults = scraper.Execute("get_screenshots", getDetailsParams(result.SiteId));
            if (imageResults == null)
                return base.PopulateScreens(result, scraperGame);

            string baseUrl;
            imageResults.TryGetValue("game.baseurl", out baseUrl);

            bool hasFront = !string.IsNullOrEmpty(scraperGame.TitleScreenUrl);
            bool hasBack = !string.IsNullOrEmpty(scraperGame.InGameUrl);

            if (!hasFront)
            {
                string titleScreen;
                if (imageResults.TryGetValue("game.screen.title", out titleScreen) && !string.IsNullOrEmpty(titleScreen))
                {
                    titleScreen = expandUrl(titleScreen, baseUrl);
                    hasFront = true;
                }
            }

            if (!hasBack)
            {
                string inGame;
                if (imageResults.TryGetValue("game.screen.ingame", out inGame) && !string.IsNullOrEmpty(inGame))
                {
                    inGame = expandUrl(inGame, baseUrl);
                    hasBack = true;
                }
            }

            if (!hasFront || !hasBack)
            {
                List<string> urls = getImageUrls(imageResults, baseUrl);
                matchUrlToImageType(urls, scraperGame, ThumbSearchType.Screens);
            }

            return base.PopulateScreens(result, scraperGame);
        }
예제 #5
0
        public override bool PopulateCovers(ScraperResult result, ScraperGame scraperGame)
        {
            Dictionary<string, string> imageResults = scraper.Execute("get_cover_art", getDetailsParams(result.SiteId));
            if (imageResults == null)
                return base.PopulateCovers(result, scraperGame);

            string baseUrl;
            imageResults.TryGetValue("game.baseurl", out baseUrl);

            bool hasFront = !string.IsNullOrEmpty(scraperGame.BoxFrontUrl);
            bool hasBack = !string.IsNullOrEmpty(scraperGame.BoxBackUrl);

            if (!hasFront)
            {
                string coverFront;
                if (imageResults.TryGetValue("game.cover.front", out coverFront) && !string.IsNullOrEmpty(coverFront))
                {
                    scraperGame.BoxFrontUrl = expandUrl(coverFront, baseUrl);
                    hasFront = true;
                }
            }

            if (!hasBack)
            {
                string coverBack;
                if (string.IsNullOrEmpty(scraperGame.BoxBackUrl) && imageResults.TryGetValue("game.cover.back", out coverBack) && !string.IsNullOrEmpty(coverBack))
                {
                    scraperGame.BoxBackUrl = expandUrl(coverBack, baseUrl);
                    hasBack = true;
                }
            }

            if (!hasFront || !hasBack)
            {
                List<string> urls = getImageUrls(imageResults, baseUrl);
                matchUrlToImageType(urls, scraperGame, ThumbSearchType.Covers);
            }

            return base.PopulateCovers(result, scraperGame);
        }
예제 #6
0
 public virtual bool PopulateFanart(ScraperResult result, ScraperGame scraperGame) 
 {
     return !string.IsNullOrEmpty(scraperGame.FanartUrl);
 }
예제 #7
0
 public virtual bool PopulateScreens(ScraperResult result, ScraperGame scraperGame) 
 {
     return !string.IsNullOrEmpty(scraperGame.TitleScreenUrl) && !string.IsNullOrEmpty(scraperGame.InGameUrl);
 }
예제 #8
0
 public virtual bool PopulateCovers(ScraperResult result, ScraperGame scraperGame) 
 {
     return !string.IsNullOrEmpty(scraperGame.BoxFrontUrl) && !string.IsNullOrEmpty(scraperGame.BoxBackUrl);
 }