mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2025-02-02 05:52:31 +01:00
Add option to include hidden products
Adds option --include-hidden-products that allows user to list and download products that have been set hidden in account page.
This commit is contained in:
parent
f4c8db78ae
commit
df628b2a59
@ -223,6 +223,7 @@ class Config
|
||||
bool bCheckStatus;
|
||||
bool bShowWishlist;
|
||||
bool bNotifications;
|
||||
bool bIncludeHiddenProducts;
|
||||
|
||||
bool bVerbose;
|
||||
bool bUnicode; // use Unicode in console output
|
||||
|
1
main.cpp
1
main.cpp
@ -244,6 +244,7 @@ int main(int argc, char *argv[])
|
||||
("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")
|
||||
("include-hidden-products", bpo::value<bool>(&Globals::globalConfig.bIncludeHiddenProducts)->zero_tokens()->default_value(false), "Include games that have been set hidden in account page")
|
||||
;
|
||||
// Options read from config file
|
||||
options_cfg_only.add_options()
|
||||
|
@ -125,10 +125,11 @@ std::vector<gameItem> Website::getGames()
|
||||
int i = 1;
|
||||
bool bAllPagesParsed = false;
|
||||
int iUpdated = Globals::globalConfig.bUpdated ? 1 : 0;
|
||||
int iHidden = 0;
|
||||
|
||||
do
|
||||
{
|
||||
std::string response = this->getResponse("https://www.gog.com/account/getFilteredProducts?hasHiddenProducts=false&hiddenFlag=0&isUpdated=" + std::to_string(iUpdated) + "&mediaType=1&sortBy=title&system=&page=" + std::to_string(i));
|
||||
std::string response = this->getResponse("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::istringstream json_stream(response);
|
||||
|
||||
try {
|
||||
@ -154,6 +155,15 @@ std::vector<gameItem> Website::getGames()
|
||||
#endif
|
||||
if (root["page"].asInt() == root["totalPages"].asInt() || root["totalPages"].asInt() == 0)
|
||||
bAllPagesParsed = true;
|
||||
|
||||
// Make the next loop handle hidden products
|
||||
if (Globals::globalConfig.bIncludeHiddenProducts && bAllPagesParsed && iHidden == 0)
|
||||
{
|
||||
bAllPagesParsed = false;
|
||||
iHidden = 1;
|
||||
i = 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)
|
||||
@ -266,6 +276,11 @@ std::vector<gameItem> Website::getGames()
|
||||
} while (!bAllPagesParsed);
|
||||
std::cerr << std::endl;
|
||||
|
||||
if (Globals::globalConfig.bIncludeHiddenProducts)
|
||||
{
|
||||
std::sort(games.begin(), games.end(), [](const gameItem& i, const gameItem& j) -> bool { return i.name < j.name; });
|
||||
}
|
||||
|
||||
return games;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user