Skip to content

Commit

Permalink
Improvements to --download-file option
Browse files Browse the repository at this point in the history
Allows downloading DLC files by extending file selection.
Files can be selected by using the name of dlc
--download-file "gamename/dlc_gamename/fileid"
  • Loading branch information
Sude- committed May 13, 2024
1 parent 81fdfea commit 761c3f1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ int main(int argc, char *argv[])
("report", bpo::value<std::string>(&Globals::globalConfig.sReportFilePath)->implicit_value("lgogdownloader-report.log"), "Save report of downloaded/repaired files to specified file\nDefault filename: lgogdownloader-report.log")
("update-cache", bpo::value<bool>(&Globals::globalConfig.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>(&Globals::globalConfig.sFileIdString)->default_value(""), "Download files using fileid\n\nFormat:\n\"gamename/fileid\"\nor: \"gogdownloader://gamename/fileid\"\n\nMultiple files:\n\"gamename1/fileid1,gamename2/fileid2\"\nor: \"gogdownloader://gamename1/fileid1,gamename2/fileid2\"\n\nThis option ignores all subdir options. The files are downloaded to directory specified with --directory option.")
("download-file", bpo::value<std::string>(&Globals::globalConfig.sFileIdString)->default_value(""), "Download files using fileid\n\nFormat:\n\"gamename/fileid\"\n\"gamename/dlc_gamename/fileid\"\n\"gogdownloader://gamename/fileid\"\n\"gogdownloader://gamename/dlc_name/fileid\"\n\nMultiple files:\n\"gamename1/fileid1,gamename2/fileid2,gamename2/dlcname/fileid1\"\n\nThis option ignores all subdir options. The files are downloaded to directory specified with --directory option.")
("output-file,o", bpo::value<std::string>(&Globals::globalConfig.sOutputFilename)->default_value(""), "Set filename of file downloaded with --download-file.")
("wishlist", bpo::value<bool>(&Globals::globalConfig.bShowWishlist)->zero_tokens()->default_value(false), "Show wishlist")
("cacert", bpo::value<std::string>(&Globals::globalConfig.curlConf.sCACertPath)->default_value(""), "Path to CA certificate bundle in PEM format")
Expand Down
26 changes: 22 additions & 4 deletions src/downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2405,12 +2405,24 @@ int Downloader::downloadFileWithId(const std::string& fileid_string, const std::
}
else
{
std::string gamename, fileid, url;
gamename.assign(fileid_string.begin(), fileid_string.begin()+pos);
fileid.assign(fileid_string.begin()+pos+1, fileid_string.end());
bool bIsDLC = false;
std::string gamename, dlc_gamename, fileid, url;
std::vector<std::string> fileid_vector = Util::tokenize(fileid_string, "/");
if (fileid_vector.size() == 3)
bIsDLC = true;

gamename = fileid_vector[0];
if (bIsDLC)
{
dlc_gamename = fileid_vector[1];
fileid = fileid_vector[2];
}
else
fileid = fileid_vector[1];

std::string product_id;
bool bSelectOK = this->galaxySelectProductIdHelper(gamename, product_id);
std::string gamename_select = "^" + gamename + "$";
bool bSelectOK = this->galaxySelectProductIdHelper(gamename_select, product_id);

if (!bSelectOK || product_id.empty())
{
Expand All @@ -2432,6 +2444,12 @@ int Downloader::downloadFileWithId(const std::string& fileid_string, const std::
bool bFoundMatchingFile = false;
for (auto f : vFiles)
{
if (bIsDLC)
{
if (f.gamename != dlc_gamename)
continue;
}

if (f.id == fileid)
{
gf = f;
Expand Down

0 comments on commit 761c3f1

Please sign in to comment.