diff --git a/include/config.h b/include/config.h index f038229..452c67b 100644 --- a/include/config.h +++ b/include/config.h @@ -223,6 +223,7 @@ class Config bool bCheckStatus; bool bShowWishlist; bool bNotifications; + bool bIncludeHiddenProducts; bool bVerbose; bool bUnicode; // use Unicode in console output diff --git a/main.cpp b/main.cpp index 2df784d..bada05a 100644 --- a/main.cpp +++ b/main.cpp @@ -244,6 +244,7 @@ int main(int argc, char *argv[]) ("progress-interval", bpo::value(&Globals::globalConfig.iProgressInterval)->default_value(100), "Set interval for progress bar update (milliseconds)\nValue must be between 1 and 10000") ("lowspeed-timeout", bpo::value(&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(&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(&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() diff --git a/src/website.cpp b/src/website.cpp index 8af2e4f..0885cda 100644 --- a/src/website.cpp +++ b/src/website.cpp @@ -125,10 +125,11 @@ std::vector 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 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 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; }