Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ class Config
std::string sGameHasDLCListFilePath;
std::string sReportFilePath;
std::string sTransformConfigFilePath;
std::string sGameListFilePath;

std::string sXMLFile;

Expand Down
3 changes: 2 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ int main(int argc, char *argv[])
("list", bpo::value<std::string>(&sListFormat)->implicit_value("games"), list_format_text.c_str())
("download", bpo::value<bool>(&Globals::globalConfig.bDownload)->zero_tokens()->default_value(false), "Download")
("repair", bpo::value<bool>(&Globals::globalConfig.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 rename the old file (appends .old to filename)")
("game", bpo::value<std::string>(&Globals::globalConfig.sGameRegex)->default_value(""), "Set regular expression filter\nfor download/list/repair (Perl syntax)")
("game", bpo::value<std::string>(&Globals::globalConfig.sGameRegex)->default_value(""), "Set regular expression filter\nfor download/list/repair (Perl syntax). Takes precedence over --game-list if both are specified.")
("game-list", bpo::value<std::string>(&Globals::globalConfig.sGameListFilePath)->default_value(""), "Set file with a list of regular expressions to filter\nfor download/list/repair (Perl syntax)")
("create-xml", bpo::value<std::string>(&Globals::globalConfig.sXMLFile)->implicit_value("automatic"), "Create GOG XML for file\n\"automatic\" to enable automatic XML creation")
("notifications", bpo::value<bool>(&Globals::globalConfig.bNotifications)->zero_tokens()->default_value(false), "Check notifications")
("updated", bpo::value<bool>(&Globals::globalConfig.bUpdated)->zero_tokens()->default_value(false), "List/download only games with update flag set")
Expand Down
4 changes: 4 additions & 0 deletions man/lgogdownloader.1
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ Use \fB\-\-repair\fR \fB\-\-download\fR to redownload files when filesizes don't
.TP
\fB\-\-game\fR arg
Set regular expression filter
for download/list/repair (Perl syntax). Takes precedence over \fB\-\-game\-list\fR if both are specified.
.TP
\fB\-\-game\-list\fR arg
Set file with a list of regular expressions to filter
for download/list/repair (Perl syntax)
.TP
\fB\-\-create\-xml\fR [=arg(=automatic)]
Expand Down
58 changes: 50 additions & 8 deletions src/website.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,31 @@ std::vector<gameItem> Website::getGames()
} while (!bAllPagesParsed);
std::cerr << std::endl;

// Populate game filter list
std::vector<boost::regex> gameFilters;
if (!Globals::globalConfig.sGameRegex.empty())
{
gameFilters.emplace_back(Globals::globalConfig.sGameRegex);
}
else if (!Globals::globalConfig.sGameListFilePath.empty())
{
std::ifstream ifs(Globals::globalConfig.sGameListFilePath.c_str());
if (!ifs)
{
std::cerr << "Could not open game filter list file: " << Globals::globalConfig.sGameListFilePath << std::endl;
}
else
{
std::string line;
while (!ifs.eof())
{
std::getline(ifs, line);
if (!line.empty())
gameFilters.emplace_back(line);
}
}
}

unsigned int iProduct = 0;
unsigned int iProductTotal = jsonProductInfo.size();
for (auto product : jsonProductInfo)
Expand Down Expand Up @@ -197,12 +222,23 @@ std::vector<gameItem> Website::getGames()
continue;

// Filter the game list
if (!Globals::globalConfig.sGameRegex.empty())
if (!gameFilters.empty())
{
boost::regex expression(Globals::globalConfig.sGameRegex);
boost::match_results<std::string::const_iterator> what;
if (!boost::regex_search(game.name, what, expression)) // Check if name matches the specified regex
bool found = false;
for (const auto& expression : gameFilters)
{
boost::match_results<std::string::const_iterator> what;
if (!boost::regex_search(game.name, what, expression)) // Check if name matches the specified regex
continue;

found = true;
break;
}

if (!found)
{
continue;
}
}

if (Globals::globalConfig.dlConf.iInclude & GlobalConstants::GFTYPE_DLC)
Expand Down Expand Up @@ -233,12 +269,18 @@ std::vector<gameItem> Website::getGames()
if (bDownloadDLCInfo && !Globals::globalConfig.sGameRegex.empty())
{
// don't download unnecessary info if user is only interested in a subset of his account
boost::regex expression(Globals::globalConfig.sGameRegex);
boost::match_results<std::string::const_iterator> what;
if (!boost::regex_search(game.name, what, expression))
bool found = false;
for (const auto& expression : gameFilters)
{
bDownloadDLCInfo = false;
boost::match_results<std::string::const_iterator> what;
if (!boost::regex_search(game.name, what, expression)) // Check if name matches the specified regex
continue;

found = true;
break;
}

bDownloadDLCInfo = found;
}

if (bDownloadDLCInfo)
Expand Down