From 9f240394ed100a679bfd0811577a9ae02eae79f7 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Thu, 6 Aug 2020 11:27:16 +0200 Subject: [PATCH] Added option to exclude files from the multi-scraper. Two new scraper filters were added as well, 'Favorite games' and 'No game video'. --- es-app/src/FileData.cpp | 10 +++++++++- es-app/src/FileData.h | 1 + es-app/src/MetaData.cpp | 10 ++++++---- es-app/src/guis/GuiScraperMenu.cpp | 26 +++++++++++++++++++++----- es-core/src/Settings.cpp | 1 + 5 files changed, 38 insertions(+), 10 deletions(-) diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 3d69a9ce1..aa19a09f8 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -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; diff --git a/es-app/src/FileData.h b/es-app/src/FileData.h index 917c3cb36..a071f9e97 100644 --- a/es-app/src/FileData.h +++ b/es-app/src/FileData.h @@ -49,6 +49,7 @@ public: const bool getFavorite(); const bool getHidden(); const bool getCountAsGame(); + const bool getExcludeFromScraper(); const std::vector getChildrenRecursive() const; inline FileType getType() const { return mType; } inline const std::string& getPath() const { return mPath; } diff --git a/es-app/src/MetaData.cpp b/es-app/src/MetaData.cpp index 7f633b15e..ca3afa6b1 100644 --- a/es-app/src/MetaData.cpp +++ b/es-app/src/MetaData.cpp @@ -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 folderMDD(folderDecls, folderDecls + diff --git a/es-app/src/guis/GuiScraperMenu.cpp b/es-app/src/guis/GuiScraperMenu.cpp index 6ae2fdf45..9ed512c7b 100644 --- a/es-app/src/guis/GuiScraperMenu.cpp +++ b/es-app/src/guis/GuiScraperMenu.cpp @@ -38,14 +38,17 @@ GuiScraperMenu::GuiScraperMenu(Window* window) : GuiComponent(window), // based on the outcome of the checks below. mFilters = std::make_shared< OptionListComponent> (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(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 GuiScraperMenu::getSearches( for (auto sys = systems.cbegin(); sys != systems.cend(); sys++) { std::vector 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; diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index e5fd53069..9c343b981 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -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;