diff --git a/include/config.h b/include/config.h index 12e15a9..0e9f068 100644 --- a/include/config.h +++ b/include/config.h @@ -69,6 +69,7 @@ class Config std::string sFileIdString; std::string sLanguagePriority; std::string sPlatformPriority; + std::string sIgnoreDLCCountRegex; std::vector vLanguagePriority; std::vector vPlatformPriority; diff --git a/include/util.h b/include/util.h index 980460d..25e9f78 100644 --- a/include/util.h +++ b/include/util.h @@ -24,6 +24,7 @@ struct gameSpecificConfig unsigned int iInstallerType; unsigned int iInstallerLanguage; bool bDLC; + bool bIgnoreDLCCount; }; namespace Util diff --git a/main.cpp b/main.cpp index 81e1bc5..2f2ed79 100644 --- a/main.cpp +++ b/main.cpp @@ -191,6 +191,7 @@ int main(int argc, char *argv[]) ("language-priority", bpo::value(&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(&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(&config.bSaveSerials)->zero_tokens()->default_value(false), "Save serial numbers when downloading") + ("ignore-dlc-count", bpo::value(&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() diff --git a/man/lgogdownloader.supplemental.groff b/man/lgogdownloader.supplemental.groff index 5f5ad1d..418e980 100644 --- a/man/lgogdownloader.supplemental.groff +++ b/man/lgogdownloader.supplemental.groff @@ -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" : , "platform" : , - "dlc" : + "dlc" : , + "ignore-dlc-count" : .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 diff --git a/src/downloader.cpp b/src/downloader.cpp index ae05f7a..965de48 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -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 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 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 Downloader::getExtrasFromJSON(const Json::Value& json, con return extras; } - std::string Downloader::getSerialsFromJSON(const Json::Value& json) { std::ostringstream serials; diff --git a/src/util.cpp b/src/util.cpp index 29aadf2..2d57807 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -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 {