Added option to exclude files from the multi-scraper.

Two new scraper filters were added as well, 'Favorite games' and 'No game video'.
This commit is contained in:
Leon Styhre 2020-08-06 11:27:16 +02:00
parent 608138e810
commit 9f240394ed
5 changed files with 38 additions and 10 deletions

View file

@ -117,7 +117,15 @@ const bool FileData::getHidden()
const bool FileData::getCountAsGame()
{
if (metadata.get("countasgame") == "true")
if (metadata.get("nogamecount") == "true")
return false;
else
return true;
}
const bool FileData::getExcludeFromScraper()
{
if (metadata.get("nomultiscrape") == "true")
return true;
else
return false;

View file

@ -49,6 +49,7 @@ public:
const bool getFavorite();
const bool getHidden();
const bool getCountAsGame();
const bool getExcludeFromScraper();
const std::vector<FileData*> getChildrenRecursive() const;
inline FileType getType() const { return mType; }
inline const std::string& getPath() const { return mPath; }

View file

@ -24,10 +24,11 @@ MetaDataDecl gameDecls[] = {
{"players", MD_INT, "unknown", false, "players", "enter number of players", true},
{"favorite", MD_BOOL, "false", false, "favorite", "enter favorite off/on", false},
{"completed", MD_BOOL, "false", false, "completed", "enter completed off/on", false},
{"broken", MD_BOOL, "false", false, "broken/not working", "enter broken off/on", false},
{"hidden", MD_BOOL, "false", false, "hidden", "enter hidden off/on", false},
{"kidgame", MD_BOOL, "false", false, "kidgame", "enter kidgame off/on", false},
{"countasgame", MD_BOOL, "true", false, "count as game", "enter count as game off/on", false},
{"hidden", MD_BOOL, "false", false, "hidden", "enter hidden off/on", false},
{"broken", MD_BOOL, "false", false, "broken/not working", "enter broken off/on", false},
{"nogamecount", MD_BOOL, "false", false, "exclude from game counter", "enter don't count as game off/on", false},
{"nomultiscrape", MD_BOOL, "false", false, "exclude from multi-scraper", "enter no autoscrape off/on", false},
{"launchcommand", MD_LAUNCHCOMMAND, "", false, "launch command", "enter game launch command "
"(emulator override)", false},
{"playcount", MD_INT, "0", false, "play count", "enter number of times played", false},
@ -48,8 +49,9 @@ MetaDataDecl folderDecls[] = {
{"players", MD_INT, "unknown", false, "players", "enter number of players", true},
{"favorite", MD_BOOL, "false", false, "favorite", "enter favorite off/on", false},
{"completed", MD_BOOL, "false", false, "completed", "enter completed off/on", false},
{"broken", MD_BOOL, "false", false, "broken/not working", "enter broken off/on", false},
{"hidden", MD_BOOL, "false", false, "hidden", "enter hidden off/on", false},
{"broken", MD_BOOL, "false", false, "broken/not working", "enter broken off/on", false},
{"nomultiscrape", MD_BOOL, "false", false, "exclude from multi-scraper", "enter no autoscrape off/on", false},
{"lastplayed", MD_TIME, "0", true, "last played", "enter last played date", false}
};
const std::vector<MetaDataDecl> folderMDD(folderDecls, folderDecls +

View file

@ -38,14 +38,17 @@ GuiScraperMenu::GuiScraperMenu(Window* window) : GuiComponent(window),
// based on the outcome of the checks below.
mFilters = std::make_shared< OptionListComponent<GameFilterFunc>>
(mWindow, getHelpStyle(), "SCRAPE THESE GAMES", false);
mFilters->add("ALL GAMES",
[](SystemData*, FileData*) -> bool { return true; }, true);
mFilters->add("NO METADATA",
[](SystemData*, FileData* g) -> bool {
mFilters->add("ALL GAMES", [](SystemData*, FileData*) -> bool { return true; }, true);
mFilters->add("FAVORITE GAMES", [](SystemData*, FileData* g) -> bool {
return g->getFavorite(); }, false);
mFilters->add("NO METADATA", [](SystemData*, FileData* g) -> bool {
return g->metadata.get("desc").empty(); }, false);
mFilters->add("NO GAME IMAGE",
[](SystemData*, FileData* g) -> bool {
return g->getImagePath().empty(); }, false);
mFilters->add("NO GAME VIDEO",
[](SystemData*, FileData* g) -> bool {
return g->getVideoPath().empty(); }, false);
mMenu.addWithLabel("Filter", mFilters);
// Add systems (all systems with an existing platform ID are listed).
@ -280,6 +283,15 @@ void GuiScraperMenu::openOtherSettings()
Settings::getInstance()->setBool("ScraperSemiautomatic",
scraper_semiautomatic->getState()); });
// Respect the per-file multi-scraper exclusion flag.
auto scraper_respect_exclusions = std::make_shared<SwitchComponent>(mWindow);
scraper_respect_exclusions->setState(
Settings::getInstance()->getBool("ScraperRespectExclusions"));
s->addWithLabel("RESPECT PER-FILE SCRAPER EXCLUSIONS", scraper_respect_exclusions);
s->addSaveFunc([scraper_respect_exclusions] {
Settings::getInstance()->setBool("ScraperRespectExclusions",
scraper_respect_exclusions->getState()); });
mWindow->pushGui(s);
}
@ -327,7 +339,11 @@ std::queue<ScraperSearchParams> GuiScraperMenu::getSearches(
for (auto sys = systems.cbegin(); sys != systems.cend(); sys++) {
std::vector<FileData*> games = (*sys)->getRootFolder()->getFilesRecursive(GAME);
for (auto game = games.cbegin(); game != games.cend(); game++) {
if (selector((*sys), (*game))) {
// Skip scraping the game if the multi-scraper exclusion flag has been
// set for the file, and the flag to respect this value is also enabled.
bool skipGame = ((*game)->getExcludeFromScraper() &&
Settings::getInstance()->getBool("ScraperRespectExclusions") == true);
if (!skipGame && selector((*sys), (*game))) {
ScraperSearchParams search;
search.game = *game;
search.system = *sys;

View file

@ -154,6 +154,7 @@ void Settings::setDefaults()
mBoolMap["ScraperInteractive"] = true;
mBoolMap["ScraperSemiautomatic"] = true;
mBoolMap["ScraperOverwriteData"] = true;
mBoolMap["ScraperRespectExclusions"] = true;
mBoolMap["ScrapeMetadata"] = true;
mBoolMap["ScrapeGameNames"] = true;
mBoolMap["ScrapeRatings"] = true;