mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Added a ScreenScraper option to fallback to additional regions to allow scraping of country-specific games and unofficial releases.
This commit is contained in:
parent
18cd5efb7d
commit
bded2bf31f
|
@ -893,6 +893,28 @@ void GuiScraperMenu::openOtherOptions()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Whether to fallback to additional regions.
|
||||||
|
auto scraperRegionFallback = std::make_shared<SwitchComponent>(mWindow);
|
||||||
|
scraperRegionFallback->setState(Settings::getInstance()->getBool("ScraperRegionFallback"));
|
||||||
|
s->addWithLabel("ENABLE FALLBACK TO ADDITIONAL REGIONS", scraperRegionFallback);
|
||||||
|
s->addSaveFunc([scraperRegionFallback, s] {
|
||||||
|
if (scraperRegionFallback->getState() !=
|
||||||
|
Settings::getInstance()->getBool("ScraperRegionFallback")) {
|
||||||
|
Settings::getInstance()->setBool("ScraperRegionFallback",
|
||||||
|
scraperRegionFallback->getState());
|
||||||
|
s->setNeedsSaving();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Regions are not supported by TheGamesDB, so gray out the option if this scraper is selected.
|
||||||
|
if (Settings::getInstance()->getString("Scraper") == "thegamesdb") {
|
||||||
|
scraperRegionFallback->setEnabled(false);
|
||||||
|
scraperRegionFallback->setOpacity(DISABLED_OPACITY);
|
||||||
|
scraperRegionFallback->getParent()
|
||||||
|
->getChild(scraperRegionFallback->getChildIndex() - 1)
|
||||||
|
->setOpacity(DISABLED_OPACITY);
|
||||||
|
}
|
||||||
|
|
||||||
// Retry search on peer verification errors (TLS/certificate issues).
|
// Retry search on peer verification errors (TLS/certificate issues).
|
||||||
auto retry_peer_verification = std::make_shared<SwitchComponent>();
|
auto retry_peer_verification = std::make_shared<SwitchComponent>();
|
||||||
retry_peer_verification->setState(
|
retry_peer_verification->setState(
|
||||||
|
|
|
@ -610,14 +610,14 @@ void ScreenScraperRequest::processMedia(ScraperSearchResult& result,
|
||||||
std::string& fileFormat,
|
std::string& fileFormat,
|
||||||
std::string region)
|
std::string region)
|
||||||
{
|
{
|
||||||
pugi::xml_node art = pugi::xml_node(nullptr);
|
pugi::xml_node art {pugi::xml_node(nullptr)};
|
||||||
|
|
||||||
// Do an XPath query for media[type='$media_type'], then filter by region.
|
// Do an XPath query for media[type='$media_type'], then filter by region.
|
||||||
// We need to do this because any child of 'medias' has the form
|
// We need to do this because any child of 'medias' has the form
|
||||||
// <media type="..." region="..." format="...">
|
// <media type="..." region="..." format="...">
|
||||||
// and we need to find the right media for the region.
|
// and we need to find the right media for the region.
|
||||||
pugi::xpath_node_set results = media_list.select_nodes(
|
pugi::xpath_node_set results {media_list.select_nodes(
|
||||||
(static_cast<std::string>("media[@type='") + mediaType + "']").c_str());
|
(static_cast<std::string>("media[@type='") + mediaType + "']").c_str())};
|
||||||
|
|
||||||
if (results.size()) {
|
if (results.size()) {
|
||||||
// Videos and fan art don't have any region attributes, so just take the first entry
|
// Videos and fan art don't have any region attributes, so just take the first entry
|
||||||
|
@ -626,13 +626,23 @@ void ScreenScraperRequest::processMedia(ScraperSearchResult& result,
|
||||||
art = results.first().node();
|
art = results.first().node();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Region fallback: WOR(LD), US, CUS(TOM?), JP, EU.
|
std::string otherRegion;
|
||||||
for (auto _region : std::vector<std::string> {region, "wor", "us", "cus", "jp", "eu"}) {
|
if (Settings::getInstance()->getBool("ScraperRegionFallback")) {
|
||||||
|
// In case none of the regular fallback regions are found, try whatever is the
|
||||||
|
// first region in the returned results. This should capture games only released
|
||||||
|
// for specific countries and such as well as invalid database entries where the
|
||||||
|
// wrong region was defined. This fallback also includes the ss/ScreenScraper
|
||||||
|
// region which adds media for unofficial games (e.g. for OpenBOR and PICO-8).
|
||||||
|
otherRegion = results.first().node().attribute("region").as_string();
|
||||||
|
}
|
||||||
|
// Region fallback: world, USA, Japan, EU and custom.
|
||||||
|
for (auto regionEntry :
|
||||||
|
std::vector<std::string> {region, "wor", "us", "jp", "eu", "cus", otherRegion}) {
|
||||||
if (art)
|
if (art)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
for (auto node : results) {
|
for (auto node : results) {
|
||||||
if (node.node().attribute("region").value() == _region) {
|
if (node.node().attribute("region").value() == regionEntry) {
|
||||||
art = node.node();
|
art = node.node();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,6 +127,7 @@ void Settings::setDefaults()
|
||||||
mBoolMap["ScraperRespectExclusions"] = {true, true};
|
mBoolMap["ScraperRespectExclusions"] = {true, true};
|
||||||
mBoolMap["ScraperExcludeRecursively"] = {true, true};
|
mBoolMap["ScraperExcludeRecursively"] = {true, true};
|
||||||
mBoolMap["ScraperConvertUnderscores"] = {true, true};
|
mBoolMap["ScraperConvertUnderscores"] = {true, true};
|
||||||
|
mBoolMap["ScraperRegionFallback"] = {true, true};
|
||||||
mBoolMap["ScraperRetryPeerVerification"] = {false, false};
|
mBoolMap["ScraperRetryPeerVerification"] = {false, false};
|
||||||
|
|
||||||
// UI settings.
|
// UI settings.
|
||||||
|
|
Loading…
Reference in a new issue