mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2024-11-20 11:49:17 +01:00
Code and comment cleanup
This commit is contained in:
parent
2a682ff666
commit
01430a5735
2
main.cpp
2
main.cpp
@ -85,7 +85,7 @@ int main(int argc, char *argv[])
|
|||||||
("repair", bpo::value<bool>(&config.bRepair)->zero_tokens()->default_value(false), "Repair downloaded files\nUse --repair --download to redownload files when filesizes don't match (possibly different version). Redownload will delete the old file")
|
("repair", bpo::value<bool>(&config.bRepair)->zero_tokens()->default_value(false), "Repair downloaded files\nUse --repair --download to redownload files when filesizes don't match (possibly different version). Redownload will delete the old file")
|
||||||
("game", bpo::value<std::string>(&config.sGameRegex)->default_value(""), "Set regular expression filter\nfor download/list/repair (Perl syntax)\nAliases: \"all\", \"free\"")
|
("game", bpo::value<std::string>(&config.sGameRegex)->default_value(""), "Set regular expression filter\nfor download/list/repair (Perl syntax)\nAliases: \"all\", \"free\"")
|
||||||
("directory", bpo::value<std::string>(&config.sDirectory)->default_value(""), "Set download directory")
|
("directory", bpo::value<std::string>(&config.sDirectory)->default_value(""), "Set download directory")
|
||||||
#ifndef ENVIRONMENT32
|
#ifdef ENVIRONMENT64
|
||||||
("limit-rate", bpo::value<curl_off_t>(&config.iDownloadRate)->default_value(0), "Limit download rate to value in kB\n0 = unlimited")
|
("limit-rate", bpo::value<curl_off_t>(&config.iDownloadRate)->default_value(0), "Limit download rate to value in kB\n0 = unlimited")
|
||||||
#endif
|
#endif
|
||||||
("create-xml", bpo::value<std::string>(&config.sXMLFile)->default_value(""), "Create GOG XML for file\n\"automatic\" to enable automatic XML creation")
|
("create-xml", bpo::value<std::string>(&config.sXMLFile)->default_value(""), "Create GOG XML for file\n\"automatic\" to enable automatic XML creation")
|
||||||
|
23
src/api.cpp
23
src/api.cpp
@ -372,13 +372,6 @@ std::string API::getInstallerLink(const std::string& game_name, const std::strin
|
|||||||
Json::Reader *jsonparser = new Json::Reader;
|
Json::Reader *jsonparser = new Json::Reader;
|
||||||
if (jsonparser->parse(json, root))
|
if (jsonparser->parse(json, root))
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
std::string result = root["result"].asString();
|
|
||||||
int timestamp = root["timestamp"].asInt();
|
|
||||||
int available = root["file"]["available"].asInt();
|
|
||||||
std::string link = root["file"]["link"].asString();
|
|
||||||
std::string message = root["file"]["message"].asString();
|
|
||||||
*/
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
std::cerr << "DEBUG INFO (API::getInstallerLink)" << std::endl << root << std::endl;
|
std::cerr << "DEBUG INFO (API::getInstallerLink)" << std::endl << root << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -417,15 +410,6 @@ std::string API::getExtraLink(const std::string& game_name, const std::string& i
|
|||||||
Json::Reader *jsonparser = new Json::Reader;
|
Json::Reader *jsonparser = new Json::Reader;
|
||||||
if (jsonparser->parse(json, root))
|
if (jsonparser->parse(json, root))
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
std::string result = root["result"].asString();
|
|
||||||
int timestamp = root["timestamp"].asInt();
|
|
||||||
int available = root["file"]["available"].asInt();
|
|
||||||
std::string link = root["file"]["link"].asString();
|
|
||||||
std::string type = root["file"]["type"].asString();
|
|
||||||
std::string name = root["file"]["name"].asString();
|
|
||||||
std::string message = root["file"]["message"].asString();
|
|
||||||
*/
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
std::cerr << "DEBUG INFO (API::getExtraLink)" << std::endl << root << std::endl;
|
std::cerr << "DEBUG INFO (API::getExtraLink)" << std::endl << root << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -465,13 +449,6 @@ std::string API::getXML(const std::string& game_name, const std::string& id)
|
|||||||
Json::Reader *jsonparser = new Json::Reader;
|
Json::Reader *jsonparser = new Json::Reader;
|
||||||
if (jsonparser->parse(json, root))
|
if (jsonparser->parse(json, root))
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
std::string result = root["result"].asString();
|
|
||||||
int timestamp = root["timestamp"].asInt();
|
|
||||||
int available = root["file"]["available"].asInt();
|
|
||||||
std::string link = root["file"]["link"].asString();
|
|
||||||
std::string message = root["file"]["message"].asString();
|
|
||||||
*/
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
std::cerr << "DEBUG INFO (API::getXML)" << std::endl << root << std::endl;
|
std::cerr << "DEBUG INFO (API::getXML)" << std::endl << root << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
@ -49,7 +49,6 @@ int Downloader::init()
|
|||||||
|
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
curlhandle = curl_easy_init();
|
curlhandle = curl_easy_init();
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, 0);
|
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_FOLLOWLOCATION, 1);
|
curl_easy_setopt(curlhandle, CURLOPT_FOLLOWLOCATION, 1);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_USERAGENT, config.sVersionString.c_str());
|
curl_easy_setopt(curlhandle, CURLOPT_USERAGENT, config.sVersionString.c_str());
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 0);
|
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 0);
|
||||||
@ -59,9 +58,10 @@ int Downloader::init()
|
|||||||
curl_easy_setopt(curlhandle, CURLOPT_COOKIEFILE, config.sCookiePath.c_str());
|
curl_easy_setopt(curlhandle, CURLOPT_COOKIEFILE, config.sCookiePath.c_str());
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_COOKIEJAR, config.sCookiePath.c_str());
|
curl_easy_setopt(curlhandle, CURLOPT_COOKIEJAR, config.sCookiePath.c_str());
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_SSL_VERIFYPEER, config.bVerifyPeer);
|
curl_easy_setopt(curlhandle, CURLOPT_SSL_VERIFYPEER, config.bVerifyPeer);
|
||||||
|
curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, config.bVerbose);
|
||||||
if (config.bVerbose)
|
#ifdef ENVIRONMENT64
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, 1);
|
curl_easy_setopt(curlhandle, CURLOPT_MAX_RECV_SPEED_LARGE, config.iDownloadRate);
|
||||||
|
#endif
|
||||||
|
|
||||||
gogAPI = new API(config.sToken, config.sSecret, config.bVerbose, config.bVerifyPeer);
|
gogAPI = new API(config.sToken, config.sSecret, config.bVerbose, config.bVerifyPeer);
|
||||||
progressbar = new ProgressBar(!config.bNoUnicode, !config.bNoColor);
|
progressbar = new ProgressBar(!config.bNoUnicode, !config.bNoColor);
|
||||||
@ -313,12 +313,8 @@ void Downloader::repair()
|
|||||||
curl_easy_setopt(curlhandle, CURLOPT_FOLLOWLOCATION, 1);
|
curl_easy_setopt(curlhandle, CURLOPT_FOLLOWLOCATION, 1);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_WRITEFUNCTION, Downloader::writeData);
|
curl_easy_setopt(curlhandle, CURLOPT_WRITEFUNCTION, Downloader::writeData);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_READFUNCTION, Downloader::readData);
|
curl_easy_setopt(curlhandle, CURLOPT_READFUNCTION, Downloader::readData);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_SSL_VERIFYPEER, config.bVerifyPeer);
|
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 0);
|
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 0);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_PROGRESSFUNCTION, Downloader::progressCallback);
|
curl_easy_setopt(curlhandle, CURLOPT_PROGRESSFUNCTION, Downloader::progressCallback);
|
||||||
#ifndef ENVIRONMENT32
|
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_MAX_RECV_SPEED_LARGE, config.iDownloadRate);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < games.size(); ++i)
|
for (unsigned int i = 0; i < games.size(); ++i)
|
||||||
{
|
{
|
||||||
@ -386,21 +382,14 @@ void Downloader::download()
|
|||||||
curl_easy_setopt(curlhandle, CURLOPT_FOLLOWLOCATION, 1);
|
curl_easy_setopt(curlhandle, CURLOPT_FOLLOWLOCATION, 1);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_WRITEFUNCTION, Downloader::writeData);
|
curl_easy_setopt(curlhandle, CURLOPT_WRITEFUNCTION, Downloader::writeData);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_READFUNCTION, Downloader::readData);
|
curl_easy_setopt(curlhandle, CURLOPT_READFUNCTION, Downloader::readData);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_SSL_VERIFYPEER, config.bVerifyPeer);
|
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 0);
|
curl_easy_setopt(curlhandle, CURLOPT_NOPROGRESS, 0);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_PROGRESSFUNCTION, Downloader::progressCallback);
|
curl_easy_setopt(curlhandle, CURLOPT_PROGRESSFUNCTION, Downloader::progressCallback);
|
||||||
#ifndef ENVIRONMENT32
|
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_MAX_RECV_SPEED_LARGE, config.iDownloadRate);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < games.size(); ++i)
|
for (unsigned int i = 0; i < games.size(); ++i)
|
||||||
{
|
{
|
||||||
// Download covers
|
// Download covers
|
||||||
if (!config.bNoCover && !config.bUpdateCheck)
|
if (!config.bNoCover && !config.bUpdateCheck)
|
||||||
{
|
{
|
||||||
// Doesn't work as intended unless we use "games[i].gamename" as base directory for installers and extras
|
|
||||||
// std::string directory = config.sDirectory + games[i].gamename + "/";
|
|
||||||
|
|
||||||
// Take path from installer path because for some games the base directory for installer/extra path is not "gamename"
|
// Take path from installer path because for some games the base directory for installer/extra path is not "gamename"
|
||||||
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].installers[0].path, games[i].gamename);
|
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].installers[0].path, games[i].gamename);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user