mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 22:25:38 +00:00
Merge pull request #579 from cmitu/genesis-megadrive-tgdb
ScreenScraper: Eliminate duplicate requests for multiple platform entries
This commit is contained in:
commit
723b17ae4c
|
@ -127,19 +127,32 @@ void screenscraper_generate_scraper_requests(const ScraperSearchParams& params,
|
||||||
|
|
||||||
path = ssConfig.getGameSearchUrl(params.game->getFileName());
|
path = ssConfig.getGameSearchUrl(params.game->getFileName());
|
||||||
auto& platforms = params.system->getPlatformIds();
|
auto& platforms = params.system->getPlatformIds();
|
||||||
|
std::vector<unsigned short> p_ids;
|
||||||
|
|
||||||
|
// Get the IDs of each platform from the ScreenScraper list
|
||||||
for (auto platformIt = platforms.cbegin(); platformIt != platforms.cend(); platformIt++)
|
for (auto platformIt = platforms.cbegin(); platformIt != platforms.cend(); platformIt++)
|
||||||
{
|
{
|
||||||
auto mapIt = screenscraper_platformid_map.find(*platformIt);
|
auto mapIt = screenscraper_platformid_map.find(*platformIt);
|
||||||
|
|
||||||
if (mapIt != screenscraper_platformid_map.cend())
|
if (mapIt != screenscraper_platformid_map.cend())
|
||||||
{
|
{
|
||||||
path += "&systemeid=";
|
p_ids.push_back(mapIt->second);
|
||||||
path += HttpReq::urlEncode(std::to_string(mapIt->second));
|
|
||||||
}else{
|
}else{
|
||||||
LOG(LogWarning) << "ScreenScraper: no support for platform " << getPlatformName(*platformIt);
|
LOG(LogWarning) << "ScreenScraper: no support for platform " << getPlatformName(*platformIt);
|
||||||
|
// Add the scrape request without a platform/system ID
|
||||||
|
requests.push(std::unique_ptr<ScraperRequest>(new ScreenScraperRequest(requests, results, path)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort the platform IDs and remove duplicates
|
||||||
|
std::sort(p_ids.begin(), p_ids.end());
|
||||||
|
auto last = std::unique(p_ids.begin(), p_ids.end());
|
||||||
|
p_ids.erase(last, p_ids.end());
|
||||||
|
|
||||||
|
for (auto platform = p_ids.cbegin(); platform != p_ids.cend(); platform++)
|
||||||
|
{
|
||||||
|
path += "&systemeid=";
|
||||||
|
path += HttpReq::urlEncode(std::to_string(*platform));
|
||||||
requests.push(std::unique_ptr<ScraperRequest>(new ScreenScraperRequest(requests, results, path)));
|
requests.push(std::unique_ptr<ScraperRequest>(new ScreenScraperRequest(requests, results, path)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue