Galaxy: Add support for generation 1 builds to --galaxy-show-builds

This commit is contained in:
Sude 2018-02-12 19:03:56 +02:00
parent 40cbb5fccb
commit 553c6dce1c
3 changed files with 24 additions and 8 deletions

View File

@ -49,6 +49,7 @@ class galaxyAPI
bool refreshLogin();
Json::Value getProductBuilds(const std::string& product_id, const std::string& platform = "windows", const std::string& generation = "2");
Json::Value getManifestV1(const std::string& product_id, const std::string& build_id, const std::string& manifest_id = "repository", const std::string& platform = "windows");
Json::Value getManifestV1(const std::string& manifest_url);
Json::Value getManifestV2(std::string manifest_hash);
Json::Value getSecureLink(const std::string& product_id, const std::string& path);
std::string getResponse(const std::string& url, const bool& zlib_decompress = false);

View File

@ -3809,18 +3809,27 @@ void Downloader::galaxyShowBuilds(const std::string& product_id, int build_index
return;
}
if (json["items"][build_index]["generation"].asInt() != 2)
{
std::cout << "Only generation 2 builds are supported currently" << std::endl;
return;
}
std::string link = json["items"][build_index]["link"].asString();
if (json["items"][build_index]["generation"].asInt() == 1)
{
json = gogGalaxy->getManifestV1(link);
}
else if (json["items"][build_index]["generation"].asInt() == 2)
{
std::string buildHash;
buildHash.assign(link.begin()+link.find_last_of("/")+1, link.end());
json = gogGalaxy->getManifestV2(buildHash);
}
else
{
std::cout << "Only generation 1 and 2 builds are supported currently" << std::endl;
return;
}
std::cout << json << std::endl;
return;
}
std::vector<std::string> Downloader::galaxyGetOrphanedFiles(const std::vector<galaxyDepotItem>& items, const std::string& install_path)

View File

@ -157,7 +157,13 @@ Json::Value galaxyAPI::getProductBuilds(const std::string& product_id, const std
Json::Value galaxyAPI::getManifestV1(const std::string& product_id, const std::string& build_id, const std::string& manifest_id, const std::string& platform)
{
std::string url = "https://cdn.gog.com/content-system/v1/manifests/" + product_id + "/" + platform + "/" + build_id + "/" + manifest_id + ".json";
std::istringstream response(this->getResponse(url));
return this->getManifestV1(url);
}
Json::Value galaxyAPI::getManifestV1(const std::string& manifest_url)
{
std::istringstream response(this->getResponse(manifest_url));
Json::Value json;
response >> json;