download game logo

This commit is contained in:
Thoreas 2023-06-05 15:06:44 +02:00
parent b55489435f
commit dfea23c631
6 changed files with 24 additions and 0 deletions

View File

@ -46,6 +46,7 @@ struct DownloadConfig
bool bRemoteXML; bool bRemoteXML;
bool bSaveChangelogs; bool bSaveChangelogs;
bool bSaveSerials; bool bSaveSerials;
bool bSaveLogo;
bool bAutomaticXMLCreation; bool bAutomaticXMLCreation;
bool bFreeSpaceCheck; bool bFreeSpaceCheck;

View File

@ -32,9 +32,11 @@ class gameDetails
std::string icon; std::string icon;
std::string serials; std::string serials;
std::string changelog; std::string changelog;
std::string logo;
void filterWithPriorities(const gameSpecificConfig& config); void filterWithPriorities(const gameSpecificConfig& config);
void makeFilepaths(const DirectoryConfig& config); void makeFilepaths(const DirectoryConfig& config);
std::string getSerialsFilepath(); std::string getSerialsFilepath();
std::string getLogoFilepath();
std::string getChangelogFilepath(); std::string getChangelogFilepath();
Json::Value getDetailsAsJson(); Json::Value getDetailsAsJson();
std::vector<gameFile> getGameFileVector(); std::vector<gameFile> getGameFileVector();
@ -46,6 +48,7 @@ class gameDetails
void filterListWithType(std::vector<gameFile>& list, const unsigned int& iType); void filterListWithType(std::vector<gameFile>& list, const unsigned int& iType);
private: private:
std::string serialsFilepath; std::string serialsFilepath;
std::string logoFilepath;
std::string changelogFilepath; std::string changelogFilepath;
}; };

View File

@ -258,6 +258,7 @@ int main(int argc, char *argv[])
("use-cache", bpo::value<bool>(&Globals::globalConfig.bUseCache)->zero_tokens()->default_value(false), ("Use game details cache")) ("use-cache", bpo::value<bool>(&Globals::globalConfig.bUseCache)->zero_tokens()->default_value(false), ("Use game details cache"))
("cache-valid", bpo::value<int>(&Globals::globalConfig.iCacheValid)->default_value(2880), ("Set how long cached game details are valid (in minutes)\nDefault: 2880 minutes (48 hours)")) ("cache-valid", bpo::value<int>(&Globals::globalConfig.iCacheValid)->default_value(2880), ("Set how long cached game details are valid (in minutes)\nDefault: 2880 minutes (48 hours)"))
("save-serials", bpo::value<bool>(&Globals::globalConfig.dlConf.bSaveSerials)->zero_tokens()->default_value(false), "Save serial numbers when downloading") ("save-serials", bpo::value<bool>(&Globals::globalConfig.dlConf.bSaveSerials)->zero_tokens()->default_value(false), "Save serial numbers when downloading")
("save-logo", bpo::value<bool>(&Globals::globalConfig.dlConf.bSaveLogo)->zero_tokens()->default_value(false), "Save logo when downloading")
("ignore-dlc-count", bpo::value<std::string>(&Globals::globalConfig.sIgnoreDLCCountRegex)->implicit_value(".*"), "Set regular expression filter for games to ignore DLC count information\nIgnoring DLC count information helps in situations where the account page doesn't provide accurate information about DLCs") ("ignore-dlc-count", bpo::value<std::string>(&Globals::globalConfig.sIgnoreDLCCountRegex)->implicit_value(".*"), "Set regular expression filter for games to ignore DLC count information\nIgnoring DLC count information helps in situations where the account page doesn't provide accurate information about DLCs")
("include", bpo::value<std::string>(&sIncludeOptions)->default_value("all"), ("Select what to download/list/repair\n" + include_options_text).c_str()) ("include", bpo::value<std::string>(&sIncludeOptions)->default_value("all"), ("Select what to download/list/repair\n" + include_options_text).c_str())
("exclude", bpo::value<std::string>(&sExcludeOptions)->default_value(""), ("Select what not to download/list/repair\n" + include_options_text).c_str()) ("exclude", bpo::value<std::string>(&sExcludeOptions)->default_value(""), ("Select what not to download/list/repair\n" + include_options_text).c_str())

View File

@ -683,6 +683,12 @@ void Downloader::download()
this->saveSerials(games[i].serials, filepath); this->saveSerials(games[i].serials, filepath);
} }
if (conf.dlConf.bSaveLogo && !games[i].logo.empty())
{
std::string filepath = games[i].getLogoFilepath();
this->downloadFile(games[i].logo, filepath, "", games[i].gamename);
}
if (conf.dlConf.bSaveChangelogs && !games[i].changelog.empty()) if (conf.dlConf.bSaveChangelogs && !games[i].changelog.empty())
{ {
std::string filepath = games[i].getChangelogFilepath(); std::string filepath = games[i].getChangelogFilepath();
@ -698,6 +704,11 @@ void Downloader::download()
std::string filepath = games[i].dlcs[j].getSerialsFilepath(); std::string filepath = games[i].dlcs[j].getSerialsFilepath();
this->saveSerials(games[i].dlcs[j].serials, filepath); this->saveSerials(games[i].dlcs[j].serials, filepath);
} }
if (conf.dlConf.bSaveLogo && !games[i].dlcs[j].logo.empty())
{
std::string filepath = games[i].dlcs[j].getLogoFilepath();
this->downloadFile(games[i].dlcs[j].logo, filepath, "", games[i].dlcs[j].gamename);
}
if (conf.dlConf.bSaveChangelogs && !games[i].dlcs[j].changelog.empty()) if (conf.dlConf.bSaveChangelogs && !games[i].dlcs[j].changelog.empty())
{ {
std::string filepath = games[i].dlcs[j].getChangelogFilepath(); std::string filepath = games[i].dlcs[j].getChangelogFilepath();

View File

@ -312,6 +312,7 @@ gameDetails galaxyAPI::productInfoJsonToGameDetails(const Json::Value& json, con
gamedetails.product_id = json["id"].asString(); gamedetails.product_id = json["id"].asString();
gamedetails.title = json["title"].asString(); gamedetails.title = json["title"].asString();
gamedetails.icon = "https:" + json["images"]["icon"].asString(); gamedetails.icon = "https:" + json["images"]["icon"].asString();
gamedetails.logo = "https:" + json["images"]["logo2x"].asString();
if (json.isMember("changelog")) if (json.isMember("changelog"))
gamedetails.changelog = json["changelog"].asString(); gamedetails.changelog = json["changelog"].asString();

View File

@ -83,6 +83,7 @@ void gameDetails::makeFilepaths(const DirectoryConfig& config)
std::string directory = config.sDirectory + "/" + config.sGameSubdir + "/"; std::string directory = config.sDirectory + "/" + config.sGameSubdir + "/";
std::string subdir; std::string subdir;
this->serialsFilepath = Util::makeFilepath(directory, "serials.txt", this->gamename, subdir, 0); this->serialsFilepath = Util::makeFilepath(directory, "serials.txt", this->gamename, subdir, 0);
this->logoFilepath = Util::makeFilepath(directory, "logo" + this->logo.substr(this->logo.rfind(".")), this->gamename, subdir, 0);
this->changelogFilepath = Util::makeFilepath(directory, "changelog_" + gamename + ".html", this->gamename, subdir, 0); this->changelogFilepath = Util::makeFilepath(directory, "changelog_" + gamename + ".html", this->gamename, subdir, 0);
for (unsigned int i = 0; i < this->installers.size(); ++i) for (unsigned int i = 0; i < this->installers.size(); ++i)
@ -117,6 +118,7 @@ void gameDetails::makeFilepaths(const DirectoryConfig& config)
{ {
subdir = config.bSubDirectories ? config.sDLCSubdir + "/" + config.sInstallersSubdir : ""; subdir = config.bSubDirectories ? config.sDLCSubdir + "/" + config.sInstallersSubdir : "";
this->dlcs[i].serialsFilepath = Util::makeFilepath(directory, "serials.txt", this->gamename, subdir, 0); this->dlcs[i].serialsFilepath = Util::makeFilepath(directory, "serials.txt", this->gamename, subdir, 0);
this->dlcs[i].logoFilepath = Util::makeFilepath(directory, "logo" + this->logo.substr(this->logo.rfind(".")), this->gamename, subdir, 0);
this->dlcs[i].changelogFilepath = Util::makeFilepath(directory, "changelog_" + this->dlcs[i].gamename + ".html", this->gamename, subdir, 0); this->dlcs[i].changelogFilepath = Util::makeFilepath(directory, "changelog_" + this->dlcs[i].gamename + ".html", this->gamename, subdir, 0);
for (unsigned int j = 0; j < this->dlcs[i].installers.size(); ++j) for (unsigned int j = 0; j < this->dlcs[i].installers.size(); ++j)
{ {
@ -184,6 +186,11 @@ std::string gameDetails::getSerialsFilepath()
return this->serialsFilepath; return this->serialsFilepath;
} }
std::string gameDetails::getLogoFilepath()
{
return this->logoFilepath;
}
std::string gameDetails::getChangelogFilepath() std::string gameDetails::getChangelogFilepath()
{ {
return this->changelogFilepath; return this->changelogFilepath;