From d94cdb013ff7a7a2e0fd55c50c1def6ff6ee4ade Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Thu, 3 Aug 2023 22:28:13 +0200 Subject: [PATCH] Added additional MD5 file hash logging to the scraper --- es-app/src/guis/GuiScraperSearch.cpp | 20 +++++++++++++++++++- es-app/src/scrapers/Scraper.h | 1 + es-app/src/scrapers/ScreenScraper.cpp | 5 +++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/es-app/src/guis/GuiScraperSearch.cpp b/es-app/src/guis/GuiScraperSearch.cpp index 73ef9c6c9..768723936 100644 --- a/es-app/src/guis/GuiScraperSearch.cpp +++ b/es-app/src/guis/GuiScraperSearch.cpp @@ -364,6 +364,7 @@ void GuiScraperSearch::search(ScraperSearchParams& params) else params.automaticMode = false; + mMD5Hash = ""; params.md5Hash = ""; if (!Utils::FileSystem::isDirectory(params.game->getPath())) params.fileSize = Utils::FileSystem::getFileSize(params.game->getPath()); @@ -422,6 +423,9 @@ void GuiScraperSearch::onSearchDone(std::vector& results) "FINISH", mSkipCallback)); } else { + LOG(LogDebug) + << "GuiScraperSearch::onSearchDone(): Scraper service did not return any results"; + mFoundGame = false; ComponentListRow row; row.addElement(std::make_shared("NO GAMES FOUND", font, color), true); @@ -443,6 +447,21 @@ void GuiScraperSearch::onSearchDone(std::vector& results) std::string gameName {results.at(i).mdl.get("name")}; std::string otherPlatforms; + if (mMD5Hash != "" && results.size() == 1 && results[0].md5Hash != "") { + if (results[0].md5Hash == mMD5Hash) { + LOG(LogDebug) << "GuiScraperSearch::onSearchDone(): Perfect match, MD5 digest " + "in server response identical to file hash"; + } + else if (results[0].md5Hash != "") { + LOG(LogDebug) << "GuiScraperSearch::onSearchDone(): Not a perfect match, MD5 " + "digest in server response not identical to file hash"; + } + else { + LOG(LogDebug) << "GuiScraperSearch::onSearchDone(): Server did not return an " + "MD5 digest, can't tell whether this is a perfect match"; + } + } + // As the platform names are found via reverse lookup there could be multiple entries. // So if any of the entries match the platforms of the last search, then just keep // this platform ID and remove the other ones. @@ -730,7 +749,6 @@ void GuiScraperSearch::update(int deltaTime) mCalculateMD5HashThread.join(); mLastSearch.md5Hash = mMD5Hash; mSearchHandle = startScraperSearch(mLastSearch); - mMD5Hash = ""; mNextSearch = false; } } diff --git a/es-app/src/scrapers/Scraper.h b/es-app/src/scrapers/Scraper.h index 9af2b0240..a42e154f3 100644 --- a/es-app/src/scrapers/Scraper.h +++ b/es-app/src/scrapers/Scraper.h @@ -62,6 +62,7 @@ struct ScraperSearchResult { MetaDataList mdl; std::string gameID; + std::string md5Hash; std::vector platformIDs; // How many more objects the scraper service allows to be downloaded diff --git a/es-app/src/scrapers/ScreenScraper.cpp b/es-app/src/scrapers/ScreenScraper.cpp index 034f796c1..ab935e0e9 100644 --- a/es-app/src/scrapers/ScreenScraper.cpp +++ b/es-app/src/scrapers/ScreenScraper.cpp @@ -373,6 +373,8 @@ void ScreenScraperRequest::processGame(const pugi::xml_document& xmldoc, result.mdl.set("name", Utils::String::replace(gameName, "\n", "")); LOG(LogDebug) << "ScreenScraperRequest::processGame(): Name: " << result.mdl.get("name"); + LOG(LogDebug) << "ScreenScraperRequest::processGame(): Game ID: " << result.gameID; + // Validate rating. // Process the rating even if the setting to scrape ratings has been disabled. // This is required so that the rating can still be shown in the scraper GUI. @@ -567,6 +569,9 @@ void ScreenScraperRequest::processGame(const pugi::xml_document& xmldoc, // } // } + const pugi::xml_node rom {game.child("rom")}; + result.md5Hash = Utils::String::toLower(rom.child("rommd5").text().as_string()); + // Media super-node. pugi::xml_node media_list {game.child("medias")}; bool regionFallback {false};