Added support for scraping fan art images.

Also added scraping of box back covers when using TheGamesDB.
This commit is contained in:
Leon Styhre 2022-01-15 13:16:23 +01:00
parent a135edb02e
commit 92f5284bf3
13 changed files with 58 additions and 9 deletions

View file

@ -278,6 +278,12 @@ const std::string FileData::getCoverPath() const
return getMediafilePath("covers"); return getMediafilePath("covers");
} }
const std::string FileData::getFanArtPath() const
{
// Return path to the fan art image.
return getMediafilePath("fanart");
}
const std::string FileData::getMarqueePath() const const std::string FileData::getMarqueePath() const
{ {
// Return path to the marquee image. // Return path to the marquee image.

View file

@ -65,6 +65,7 @@ public:
const std::string get3DBoxPath() const; const std::string get3DBoxPath() const;
const std::string getBackCoverPath() const; const std::string getBackCoverPath() const;
const std::string getCoverPath() const; const std::string getCoverPath() const;
const std::string getFanArtPath() const;
const std::string getMarqueePath() const; const std::string getMarqueePath() const;
const std::string getPhysicalMediaPath() const; const std::string getPhysicalMediaPath() const;
const std::string getMiximagePath() const; const std::string getMiximagePath() const;

View file

@ -183,6 +183,9 @@ void MediaViewer::findMedia()
mScreenshotIndex = static_cast<int>(mImageFiles.size() - 1); mScreenshotIndex = static_cast<int>(mImageFiles.size() - 1);
} }
if ((mediaFile = mGame->getFanArtPath()) != "")
mImageFiles.push_back(mediaFile);
if ((mediaFile = mGame->getMiximagePath()) != "") if ((mediaFile = mGame->getMiximagePath()) != "")
mImageFiles.push_back(mediaFile); mImageFiles.push_back(mediaFile);

View file

@ -353,15 +353,16 @@ void GuiScraperMenu::openContentOptions()
} }
}); });
// Box back cover images are not supported by TheGamesDB, so gray out the option if this // Scrape fan art images.
// scraper is selected. auto scrapeFanArt = std::make_shared<SwitchComponent>(mWindow);
if (Settings::getInstance()->getString("Scraper") == "thegamesdb") { scrapeFanArt->setState(Settings::getInstance()->getBool("ScrapeFanArt"));
scrapeBackCovers->setEnabled(false); s->addWithLabel("FAN ART IMAGES", scrapeFanArt);
scrapeBackCovers->setOpacity(DISABLED_OPACITY); s->addSaveFunc([scrapeFanArt, s] {
scrapeBackCovers->getParent() if (scrapeFanArt->getState() != Settings::getInstance()->getBool("ScrapeFanArt")) {
->getChild(scrapeBackCovers->getChildIndex() - 1) Settings::getInstance()->setBool("ScrapeFanArt", scrapeFanArt->getState());
->setOpacity(DISABLED_OPACITY); s->setNeedsSaving();
} }
});
// Scrape marquee images. // Scrape marquee images.
auto scrape_marquees = std::make_shared<SwitchComponent>(mWindow); auto scrape_marquees = std::make_shared<SwitchComponent>(mWindow);

View file

@ -733,6 +733,7 @@ void GuiScraperSearch::update(int deltaTime)
results_scrape[i].box3DUrl = it->box3DUrl; results_scrape[i].box3DUrl = it->box3DUrl;
results_scrape[i].backcoverUrl = it->backcoverUrl; results_scrape[i].backcoverUrl = it->backcoverUrl;
results_scrape[i].coverUrl = it->coverUrl; results_scrape[i].coverUrl = it->coverUrl;
results_scrape[i].fanartUrl = it->fanartUrl;
results_scrape[i].marqueeUrl = it->marqueeUrl; results_scrape[i].marqueeUrl = it->marqueeUrl;
results_scrape[i].screenshotUrl = it->screenshotUrl; results_scrape[i].screenshotUrl = it->screenshotUrl;
results_scrape[i].titlescreenUrl = it->titlescreenUrl; results_scrape[i].titlescreenUrl = it->titlescreenUrl;

View file

@ -402,6 +402,7 @@ void processMediaURLs(const Value& images,
result.gameID = it->name.GetString(); result.gameID = it->name.GetString();
const Value& gameMedia = images[it->name]; const Value& gameMedia = images[it->name];
result.coverUrl = ""; result.coverUrl = "";
result.fanartUrl = "";
result.marqueeUrl = ""; result.marqueeUrl = "";
result.screenshotUrl = ""; result.screenshotUrl = "";
result.titlescreenUrl = ""; result.titlescreenUrl = "";
@ -420,6 +421,13 @@ void processMediaURLs(const Value& images,
if (mediatype == "boxart" && mediaside == "front") if (mediatype == "boxart" && mediaside == "front")
if (gameMedia[i]["filename"].IsString()) if (gameMedia[i]["filename"].IsString())
result.coverUrl = base_url + gameMedia[i]["filename"].GetString(); result.coverUrl = base_url + gameMedia[i]["filename"].GetString();
if (mediatype == "boxart" && mediaside == "back")
if (gameMedia[i]["filename"].IsString())
result.backcoverUrl = base_url + gameMedia[i]["filename"].GetString();
// Only process the first fanart result.
if (mediatype == "fanart" && result.fanartUrl == "")
if (gameMedia[i]["filename"].IsString())
result.fanartUrl = base_url + gameMedia[i]["filename"].GetString();
if (mediatype == "clearlogo") if (mediatype == "clearlogo")
if (gameMedia[i]["filename"].IsString()) if (gameMedia[i]["filename"].IsString())
result.marqueeUrl = base_url + gameMedia[i]["filename"].GetString(); result.marqueeUrl = base_url + gameMedia[i]["filename"].GetString();

View file

@ -212,6 +212,14 @@ MDResolveHandle::MDResolveHandle(const ScraperSearchResult& result,
mediaFileInfo.resizeFile = true; mediaFileInfo.resizeFile = true;
scrapeFiles.push_back(mediaFileInfo); scrapeFiles.push_back(mediaFileInfo);
} }
if (Settings::getInstance()->getBool("ScrapeFanArt") && result.fanartUrl != "") {
mediaFileInfo.fileURL = result.fanartUrl;
mediaFileInfo.fileFormat = result.fanartFormat;
mediaFileInfo.subDirectory = "fanart";
mediaFileInfo.existingMediaFile = search.game->getFanArtPath();
mediaFileInfo.resizeFile = true;
scrapeFiles.push_back(mediaFileInfo);
}
if (Settings::getInstance()->getBool("ScrapePhysicalMedia") && result.physicalmediaUrl != "") { if (Settings::getInstance()->getBool("ScrapePhysicalMedia") && result.physicalmediaUrl != "") {
mediaFileInfo.fileURL = result.physicalmediaUrl; mediaFileInfo.fileURL = result.physicalmediaUrl;
mediaFileInfo.fileFormat = result.physicalmediaFormat; mediaFileInfo.fileFormat = result.physicalmediaFormat;

View file

@ -69,6 +69,7 @@ struct ScraperSearchResult {
std::string box3DUrl; std::string box3DUrl;
std::string backcoverUrl; std::string backcoverUrl;
std::string coverUrl; std::string coverUrl;
std::string fanartUrl;
std::string marqueeUrl; std::string marqueeUrl;
std::string physicalmediaUrl; std::string physicalmediaUrl;
std::string screenshotUrl; std::string screenshotUrl;
@ -79,6 +80,7 @@ struct ScraperSearchResult {
std::string box3DFormat; std::string box3DFormat;
std::string backcoverFormat; std::string backcoverFormat;
std::string coverFormat; std::string coverFormat;
std::string fanartFormat;
std::string marqueeFormat; std::string marqueeFormat;
std::string physicalmediaFormat; std::string physicalmediaFormat;
std::string screenshotFormat; std::string screenshotFormat;

View file

@ -559,6 +559,9 @@ void ScreenScraperRequest::processGame(const pugi::xml_document& xmldoc,
// Box cover. // Box cover.
processMedia(result, media_list, ssConfig.media_cover, result.coverUrl, processMedia(result, media_list, ssConfig.media_cover, result.coverUrl,
result.coverFormat, region); result.coverFormat, region);
// Fan art.
processMedia(result, media_list, ssConfig.media_fanart, result.fanartUrl,
result.fanartFormat, region);
// Marquee (wheel). // Marquee (wheel).
processMedia(result, media_list, ssConfig.media_marquee, result.marqueeUrl, processMedia(result, media_list, ssConfig.media_marquee, result.marqueeUrl,
result.marqueeFormat, region); result.marqueeFormat, region);

View file

@ -73,6 +73,7 @@ public:
std::string media_3dbox = "box-3D"; std::string media_3dbox = "box-3D";
std::string media_backcover = "box-2D-back"; std::string media_backcover = "box-2D-back";
std::string media_cover = "box-2D"; std::string media_cover = "box-2D";
std::string media_fanart = "fanart";
std::string media_marquee = "wheel"; std::string media_marquee = "wheel";
std::string media_physicalmedia = "support-2D"; std::string media_physicalmedia = "support-2D";
std::string media_screenshot = "ss"; std::string media_screenshot = "ss";

View file

@ -272,6 +272,13 @@ void BasicGameListView::removeMedia(FileData* game)
removeEmptyDirFunc(systemMediaDir, mediaType, path); removeEmptyDirFunc(systemMediaDir, mediaType, path);
} }
while (Utils::FileSystem::exists(game->getFanArtPath())) {
mediaType = "fanart";
path = game->getFanArtPath();
Utils::FileSystem::removeFile(path);
removeEmptyDirFunc(systemMediaDir, mediaType, path);
}
while (Utils::FileSystem::exists(game->getMarqueePath())) { while (Utils::FileSystem::exists(game->getMarqueePath())) {
mediaType = "marquees"; mediaType = "marquees";
path = game->getMarqueePath(); path = game->getMarqueePath();

View file

@ -625,6 +625,13 @@ void GridGameListView::removeMedia(FileData* game)
removeEmptyDirFunc(systemMediaDir, mediaType, path); removeEmptyDirFunc(systemMediaDir, mediaType, path);
} }
while (Utils::FileSystem::exists(game->getFanArtPath())) {
mediaType = "fanart";
path = game->getFanArtPath();
Utils::FileSystem::removeFile(path);
removeEmptyDirFunc(systemMediaDir, mediaType, path);
}
while (Utils::FileSystem::exists(game->getMarqueePath())) { while (Utils::FileSystem::exists(game->getMarqueePath())) {
mediaType = "marquees"; mediaType = "marquees";
path = game->getMarqueePath(); path = game->getMarqueePath();

View file

@ -97,6 +97,7 @@ void Settings::setDefaults()
mBoolMap["ScrapeTitleScreens"] = {true, true}; mBoolMap["ScrapeTitleScreens"] = {true, true};
mBoolMap["ScrapeCovers"] = {true, true}; mBoolMap["ScrapeCovers"] = {true, true};
mBoolMap["ScrapeBackCovers"] = {true, true}; mBoolMap["ScrapeBackCovers"] = {true, true};
mBoolMap["ScrapeFanArt"] = {true, true};
mBoolMap["ScrapeMarquees"] = {true, true}; mBoolMap["ScrapeMarquees"] = {true, true};
mBoolMap["Scrape3DBoxes"] = {true, true}; mBoolMap["Scrape3DBoxes"] = {true, true};
mBoolMap["ScrapePhysicalMedia"] = {true, true}; mBoolMap["ScrapePhysicalMedia"] = {true, true};