mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2024-11-20 03:39:17 +01:00
Ignore DLC count information for specific games
Ignore DLC count information for specific games by using a list of games that we know have DLC. GOG reports wrong DLC count information for many games. By using a list of games that we know have DLC we can ignore DLC count info that GOG provides for those games. User can use local list ($XDG_CONFIG_HOME/lgogdownloader/game_has_dlc.txt) or use remote list by using the new "--dlc-list" option. The list uses same format as blacklist.
This commit is contained in:
parent
0b3a6643c6
commit
34e3af3438
@ -31,6 +31,8 @@ class Blacklist
|
||||
bool isBlacklisted(const std::string& path);
|
||||
bool isBlacklisted(const std::string& path, const std::string& gamename, std::string subdirectory = "");
|
||||
|
||||
std::vector<BlacklistItem>::size_type size() const { return blacklist_.size(); }
|
||||
bool empty() { return blacklist_.empty(); }
|
||||
private:
|
||||
std::vector<BlacklistItem> blacklist_;
|
||||
};
|
||||
|
@ -63,8 +63,10 @@ class Config
|
||||
std::string sConfigFilePath;
|
||||
std::string sBlacklistFilePath;
|
||||
std::string sIgnorelistFilePath;
|
||||
std::string sGameHasDLCListFilePath;
|
||||
std::string sOrphanRegex;
|
||||
std::string sCoverList;
|
||||
std::string sGameHasDLCList;
|
||||
std::string sReportFilePath;
|
||||
std::string sInstallersSubdir;
|
||||
std::string sExtrasSubdir;
|
||||
@ -93,6 +95,7 @@ class Config
|
||||
long int iTimeout;
|
||||
Blacklist blacklist;
|
||||
Blacklist ignorelist;
|
||||
Blacklist gamehasdlc;
|
||||
};
|
||||
|
||||
#endif // CONFIG_H__
|
||||
|
28
main.cpp
28
main.cpp
@ -55,6 +55,7 @@ int main(int argc, char *argv[])
|
||||
config.sConfigFilePath = config.sConfigDirectory + "/config.cfg";
|
||||
config.sBlacklistFilePath = config.sConfigDirectory + "/blacklist.txt";
|
||||
config.sIgnorelistFilePath = config.sConfigDirectory + "/ignorelist.txt";
|
||||
config.sGameHasDLCListFilePath = config.sConfigDirectory + "/game_has_dlc.txt";
|
||||
|
||||
std::string priority_help_text = "Set priority by separating values with \",\"\nCombine values by separating with \"+\"";
|
||||
// Create help text for --platform option
|
||||
@ -164,7 +165,7 @@ int main(int argc, char *argv[])
|
||||
("timeout", bpo::value<long int>(&config.iTimeout)->default_value(10), "Set timeout for connection\nMaximum time in seconds that connection phase is allowed to take")
|
||||
("retries", bpo::value<int>(&config.iRetries)->default_value(3), "Set maximum number of retries on failed download")
|
||||
("wait", bpo::value<int>(&config.iWait)->default_value(0), "Time to wait between requests (milliseconds)")
|
||||
("cover-list", bpo::value<std::string>(&config.sCoverList)->default_value("https://sites.google.com/site/gogdownloader/covers.xml"), "Set URL for cover list")
|
||||
("cover-list", bpo::value<std::string>(&config.sCoverList)->default_value("https://raw.githubusercontent.com/Sude-/lgogdownloader-lists/master/covers.xml"), "Set URL for cover list")
|
||||
("subdir-installers", bpo::value<std::string>(&config.sInstallersSubdir)->default_value(""), ("Set subdirectory for extras" + subdir_help_text).c_str())
|
||||
("subdir-extras", bpo::value<std::string>(&config.sExtrasSubdir)->default_value("extras"), ("Set subdirectory for extras" + subdir_help_text).c_str())
|
||||
("subdir-patches", bpo::value<std::string>(&config.sPatchesSubdir)->default_value("patches"), ("Set subdirectory for patches" + subdir_help_text).c_str())
|
||||
@ -180,6 +181,7 @@ int main(int argc, char *argv[])
|
||||
("automatic-xml-creation", bpo::value<bool>(&config.bAutomaticXMLCreation)->zero_tokens()->default_value(false), "Automatically create XML data after download has completed")
|
||||
("save-changelogs", bpo::value<bool>(&config.bSaveChangelogs)->zero_tokens()->default_value(false), "Save changelogs when downloading")
|
||||
("threads", bpo::value<unsigned int>(&config.iThreads)->default_value(4), "Number of download threads")
|
||||
("dlc-list", bpo::value<std::string>(&config.sGameHasDLCList)->default_value("https://raw.githubusercontent.com/Sude-/lgogdownloader-lists/master/game_has_dlc.txt"), "Set URL for list of games that have DLC")
|
||||
;
|
||||
// Options read from config file
|
||||
options_cfg_only.add_options()
|
||||
@ -298,6 +300,30 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (config.sIgnoreDLCCountRegex.empty())
|
||||
{
|
||||
if (boost::filesystem::exists(config.sGameHasDLCListFilePath))
|
||||
{
|
||||
std::ifstream ifs(config.sGameHasDLCListFilePath.c_str());
|
||||
if (!ifs)
|
||||
{
|
||||
std::cerr << "Could not open list of games that have dlc: " << config.sGameHasDLCListFilePath << std::endl;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string line;
|
||||
std::vector<std::string> lines;
|
||||
while (!ifs.eof())
|
||||
{
|
||||
std::getline(ifs, line);
|
||||
lines.push_back(std::move(line));
|
||||
}
|
||||
config.gamehasdlc.initialize(lines);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (vm.count("chunk-size"))
|
||||
config.iChunkSize <<= 20; // Convert chunk size from bytes to megabytes
|
||||
|
||||
|
@ -74,6 +74,17 @@ blacklist.
|
||||
.br
|
||||
It doesn't have to exist, but if it does exist, it must be readable to lgogdownloader.
|
||||
|
||||
.TP
|
||||
\fI$XDG_CONFIG_HOME/lgogdownloader/game_has_dlc.txt\fP
|
||||
Allows user to specify which games have dlc and should have their DLC count
|
||||
information ignored. The file has the same format and interpretation as a
|
||||
blacklist.
|
||||
.br
|
||||
It doesn't have to exist, but if it does exist, it must be readable to lgogdownloader.
|
||||
.br
|
||||
If the file exists lgogdownloader uses it instead of list specified with
|
||||
\fB--dlc-list\fP option
|
||||
|
||||
.TP
|
||||
\fI$XDG_CONFIG_HOME/lgogdownloader/gamespecific/gamename.conf\fP
|
||||
JSON formatted file. Sets game specific settings for \fBgamename\fP.
|
||||
|
@ -112,6 +112,17 @@ int Downloader::init()
|
||||
if (!bInitOK || !bWebsiteIsLoggedIn || config.bLoginHTTP || config.bLoginAPI)
|
||||
return 1;
|
||||
|
||||
if (!config.sGameHasDLCList.empty())
|
||||
{
|
||||
if (config.gamehasdlc.empty())
|
||||
{
|
||||
std::string game_has_dlc_list = this->getResponse(config.sGameHasDLCList);
|
||||
if (!game_has_dlc_list.empty())
|
||||
config.gamehasdlc.initialize(Util::tokenize(game_has_dlc_list, "\n"));
|
||||
}
|
||||
}
|
||||
gogWebsite->setConfig(config); // Update config for website handle
|
||||
|
||||
if (config.bCover && config.bDownload && !config.bUpdateCheck)
|
||||
coverXML = this->getResponse(config.sCoverList);
|
||||
|
||||
|
@ -204,14 +204,19 @@ std::vector<gameItem> Website::getGames()
|
||||
}
|
||||
}
|
||||
|
||||
if (!bDownloadDLCInfo && !config.gamehasdlc.empty())
|
||||
{
|
||||
if (config.gamehasdlc.isBlacklisted(game.name))
|
||||
bDownloadDLCInfo = true;
|
||||
}
|
||||
|
||||
// Check game specific config
|
||||
if (!config.bUpdateCache) // Disable game specific config files for cache update
|
||||
{
|
||||
gameSpecificConfig conf;
|
||||
conf.bIgnoreDLCCount = false; // Assume false
|
||||
conf.bIgnoreDLCCount = bDownloadDLCInfo;
|
||||
Util::getGameSpecificConfig(game.name, &conf);
|
||||
if (conf.bIgnoreDLCCount)
|
||||
bDownloadDLCInfo = true;
|
||||
bDownloadDLCInfo = conf.bIgnoreDLCCount;
|
||||
}
|
||||
|
||||
if (bDownloadDLCInfo && !config.sGameRegex.empty())
|
||||
|
Loading…
Reference in New Issue
Block a user