From 2de3897c8a8d43262fe90dca002c55ce8e28c912 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Tue, 24 Oct 2023 20:32:19 +0200 Subject: [PATCH] Fixed an issue where duplicate ScreenScraper game IDs were sometimes not removed from the search results --- es-app/src/scrapers/ScreenScraper.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/es-app/src/scrapers/ScreenScraper.cpp b/es-app/src/scrapers/ScreenScraper.cpp index b701d423c..19226591f 100644 --- a/es-app/src/scrapers/ScreenScraper.cpp +++ b/es-app/src/scrapers/ScreenScraper.cpp @@ -313,13 +313,16 @@ void ScreenScraperRequest::process(const std::unique_ptr& req, // If there are multiple platforms defined for the system, then it's possible that the scraper // service will return the same results for each platform, so we need to remove such duplicates. if (results.size() > 1) { - const std::string gameID {results.front().gameID}; - for (auto it = results.cbegin() + 1; it != results.cend();) { - if ((*it).gameID == gameID) { + std::vector gameIDs; + for (auto it = results.cbegin(); it != results.cend();) { + if (std::find(gameIDs.begin(), gameIDs.end(), (*it).gameID) != gameIDs.end()) { + LOG(LogDebug) + << "ScreenScraperRequest::process(): Removed duplicate entry for game ID " + << (*it).gameID; it = results.erase(it); - LOG(LogDebug) << "ScreenScraperRequest::process(): Removed duplicate entry"; } else { + gameIDs.emplace_back((*it).gameID); ++it; } }