Add option to list user data

This commit is contained in:
Sude 2024-03-31 11:30:12 +03:00
parent eff194bcfe
commit 1866f4c65c
2 changed files with 18 additions and 1 deletions

View File

@ -123,6 +123,7 @@ namespace GlobalConstants
const unsigned int LIST_FORMAT_DETAILS_JSON = 1 << 2;
const unsigned int LIST_FORMAT_TAGS = 1 << 3;
const unsigned int LIST_FORMAT_TRANSFORMATIONS = 1 << 4;
const unsigned int LIST_FORMAT_USERDATA = 1 << 5;
const std::vector<optionsStruct> LIST_FORMAT =
{
@ -130,7 +131,8 @@ namespace GlobalConstants
{ LIST_FORMAT_DETAILS_TEXT, "details", "Details", "d|details" },
{ LIST_FORMAT_DETAILS_JSON, "json", "JSON", "j|json" },
{ LIST_FORMAT_TAGS, "tags", "Tags", "t|tags" },
{ LIST_FORMAT_TRANSFORMATIONS, "transform", "Transformations", "tr|transform|transformations" }
{ LIST_FORMAT_TRANSFORMATIONS, "transform", "Transformations", "tr|transform|transformations" },
{ LIST_FORMAT_USERDATA, "userdata", "User data", "ud|userdata" }
};
const unsigned int GFTYPE_BASE_INSTALLER = 1 << 0;

View File

@ -565,6 +565,21 @@ int Downloader::listGames()
}
}
}
else if (Globals::globalConfig.iListFormat == GlobalConstants::LIST_FORMAT_USERDATA)
{
Json::Value userdata;
std::istringstream response(gogWebsite->getResponse("https://embed.gog.com/userData.json"));
try
{
response >> userdata;
}
catch(const Json::Exception& exc)
{
std::cerr << "Failed to get user data" << std::endl;
return 1;
}
std::cout << userdata << std::endl;
}
else
{
if (this->games.empty()) {