Remove dlc-list support and a small change to getting game names

This commit is contained in:
Sude 2025-02-16 15:42:36 +02:00
parent 367b57ca89
commit 759bb1d992
6 changed files with 114 additions and 170 deletions

View File

@ -309,15 +309,12 @@ class Config
// Lists
Blacklist blacklist;
Blacklist ignorelist;
Blacklist gamehasdlc;
// Cloud save options
std::vector<std::string> cloudWhiteList;
std::vector<std::string> cloudBlackList;
bool bCloudForce;
std::string sGameHasDLCList;
// Integers
int iRetries;
unsigned int iThreads;

View File

@ -59,7 +59,6 @@ int main(int argc, char *argv[])
Globals::globalConfig.sConfigFilePath = Globals::globalConfig.sConfigDirectory + "/config.cfg";
Globals::globalConfig.sBlacklistFilePath = Globals::globalConfig.sConfigDirectory + "/blacklist.txt";
Globals::globalConfig.sIgnorelistFilePath = Globals::globalConfig.sConfigDirectory + "/ignorelist.txt";
Globals::globalConfig.sGameHasDLCListFilePath = Globals::globalConfig.sConfigDirectory + "/game_has_dlc.txt";
Globals::globalConfig.sTransformConfigFilePath = Globals::globalConfig.sConfigDirectory + "/transformations.json";
Globals::galaxyConf.setFilepath(Globals::globalConfig.sConfigDirectory + "/galaxy_tokens.json");
@ -196,7 +195,6 @@ int main(int argc, char *argv[])
bool bNoSubDirectories = false;
bool bNoPlatformDetection = false;
bool bNoGalaxyDependencies = false;
bool bUseDLCList = false;
bool bNoFastStatusCheck = false;
std::string sInstallerPlatform;
std::string sInstallerLanguage;
@ -290,8 +288,6 @@ int main(int argc, char *argv[])
("save-changelogs", bpo::value<bool>(&Globals::globalConfig.dlConf.bSaveChangelogs)->zero_tokens()->default_value(false), "Save changelogs when downloading")
("threads", bpo::value<unsigned int>(&Globals::globalConfig.iThreads)->default_value(4), "Number of download threads")
("info-threads", bpo::value<unsigned int>(&Globals::globalConfig.iInfoThreads)->default_value(4), "Number of threads for getting product info")
("use-dlc-list", bpo::value<bool>(&bUseDLCList)->zero_tokens()->default_value(false), "Use DLC list specified with --dlc-list")
("dlc-list", bpo::value<std::string>(&Globals::globalConfig.sGameHasDLCList)->default_value("https://raw.githubusercontent.com/Sude-/lgogdownloader-lists/master/game_has_dlc.txt"), "Set URL for list of games that have DLC")
("progress-interval", bpo::value<int>(&Globals::globalConfig.iProgressInterval)->default_value(100), "Set interval for progress bar update (milliseconds)\nValue must be between 1 and 10000")
("lowspeed-timeout", bpo::value<long int>(&Globals::globalConfig.curlConf.iLowSpeedTimeout)->default_value(30), "Set time in number seconds that the transfer speed should be below the rate set with --lowspeed-rate for it to considered too slow and aborted")
("lowspeed-rate", bpo::value<long int>(&Globals::globalConfig.curlConf.iLowSpeedTimeoutRate)->default_value(200), "Set average transfer speed in bytes per second that the transfer should be below during time specified with --lowspeed-timeout for it to be considered too slow and aborted")
@ -449,33 +445,6 @@ int main(int argc, char *argv[])
Globals::globalConfig.transformationsJSON = Util::readJsonFile(Globals::globalConfig.sTransformConfigFilePath);
}
if (!bUseDLCList)
Globals::globalConfig.sGameHasDLCList = "";
if (Globals::globalConfig.sIgnoreDLCCountRegex.empty())
{
if (boost::filesystem::exists(Globals::globalConfig.sGameHasDLCListFilePath) && bUseDLCList)
{
std::ifstream ifs(Globals::globalConfig.sGameHasDLCListFilePath.c_str());
if (!ifs)
{
std::cerr << "Could not open list of games that have dlc: " << Globals::globalConfig.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));
}
Globals::globalConfig.gamehasdlc.initialize(lines);
}
}
}
#ifdef USE_QT_GUI_LOGIN
if (Globals::globalConfig.bForceGUILogin)
{

View File

@ -411,12 +411,6 @@ Number of download threads
\fB\-\-info\-threads\fR arg (=4)
Number of threads for getting product info
.TP
\fB\-\-use\-dlc\-list\fR
Use DLC list specified with \fB\-\-dlc\-list\fR
.TP
\fB\-\-dlc\-list\fR arg (=https://raw.githubusercontent.com/Sude\-/lgogdownloader\-lists/master/game_has_dlc.txt)
Set URL for list of games that have DLC
.TP
\fB\-\-progress\-interval\fR arg (=100)
Set interval for progress bar update (milliseconds)
.br
@ -742,17 +736,6 @@ 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.

View File

@ -200,16 +200,6 @@ bool Downloader::isLoggedIn()
*/
int Downloader::init()
{
if (!Globals::globalConfig.sGameHasDLCList.empty())
{
if (Globals::globalConfig.gamehasdlc.empty())
{
std::string game_has_dlc_list = this->getResponse(Globals::globalConfig.sGameHasDLCList);
if (!game_has_dlc_list.empty())
Globals::globalConfig.gamehasdlc.initialize(Util::tokenize(game_has_dlc_list, "\n"));
}
}
if (!gogGalaxy->init())
{
if (gogGalaxy->refreshLogin())

View File

@ -498,6 +498,8 @@ std::vector<std::string> Util::getDLCNamesFromJSON(const Json::Value &root)
{
std::string gamename;
std::string url_prefix = "/downloads/";
if (urls[i].find(url_prefix) == std::string::npos)
continue;
gamename.assign(urls[i].begin()+urls[i].find(url_prefix)+url_prefix.length(), urls[i].begin()+urls[i].find_last_of("/"));
bool bDuplicate = false;

View File

@ -97,7 +97,7 @@ std::vector<gameItem> Website::getGames()
{
std::vector<gameItem> games;
Json::Value root;
int i = 1;
int iPage = 1;
bool bAllPagesParsed = false;
int iUpdated = Globals::globalConfig.bUpdated ? 1 : 0;
int iHidden = 0;
@ -111,9 +111,10 @@ std::vector<gameItem> Website::getGames()
}
Globals::vOwnedGamesIds = this->getOwnedGamesIds();
std::vector<Json::Value> jsonProductInfo;
do
{
std::string url = "https://www.gog.com/account/getFilteredProducts?hiddenFlag=" + std::to_string(iHidden) + "&isUpdated=" + std::to_string(iUpdated) + "&mediaType=1&sortBy=title&system=&page=" + std::to_string(i);
std::string url = "https://www.gog.com/account/getFilteredProducts?hiddenFlag=" + std::to_string(iHidden) + "&isUpdated=" + std::to_string(iUpdated) + "&mediaType=1&sortBy=title&system=&page=" + std::to_string(iPage);
if (!tags.empty())
url += "&tags=" + tags;
@ -121,6 +122,8 @@ std::vector<gameItem> Website::getGames()
if (root.empty())
continue;
std::cerr << "\033[KGetting product data " << root["page"].asInt() << " / " << root["totalPages"].asInt() << "\r" << std::flush;
if (root["page"].asInt() == root["totalPages"].asInt() || root["totalPages"].asInt() == 0)
bAllPagesParsed = true;
@ -129,15 +132,24 @@ std::vector<gameItem> Website::getGames()
{
bAllPagesParsed = false;
iHidden = 1;
i = 0; // Set to 0 because we increment it at the end of the loop
iPage = 0; // Set to 0 because we increment it at the end of the loop
}
if (root["products"].isArray())
{
for (unsigned int i = 0; i < root["products"].size(); ++i)
for (auto product : root["products"])
jsonProductInfo.push_back(product);
}
iPage++;
} while (!bAllPagesParsed);
std::cerr << std::endl;
unsigned int iProduct = 0;
unsigned int iProductTotal = jsonProductInfo.size();
for (auto product : jsonProductInfo)
{
std::cerr << "\033[KGetting game names " << "(" << root["page"].asInt() << "/" << root["totalPages"].asInt() << ") " << i+1 << " / " << root["products"].size() << "\r" << std::flush;
Json::Value product = root["products"][i];
iProduct++;
std::cerr << "\033[KGetting game names " << iProduct << " / " << iProductTotal << "\r" << std::flush;
gameItem game;
game.name = product["slug"].asString();
game.id = product["id"].isInt() ? std::to_string(product["id"].asInt()) : product["id"].asString();
@ -209,12 +221,6 @@ std::vector<gameItem> Website::getGames()
}
}
if (!bDownloadDLCInfo && !Globals::globalConfig.gamehasdlc.empty())
{
if (Globals::globalConfig.gamehasdlc.isBlacklisted(game.name))
bDownloadDLCInfo = true;
}
// Check game specific config
if (!Globals::globalConfig.bUpdateCache) // Disable game specific config files for cache update
{
@ -244,9 +250,6 @@ std::vector<gameItem> Website::getGames()
}
games.push_back(game);
}
}
i++;
} while (!bAllPagesParsed);
std::cerr << std::endl;
if (Globals::globalConfig.bIncludeHiddenProducts)