mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2025-02-02 05:52:31 +01:00
Add options to login separately to website and API
This commit is contained in:
parent
4c6ac86619
commit
f51cca5dff
@ -24,7 +24,8 @@ class Config
|
|||||||
bool bDownload;
|
bool bDownload;
|
||||||
bool bList;
|
bool bList;
|
||||||
bool bListDetails;
|
bool bListDetails;
|
||||||
bool bLogin;
|
bool bLoginHTTP;
|
||||||
|
bool bLoginAPI;
|
||||||
bool bRepair;
|
bool bRepair;
|
||||||
bool bInstallers;
|
bool bInstallers;
|
||||||
bool bExtras;
|
bool bExtras;
|
||||||
|
23
main.cpp
23
main.cpp
@ -129,12 +129,13 @@ int main(int argc, char *argv[])
|
|||||||
bool bNoTarGz = false;
|
bool bNoTarGz = false;
|
||||||
bool bNoCover = false;
|
bool bNoCover = false;
|
||||||
bool bNoPlatformDetection = false;
|
bool bNoPlatformDetection = false;
|
||||||
|
bool bLogin = false;
|
||||||
config.bReport = false;
|
config.bReport = false;
|
||||||
// Commandline options (no config file)
|
// Commandline options (no config file)
|
||||||
options_cli_no_cfg.add_options()
|
options_cli_no_cfg.add_options()
|
||||||
("help,h", "Print help message")
|
("help,h", "Print help message")
|
||||||
("version", "Print version information")
|
("version", "Print version information")
|
||||||
("login", bpo::value<bool>(&config.bLogin)->zero_tokens()->default_value(false), "Login")
|
("login", bpo::value<bool>(&bLogin)->zero_tokens()->default_value(false), "Login")
|
||||||
("list", bpo::value<bool>(&config.bList)->zero_tokens()->default_value(false), "List games")
|
("list", bpo::value<bool>(&config.bList)->zero_tokens()->default_value(false), "List games")
|
||||||
("list-details", bpo::value<bool>(&config.bListDetails)->zero_tokens()->default_value(false), "List games with detailed info")
|
("list-details", bpo::value<bool>(&config.bListDetails)->zero_tokens()->default_value(false), "List games with detailed info")
|
||||||
("download", bpo::value<bool>(&config.bDownload)->zero_tokens()->default_value(false), "Download")
|
("download", bpo::value<bool>(&config.bDownload)->zero_tokens()->default_value(false), "Download")
|
||||||
@ -152,6 +153,8 @@ int main(int argc, char *argv[])
|
|||||||
("no-platform-detection", bpo::value<bool>(&bNoPlatformDetection)->zero_tokens()->default_value(false), "Don't try to detect supported platforms from game shelf.\nSkips the initial fast platform detection and detects the supported platforms from game details which is slower but more accurate.\nUseful in case platform identifier is missing for some games in the game shelf.\nUsing --platform with --list doesn't work with this option.")
|
("no-platform-detection", bpo::value<bool>(&bNoPlatformDetection)->zero_tokens()->default_value(false), "Don't try to detect supported platforms from game shelf.\nSkips the initial fast platform detection and detects the supported platforms from game details which is slower but more accurate.\nUseful in case platform identifier is missing for some games in the game shelf.\nUsing --platform with --list doesn't work with this option.")
|
||||||
("download-file", bpo::value<std::string>(&config.sFileIdString)->default_value(""), "Download a single file using fileid\nFormat: \"gamename/fileid\"\nThis option ignores all subdir options. The file is downloaded to directory specified with --directory option.")
|
("download-file", bpo::value<std::string>(&config.sFileIdString)->default_value(""), "Download a single file using fileid\nFormat: \"gamename/fileid\"\nThis option ignores all subdir options. The file is downloaded to directory specified with --directory option.")
|
||||||
("wishlist", bpo::value<bool>(&config.bShowWishlist)->zero_tokens()->default_value(false), "Show wishlist")
|
("wishlist", bpo::value<bool>(&config.bShowWishlist)->zero_tokens()->default_value(false), "Show wishlist")
|
||||||
|
("login-api", bpo::value<bool>(&config.bLoginAPI)->zero_tokens()->default_value(false), "Login (API only)")
|
||||||
|
("login-website", bpo::value<bool>(&config.bLoginHTTP)->zero_tokens()->default_value(false), "Login (website only)")
|
||||||
;
|
;
|
||||||
// Commandline options (config file)
|
// Commandline options (config file)
|
||||||
options_cli_cfg.add_options()
|
options_cli_cfg.add_options()
|
||||||
@ -346,11 +349,17 @@ int main(int argc, char *argv[])
|
|||||||
if (bNoCover)
|
if (bNoCover)
|
||||||
config.bCover = false;
|
config.bCover = false;
|
||||||
|
|
||||||
// Handle priority business
|
if (bLogin)
|
||||||
if (!config.sLanguagePriority.empty())
|
{
|
||||||
handle_priority("languages", config.sLanguagePriority, config.vLanguagePriority, config.iInstallerLanguage);
|
config.bLoginAPI = true;
|
||||||
if (!config.sPlatformPriority.empty())
|
config.bLoginHTTP = true;
|
||||||
handle_priority("platforms", config.sPlatformPriority, config.vPlatformPriority, config.iInstallerType);
|
}
|
||||||
|
|
||||||
|
// Handle priority business
|
||||||
|
if (!config.sLanguagePriority.empty())
|
||||||
|
handle_priority("languages", config.sLanguagePriority, config.vLanguagePriority, config.iInstallerLanguage);
|
||||||
|
if (!config.sPlatformPriority.empty())
|
||||||
|
handle_priority("platforms", config.sPlatformPriority, config.vPlatformPriority, config.iInstallerType);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
@ -415,7 +424,7 @@ int main(int argc, char *argv[])
|
|||||||
int initResult = downloader.init();
|
int initResult = downloader.init();
|
||||||
|
|
||||||
int iLoginResult = 0;
|
int iLoginResult = 0;
|
||||||
if (config.bLogin || initResult == 1)
|
if (config.bLoginAPI || config.bLoginHTTP || initResult == 1)
|
||||||
{
|
{
|
||||||
iLoginResult = downloader.login();
|
iLoginResult = downloader.login();
|
||||||
if (iLoginResult == 0)
|
if (iLoginResult == 0)
|
||||||
|
@ -30,7 +30,7 @@ namespace bptime = boost::posix_time;
|
|||||||
Downloader::Downloader(Config &conf)
|
Downloader::Downloader(Config &conf)
|
||||||
{
|
{
|
||||||
this->config = conf;
|
this->config = conf;
|
||||||
if (config.bLogin && boost::filesystem::exists(config.sCookiePath))
|
if (config.bLoginHTTP && boost::filesystem::exists(config.sCookiePath))
|
||||||
if (!boost::filesystem::remove(config.sCookiePath))
|
if (!boost::filesystem::remove(config.sCookiePath))
|
||||||
std::cout << "Failed to delete " << config.sCookiePath << std::endl;
|
std::cout << "Failed to delete " << config.sCookiePath << std::endl;
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ int Downloader::init()
|
|||||||
progressbar = new ProgressBar(config.bUnicode, config.bColor);
|
progressbar = new ProgressBar(config.bUnicode, config.bColor);
|
||||||
|
|
||||||
bool bInitOK = gogAPI->init(); // Initialize the API
|
bool bInitOK = gogAPI->init(); // Initialize the API
|
||||||
if (!bInitOK || config.bLogin)
|
if (!bInitOK || config.bLoginHTTP || config.bLoginAPI)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (config.bCover && config.bDownload && !config.bUpdateCheck)
|
if (config.bCover && config.bDownload && !config.bUpdateCheck)
|
||||||
@ -133,29 +133,38 @@ int Downloader::login()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Login to website
|
// Login to website
|
||||||
if (!HTTP_Login(email, password))
|
if (config.bLoginHTTP)
|
||||||
{
|
{
|
||||||
std::cout << "HTTP: Login failed" << std::endl;
|
if (!HTTP_Login(email, password))
|
||||||
return 0;
|
{
|
||||||
}
|
std::cout << "HTTP: Login failed" << std::endl;
|
||||||
else
|
return 0;
|
||||||
{
|
}
|
||||||
std::cout << "HTTP: Login successful" << std::endl;
|
else
|
||||||
|
{
|
||||||
|
std::cout << "HTTP: Login successful" << std::endl;
|
||||||
|
if (!config.bLoginAPI)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Login to API
|
// Login to API
|
||||||
if (!gogAPI->login(email, password))
|
if (config.bLoginAPI)
|
||||||
{
|
{
|
||||||
std::cout << "API: Login failed" << std::endl;
|
if (!gogAPI->login(email, password))
|
||||||
return 0;
|
{
|
||||||
}
|
std::cout << "API: Login failed" << std::endl;
|
||||||
else
|
return 0;
|
||||||
{
|
}
|
||||||
std::cout << "API: Login successful" << std::endl;
|
else
|
||||||
config.sToken = gogAPI->getToken();
|
{
|
||||||
config.sSecret = gogAPI->getSecret();
|
std::cout << "API: Login successful" << std::endl;
|
||||||
return 1;
|
config.sToken = gogAPI->getToken();
|
||||||
|
config.sSecret = gogAPI->getSecret();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Downloader::updateCheck()
|
void Downloader::updateCheck()
|
||||||
@ -1508,7 +1517,7 @@ int Downloader::repairFile(const std::string& url, const std::string& filepath,
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if file sizes match
|
// check if file sizes match
|
||||||
if (offset != filesize)
|
if (offset != filesize)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user