mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2025-03-08 20:35:18 +01:00
Add options to ignore DLC count information
Ignoring DLC count information helps in situations where the account page doesn't provide accurate information about DLCs. --ignore-dlc-count sets regular expression filter for games to ignore DLC count information. Game specific option "ignore-dlc-count" can be used to ignore DLC count for specific game.
This commit is contained in:
parent
e6e39390a3
commit
834e6baa7a
@ -69,6 +69,7 @@ class Config
|
||||
std::string sFileIdString;
|
||||
std::string sLanguagePriority;
|
||||
std::string sPlatformPriority;
|
||||
std::string sIgnoreDLCCountRegex;
|
||||
std::vector<unsigned int> vLanguagePriority;
|
||||
std::vector<unsigned int> vPlatformPriority;
|
||||
|
||||
|
@ -24,6 +24,7 @@ struct gameSpecificConfig
|
||||
unsigned int iInstallerType;
|
||||
unsigned int iInstallerLanguage;
|
||||
bool bDLC;
|
||||
bool bIgnoreDLCCount;
|
||||
};
|
||||
|
||||
namespace Util
|
||||
|
1
main.cpp
1
main.cpp
@ -191,6 +191,7 @@ int main(int argc, char *argv[])
|
||||
("language-priority", bpo::value<std::string>(&config.sLanguagePriority)->default_value(""), ("Set priority of systems" + priority_help_text + ", like \"4,1\" for French first, then English if no French version").c_str())
|
||||
("platform-priority", bpo::value<std::string>(&config.sPlatformPriority)->default_value(""), ("Set priority of platforms" + priority_help_text + ", like \"4,1\" for Linux first, then Windows if no Linux version").c_str())
|
||||
("save-serials", bpo::value<bool>(&config.bSaveSerials)->zero_tokens()->default_value(false), "Save serial numbers when downloading")
|
||||
("ignore-dlc-count", bpo::value<std::string>(&config.sIgnoreDLCCountRegex)->default_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")
|
||||
;
|
||||
// Options read from config file
|
||||
options_cfg_only.add_options()
|
||||
|
@ -7,7 +7,7 @@ An open-source GOG.com downloader for Linux users which uses the same API as the
|
||||
.PP
|
||||
LGOGDownloader can download purchased games, query GOG.com to see if game files have changed, as well as downloading extras such as artwork and manuals. It is capable of downloading language-specific installers for games where they exist.
|
||||
.PP
|
||||
These games are currently offered only for the Microsoft Windows\[rg] and Apple OS X\[rg] operating systems. To play these games under GNU/Linux will require a compatibility layer such as Wine. Usage of such a program is outside the scope of this document.
|
||||
These games are currently offered only for the Microsoft Windows\[rg] and Apple OS X\[rg] operating systems. To play these games under GNU/Linux will require a compatibility layer such as Wine. Usage of such a program is outside the scope of this document.
|
||||
|
||||
/--update-check/
|
||||
.nf
|
||||
@ -70,7 +70,7 @@ It doesn't have to exist, but if it does exist, it must be readable to lgogdownl
|
||||
\fI$XDG_CONFIG_HOME/lgogdownloader/gamename.conf\fP
|
||||
JSON formatted file. Sets game specific settings for \fBgamename\fP.
|
||||
.br
|
||||
Allowed settings are \fBlanguage\fP, \fBplatform\fP and \fBdlc\fP.
|
||||
Allowed settings are \fBlanguage\fP, \fBplatform\fP, \fBdlc\fP and \fBignore-dlc-count\fP.
|
||||
.br
|
||||
The \fBdlc\fP option is limited to disabling DLC for specific game. It can't enable DLC listing/downloading if \fB--no-dlc\fP option is used.
|
||||
.br
|
||||
@ -79,7 +79,8 @@ Must be in the following format:
|
||||
{
|
||||
"language" : <int>,
|
||||
"platform" : <int>,
|
||||
"dlc" : <bool>
|
||||
"dlc" : <bool>,
|
||||
"ignore-dlc-count" : <bool>
|
||||
.br
|
||||
}
|
||||
|
||||
@ -87,7 +88,7 @@ Must be in the following format:
|
||||
For both languages and platforms, the default behavior is to download all enabled ones.
|
||||
The \fBlanguage-priority\fB and \fBplatform-priority\fB switches enable a priority-based mode: only the first matching one will be downloaded.
|
||||
.PP
|
||||
For example, setting \fBlanguage\fB to 5 means both French and English will be downloaded (if available) for all games. Setting \fBlanguage-priority\fB to 4,1 means that the French version (and only that one) will be downloaded if available, and if not, the English version will be downloaded.
|
||||
For example, setting \fBlanguage\fB to 5 means both French and English will be downloaded (if available) for all games. Setting \fBlanguage-priority\fB to 4,1 means that the French version (and only that one) will be downloaded if available, and if not, the English version will be downloaded.
|
||||
.PP
|
||||
You're allowed to "stack" codes in the priority string if needed. If you set \fBlanguage-priority\fB 132,1 it means it'll download both Spanish (128) and French (4) versions if they are available, and the English (1) one only if none of French and Spanish are available.
|
||||
.PP
|
||||
|
@ -249,12 +249,13 @@ int Downloader::getGameDetails()
|
||||
|
||||
gameSpecificConfig conf;
|
||||
conf.bDLC = config.bDLC;
|
||||
conf.bIgnoreDLCCount = false;
|
||||
conf.iInstallerLanguage = config.iInstallerLanguage;
|
||||
conf.iInstallerType = config.iInstallerType;
|
||||
if (!config.bUpdateCache) // Disable game specific config files for cache update
|
||||
{
|
||||
if (Util::getGameSpecificConfig(gameItems[i].name, &conf) > 0)
|
||||
std::cout << std::endl << gameItems[i].name << " - Language: " << conf.iInstallerLanguage << ", Platform: " << conf.iInstallerType << ", DLC: " << (conf.bDLC ? "true" : "false") << std::endl;
|
||||
std::cout << std::endl << gameItems[i].name << " - Language: " << conf.iInstallerLanguage << ", Platform: " << conf.iInstallerType << ", DLC: " << (conf.bDLC ? "true" : "false") << ", Ignore DLC count: " << (conf.bIgnoreDLCCount ? "true" : "false") << std::endl;
|
||||
}
|
||||
|
||||
game = gogAPI->getGameDetails(gameItems[i].name, conf.iInstallerType, conf.iInstallerLanguage, config.bDuplicateHandler);
|
||||
@ -274,6 +275,17 @@ int Downloader::getGameDetails()
|
||||
gameDetailsJSON = this->getGameDetailsJSON(gameItems[i].id);
|
||||
game.serials = this->getSerialsFromJSON(gameDetailsJSON);
|
||||
}
|
||||
|
||||
// Ignore DLC count and try to get DLCs from JSON
|
||||
if (game.dlcs.empty() && !bHasDLC && conf.bDLC && conf.bIgnoreDLCCount)
|
||||
{
|
||||
if (gameDetailsJSON.empty())
|
||||
gameDetailsJSON = this->getGameDetailsJSON(gameItems[i].id);
|
||||
|
||||
gameItems[i].dlcnames = Util::getDLCNamesFromJSON(gameDetailsJSON["dlcs"]);
|
||||
bHasDLC = !gameItems[i].dlcnames.empty();
|
||||
}
|
||||
|
||||
if (game.dlcs.empty() && bHasDLC && conf.bDLC)
|
||||
{
|
||||
for (unsigned int j = 0; j < gameItems[i].dlcnames.size(); ++j)
|
||||
@ -2129,7 +2141,17 @@ std::vector<gameItem> Downloader::getGames()
|
||||
if (config.bDLC)
|
||||
{
|
||||
int dlcCount = product["dlcCount"].asInt();
|
||||
if (dlcCount != 0)
|
||||
|
||||
bool bIgnoreDLCCount = false;
|
||||
if (!config.sIgnoreDLCCountRegex.empty())
|
||||
{
|
||||
boost::regex expression(config.sIgnoreDLCCountRegex);
|
||||
boost::match_results<std::string::const_iterator> what;
|
||||
if (boost::regex_search(game.name, what, expression)) // Check if name matches the specified regex
|
||||
bIgnoreDLCCount = true;
|
||||
}
|
||||
|
||||
if (dlcCount != 0 || bIgnoreDLCCount)
|
||||
{
|
||||
std::string gameinfo = this->getResponse("https://www.gog.com/account/gameDetails/" + game.id + ".json");
|
||||
Json::Value info;
|
||||
@ -2289,7 +2311,6 @@ std::vector<gameFile> Downloader::getExtrasFromJSON(const Json::Value& json, con
|
||||
return extras;
|
||||
}
|
||||
|
||||
|
||||
std::string Downloader::getSerialsFromJSON(const Json::Value& json)
|
||||
{
|
||||
std::ostringstream serials;
|
||||
|
@ -267,6 +267,11 @@ int Util::getGameSpecificConfig(std::string gamename, gameSpecificConfig* conf,
|
||||
conf->bDLC = root["dlc"].asBool();
|
||||
res++;
|
||||
}
|
||||
if (root.isMember("ignore-dlc-count"))
|
||||
{
|
||||
conf->bIgnoreDLCCount = root["ignore-dlc-count"].asBool();
|
||||
res++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user