mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2025-02-02 05:52:31 +01:00
API: Unescape file paths
Some file paths returned by the API are url encoded. Use curl_easy_unescape to url decode all file paths returned by the API.
This commit is contained in:
parent
3fb05682c6
commit
a9e61b00ba
21
src/api.cpp
21
src/api.cpp
@ -356,6 +356,8 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int
|
|||||||
{
|
{
|
||||||
Json::Value installer = installers[i].jsonNode[index];
|
Json::Value installer = installers[i].jsonNode[index];
|
||||||
unsigned int language = installers[i].language;
|
unsigned int language = installers[i].language;
|
||||||
|
std::string path = installer["link"].asString();
|
||||||
|
path = (std::string)curl_easy_unescape(curlhandle, path.c_str(), path.size(), NULL);
|
||||||
|
|
||||||
// Check for duplicate installers in different languages and add languageId of duplicate installer to the original installer
|
// Check for duplicate installers in different languages and add languageId of duplicate installer to the original installer
|
||||||
// https://secure.gog.com/forum/general/introducing_the_beta_release_of_the_new_gogcom_downloader/post1483
|
// https://secure.gog.com/forum/general/introducing_the_beta_release_of_the_new_gogcom_downloader/post1483
|
||||||
@ -364,7 +366,7 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int
|
|||||||
bool bDuplicate = false;
|
bool bDuplicate = false;
|
||||||
for (unsigned int j = 0; j < game.installers.size(); ++j)
|
for (unsigned int j = 0; j < game.installers.size(); ++j)
|
||||||
{
|
{
|
||||||
if (game.installers[j].path == installer["link"].asString())
|
if (game.installers[j].path == path)
|
||||||
{
|
{
|
||||||
game.installers[j].language |= language; // Add language code to installer
|
game.installers[j].language |= language; // Add language code to installer
|
||||||
bDuplicate = true;
|
bDuplicate = true;
|
||||||
@ -381,7 +383,7 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int
|
|||||||
gf.updated = installer["notificated"].isInt() ? installer["notificated"].asInt() : std::stoi(installer["notificated"].asString());
|
gf.updated = installer["notificated"].isInt() ? installer["notificated"].asInt() : std::stoi(installer["notificated"].asString());
|
||||||
gf.id = installer["id"].isInt() ? std::to_string(installer["id"].asInt()) : installer["id"].asString();
|
gf.id = installer["id"].isInt() ? std::to_string(installer["id"].asInt()) : installer["id"].asString();
|
||||||
gf.name = installer["name"].asString();
|
gf.name = installer["name"].asString();
|
||||||
gf.path = installer["link"].asString();
|
gf.path = path;
|
||||||
gf.size = installer["size"].asString();
|
gf.size = installer["size"].asString();
|
||||||
gf.language = language;
|
gf.language = language;
|
||||||
gf.platform = installers[i].platform;
|
gf.platform = installers[i].platform;
|
||||||
@ -404,6 +406,7 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int
|
|||||||
gf.id = extra["id"].isInt() ? std::to_string(extra["id"].asInt()) : extra["id"].asString();
|
gf.id = extra["id"].isInt() ? std::to_string(extra["id"].asInt()) : extra["id"].asString();
|
||||||
gf.name = extra["name"].asString();
|
gf.name = extra["name"].asString();
|
||||||
gf.path = extra["link"].asString();
|
gf.path = extra["link"].asString();
|
||||||
|
gf.path = (std::string)curl_easy_unescape(curlhandle, gf.path.c_str(), gf.path.size(), NULL);
|
||||||
gf.size = extra["size_mb"].asString();
|
gf.size = extra["size_mb"].asString();
|
||||||
|
|
||||||
game.extras.push_back(gf);
|
game.extras.push_back(gf);
|
||||||
@ -446,6 +449,8 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int
|
|||||||
for ( unsigned int index = 0; index < patchnode.size(); ++index )
|
for ( unsigned int index = 0; index < patchnode.size(); ++index )
|
||||||
{
|
{
|
||||||
Json::Value patch = patchnode[index];
|
Json::Value patch = patchnode[index];
|
||||||
|
std::string path = patch["link"].asString();
|
||||||
|
path = (std::string)curl_easy_unescape(curlhandle, path.c_str(), path.size(), NULL);
|
||||||
|
|
||||||
// Check for duplicate patches in different languages and add languageId of duplicate patch to the original patch
|
// Check for duplicate patches in different languages and add languageId of duplicate patch to the original patch
|
||||||
if (useDuplicateHandler)
|
if (useDuplicateHandler)
|
||||||
@ -453,7 +458,7 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int
|
|||||||
bool bDuplicate = false;
|
bool bDuplicate = false;
|
||||||
for (unsigned int j = 0; j < game.patches.size(); ++j)
|
for (unsigned int j = 0; j < game.patches.size(); ++j)
|
||||||
{
|
{
|
||||||
if (game.patches[j].path == patch["link"].asString())
|
if (game.patches[j].path == path)
|
||||||
{
|
{
|
||||||
game.patches[j].language |= GlobalConstants::LANGUAGES[i].id; // Add language code to patch
|
game.patches[j].language |= GlobalConstants::LANGUAGES[i].id; // Add language code to patch
|
||||||
bDuplicate = true;
|
bDuplicate = true;
|
||||||
@ -470,7 +475,7 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int
|
|||||||
gf.updated = patch["notificated"].isInt() ? patch["notificated"].asInt() : std::stoi(patch["notificated"].asString());
|
gf.updated = patch["notificated"].isInt() ? patch["notificated"].asInt() : std::stoi(patch["notificated"].asString());
|
||||||
gf.id = patch["id"].isInt() ? std::to_string(patch["id"].asInt()) : patch["id"].asString();
|
gf.id = patch["id"].isInt() ? std::to_string(patch["id"].asInt()) : patch["id"].asString();
|
||||||
gf.name = patch["name"].asString();
|
gf.name = patch["name"].asString();
|
||||||
gf.path = patch["link"].asString();
|
gf.path = path;
|
||||||
gf.size = patch["size"].asString();
|
gf.size = patch["size"].asString();
|
||||||
gf.language = GlobalConstants::LANGUAGES[i].id;
|
gf.language = GlobalConstants::LANGUAGES[i].id;
|
||||||
gf.platform = patches[j].platform;
|
gf.platform = patches[j].platform;
|
||||||
@ -480,13 +485,16 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int
|
|||||||
}
|
}
|
||||||
else // Patch is a single file
|
else // Patch is a single file
|
||||||
{
|
{
|
||||||
|
std::string path = patchnode["link"].asString();
|
||||||
|
path = (std::string)curl_easy_unescape(curlhandle, path.c_str(), path.size(), NULL);
|
||||||
|
|
||||||
// Check for duplicate patches in different languages and add languageId of duplicate patch to the original patch
|
// Check for duplicate patches in different languages and add languageId of duplicate patch to the original patch
|
||||||
if (useDuplicateHandler)
|
if (useDuplicateHandler)
|
||||||
{
|
{
|
||||||
bool bDuplicate = false;
|
bool bDuplicate = false;
|
||||||
for (unsigned int k = 0; k < game.patches.size(); ++k)
|
for (unsigned int k = 0; k < game.patches.size(); ++k)
|
||||||
{
|
{
|
||||||
if (game.patches[k].path == patchnode["link"].asString())
|
if (game.patches[k].path == path)
|
||||||
{
|
{
|
||||||
game.patches[k].language |= GlobalConstants::LANGUAGES[i].id; // Add language code to patch
|
game.patches[k].language |= GlobalConstants::LANGUAGES[i].id; // Add language code to patch
|
||||||
bDuplicate = true;
|
bDuplicate = true;
|
||||||
@ -503,7 +511,7 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int
|
|||||||
gf.updated = patchnode["notificated"].isInt() ? patchnode["notificated"].asInt() : std::stoi(patchnode["notificated"].asString());
|
gf.updated = patchnode["notificated"].isInt() ? patchnode["notificated"].asInt() : std::stoi(patchnode["notificated"].asString());
|
||||||
gf.id = patchnode["id"].isInt() ? std::to_string(patchnode["id"].asInt()) : patchnode["id"].asString();
|
gf.id = patchnode["id"].isInt() ? std::to_string(patchnode["id"].asInt()) : patchnode["id"].asString();
|
||||||
gf.name = patchnode["name"].asString();
|
gf.name = patchnode["name"].asString();
|
||||||
gf.path = patchnode["link"].asString();
|
gf.path = path;
|
||||||
gf.size = patchnode["size"].asString();
|
gf.size = patchnode["size"].asString();
|
||||||
gf.language = GlobalConstants::LANGUAGES[i].id;
|
gf.language = GlobalConstants::LANGUAGES[i].id;
|
||||||
gf.platform = patches[j].platform;
|
gf.platform = patches[j].platform;
|
||||||
@ -542,6 +550,7 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int
|
|||||||
gf.id = langpack["id"].isInt() ? std::to_string(langpack["id"].asInt()) : langpack["id"].asString();
|
gf.id = langpack["id"].isInt() ? std::to_string(langpack["id"].asInt()) : langpack["id"].asString();
|
||||||
gf.name = langpack["name"].asString();
|
gf.name = langpack["name"].asString();
|
||||||
gf.path = langpack["link"].asString();
|
gf.path = langpack["link"].asString();
|
||||||
|
gf.path = (std::string)curl_easy_unescape(curlhandle, gf.path.c_str(), gf.path.size(), NULL);
|
||||||
gf.size = langpack["size"].asString();
|
gf.size = langpack["size"].asString();
|
||||||
gf.language = GlobalConstants::LANGUAGES[i].id;
|
gf.language = GlobalConstants::LANGUAGES[i].id;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user