public List <string> GetCoverUrls(ScraperResult result, out string coverFront, out string coverBack) { coverFront = null; coverBack = null; Dictionary <string, string> imageResults = scraper.Execute("get_cover_art", getDetailsParams(result.SiteId)); if (imageResults == null) { return(new List <string>()); } string baseUrl; imageResults.TryGetValue("game.baseurl", out baseUrl); if (imageResults.TryGetValue("game.cover.front", out coverFront) && !string.IsNullOrEmpty(coverFront)) { coverFront = expandUrl(coverFront, baseUrl); } if (imageResults.TryGetValue("game.cover.back", out coverBack) && !string.IsNullOrEmpty(coverBack)) { coverBack = expandUrl(coverBack, baseUrl); } List <string> urls = getImageUrls(imageResults, baseUrl); matchUrlToImageType(urls, ref coverFront, "front", ref coverBack, "back"); return(urls); }
public List <string> GetScreenUrls(ScraperResult result, out string titleScreen, out string inGame) { titleScreen = null; inGame = null; Dictionary <string, string> imageResults = scraper.Execute("get_screenshots", getDetailsParams(result.SiteId)); if (imageResults == null) { return(new List <string>()); } string baseUrl; imageResults.TryGetValue("game.baseurl", out baseUrl); if (imageResults.TryGetValue("game.screen.title", out titleScreen) && !string.IsNullOrEmpty(titleScreen)) { titleScreen = expandUrl(titleScreen, baseUrl); } if (imageResults.TryGetValue("game.screem.ingame", out inGame) && !string.IsNullOrEmpty(inGame)) { inGame = expandUrl(inGame, baseUrl); } List <string> urls = getImageUrls(imageResults, baseUrl); matchUrlToImageType(urls, ref titleScreen, "title", ref inGame, null); return(urls); }
public ScraperGame GetDetails(ScraperResult result) { Dictionary <string, string> paramList = new Dictionary <string, string>(); paramList["game.site_id"] = result.SiteId; Dictionary <string, string> results = scraper.Execute("get_details", paramList); if (results == null) { return(null); } string grade, title, yearmade, company, description, genre; results.TryGetValue("game.grade", out grade); results.TryGetValue("game.title", out title); results.TryGetValue("game.yearmade", out yearmade); results.TryGetValue("game.company", out company); results.TryGetValue("game.description", out description); results.TryGetValue("game.genre", out genre); if (!string.IsNullOrEmpty(genre) && genre.StartsWith("|")) { genre = genre.Remove(0, 1); } return(new ScraperGame(title, company, yearmade, grade, stripTags(description), genre)); }
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); }
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); }
public List <ScraperResult> GetMatches(RomMatch romMatch, out ScraperResult bestResult, out bool approved) { bestResult = null; approved = false; List <Scraper> lScrapers = new List <Scraper>(scrapers); //get parent title to try and match platform string searchPlatform = romMatch.Game.ParentEmulator.PlatformTitle; if (searchPlatform == "Unspecified") { searchPlatform = ""; } ScraperSearchParams searchParams = new ScraperSearchParams() { Term = RemoveSpecialChars(romMatch.Title), Platform = searchPlatform }; List <ScraperResult> results = new List <ScraperResult>(); foreach (Scraper scraper in lScrapers) { if (!doWork()) { return(null); } results.AddRange(scraper.GetMatches(searchParams)); } searchPlatform = searchPlatform.ToLower(); results = sortResults(results, searchPlatform, out approved); if (results.Count > 0) { bestResult = results[0]; } return(results); }
public List <string> GetFanartUrls(ScraperResult result, out string fanart) { fanart = null; Dictionary <string, string> imageResults = scraper.Execute("get_fanart", getDetailsParams(result.SiteId)); if (imageResults == null) { return(new List <string>()); } string baseUrl; imageResults.TryGetValue("game.baseurl", out baseUrl); List <string> results = getImageUrls(imageResults, baseUrl); if (results.Count > 0) { fanart = results[0]; } return(results); }
public void Add(Scraper scraper, ScraperResult result) { cachedResults[scraper] = result; }