mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2024-11-20 11:49:17 +01:00
Merge branch 'outname' of https://github.com/bwrsandman/lgogdownloader
This commit is contained in:
commit
b6d07f5343
@ -68,6 +68,7 @@ class Config
|
||||
std::string sDLCSubdir;
|
||||
std::string sGameSubdir;
|
||||
std::string sFileIdString;
|
||||
std::string sOutputFilename;
|
||||
std::string sLanguagePriority;
|
||||
std::string sPlatformPriority;
|
||||
std::string sIgnoreDLCCountRegex;
|
||||
|
@ -68,7 +68,7 @@ class Downloader
|
||||
void checkOrphans();
|
||||
void checkStatus();
|
||||
void updateCache();
|
||||
void downloadFileWithId(const std::string& fileid_string);
|
||||
void downloadFileWithId(const std::string& fileid_string, const std::string& output_filepath);
|
||||
void showWishlist();
|
||||
CURL* curlhandle;
|
||||
Timer timer;
|
||||
|
5
main.cpp
5
main.cpp
@ -151,6 +151,7 @@ int main(int argc, char *argv[])
|
||||
("update-cache", bpo::value<bool>(&config.bUpdateCache)->zero_tokens()->default_value(false), "Update game details cache")
|
||||
("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\"\nor: \"gogdownloader://gamename/fileid\"\nThis option ignores all subdir options. The file is downloaded to directory specified with --directory option.")
|
||||
("output-file,o", bpo::value<std::string>(&config.sOutputFilename)->default_value(""), "Set filename of file downloaded with --download-file.")
|
||||
("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)")
|
||||
@ -525,12 +526,12 @@ int main(int argc, char *argv[])
|
||||
size_t back = config.sFileIdString.find(',', front);
|
||||
if (back == (size_t) -1)
|
||||
back = config.sFileIdString.length();
|
||||
downloader.downloadFileWithId(config.sFileIdString.substr(front, back-front));
|
||||
downloader.downloadFileWithId(config.sFileIdString.substr(front, back-front), config.sOutputFilename);
|
||||
front = back + 1;
|
||||
} while(front < config.sFileIdString.length());
|
||||
}
|
||||
else
|
||||
downloader.downloadFileWithId(config.sFileIdString);
|
||||
downloader.downloadFileWithId(config.sFileIdString, config.sOutputFilename);
|
||||
}
|
||||
else if (config.bRepair) // Repair file
|
||||
downloader.repair();
|
||||
|
@ -1174,6 +1174,7 @@ CURLcode Downloader::downloadFile(const std::string& url, const std::string& fil
|
||||
|
||||
// Get directory from filepath
|
||||
boost::filesystem::path pathname = filepath;
|
||||
pathname = boost::filesystem::absolute(pathname, boost::filesystem::current_path());
|
||||
std::string directory = pathname.parent_path().string();
|
||||
std::string filenameXML = pathname.filename().string() + ".xml";
|
||||
std::string xml_directory;
|
||||
@ -3174,13 +3175,17 @@ void Downloader::saveSerials(const std::string& serials, const std::string& file
|
||||
return;
|
||||
}
|
||||
|
||||
void Downloader::downloadFileWithId(const std::string& fileid_string)
|
||||
void Downloader::downloadFileWithId(const std::string& fileid_string, const std::string& output_filepath)
|
||||
{
|
||||
size_t pos = fileid_string.find("/");
|
||||
if (pos == std::string::npos)
|
||||
{
|
||||
std::cout << "Invalid file id " << fileid_string << ": could not find separator \"/\"" << std::endl;
|
||||
}
|
||||
else if (!output_filepath.empty() && boost::filesystem::is_directory(output_filepath))
|
||||
{
|
||||
std::cout << "Failed to create the file " << output_filepath << ": Is a directory" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string gamename, fileid, url;
|
||||
@ -3198,7 +3203,10 @@ void Downloader::downloadFileWithId(const std::string& fileid_string)
|
||||
{
|
||||
std::string filename, filepath;
|
||||
filename.assign(url.begin()+url.find_last_of("/")+1, url.begin()+url.find_first_of("?"));
|
||||
if (output_filepath.empty())
|
||||
filepath = Util::makeFilepath(config.sDirectory, filename, gamename);
|
||||
else
|
||||
filepath = output_filepath;
|
||||
std::cout << "Downloading: " << filepath << std::endl;
|
||||
this->downloadFile(url, filepath, std::string(), gamename);
|
||||
std::cout << std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user