From 6ec1898e97248eed88df0fa51d4538607fda8aef Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sat, 26 Sep 2020 13:07:52 +0200 Subject: [PATCH] Implemented handling of invalid ScreenScraper responses. --- es-app/src/scrapers/ScreenScraper.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/es-app/src/scrapers/ScreenScraper.cpp b/es-app/src/scrapers/ScreenScraper.cpp index 34590bdf8..1922a6c85 100644 --- a/es-app/src/scrapers/ScreenScraper.cpp +++ b/es-app/src/scrapers/ScreenScraper.cpp @@ -223,6 +223,24 @@ void ScreenScraperRequest::process(const std::unique_ptr& req, } processGame(doc, results); + + // For some files, screenscraper.fr consistently responds with the game name 'ZZZ(notgame)', + // or sometimes in the longer format 'ZZZ(notgame):Fichier Annexes - Non Jeux'. For instance + // this can happen for configuration files for DOS games such as 'setup.exe' and similar. + // We definitely don't want to save these to our gamelists, so we simply skip these + // responses. There also seems to be some cases where this type of response is randomly + // returned instead of a valid game name, and retrying a second time returns the proper + // name. But it's basically impossible to know which is the case, and we really can't + // compensate for errors in the scraper service. + for (auto it = results.cbegin(); it != results.cend(); it++) { + std::string gameName = Utils::String::toUpper((*it).mdl.get("name")); + if (gameName.substr(0, 12) == "ZZZ(NOTGAME)") { + LOG(LogWarning) << "ScreenScraperRequest - Received \"ZZZ(notgame)\" as game name, " + "ignoring response."; + results.pop_back(); + return; + } + } } void ScreenScraperRequest::processGame(const pugi::xml_document& xmldoc,