Added additional MD5 file hash logging to the scraper

This commit is contained in:
Leon Styhre 2023-08-03 22:28:13 +02:00
parent 40d27ff772
commit d94cdb013f
3 changed files with 25 additions and 1 deletions

View file

@ -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<ScraperSearchResult>& results)
"FINISH", mSkipCallback));
}
else {
LOG(LogDebug)
<< "GuiScraperSearch::onSearchDone(): Scraper service did not return any results";
mFoundGame = false;
ComponentListRow row;
row.addElement(std::make_shared<TextComponent>("NO GAMES FOUND", font, color), true);
@ -443,6 +447,21 @@ void GuiScraperSearch::onSearchDone(std::vector<ScraperSearchResult>& 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;
}
}

View file

@ -62,6 +62,7 @@ struct ScraperSearchResult {
MetaDataList mdl;
std::string gameID;
std::string md5Hash;
std::vector<PlatformIds::PlatformId> platformIDs;
// How many more objects the scraper service allows to be downloaded

View file

@ -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};