From 553c6dce1c8f6e555e8fa1e4cee9ed3a18f8d2cc Mon Sep 17 00:00:00 2001 From: Sude Date: Mon, 12 Feb 2018 19:03:56 +0200 Subject: [PATCH] Galaxy: Add support for generation 1 builds to --galaxy-show-builds --- include/galaxyapi.h | 1 + src/downloader.cpp | 23 ++++++++++++++++------- src/galaxyapi.cpp | 8 +++++++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/include/galaxyapi.h b/include/galaxyapi.h index 465039e..960f6a7 100644 --- a/include/galaxyapi.h +++ b/include/galaxyapi.h @@ -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); diff --git a/src/downloader.cpp b/src/downloader.cpp index 08ff7f0..1a0eba5 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -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::string link = json["items"][build_index]["link"].asString(); + + if (json["items"][build_index]["generation"].asInt() == 1) { - std::cout << "Only generation 2 builds are supported currently" << std::endl; + 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::string link = json["items"][build_index]["link"].asString(); - std::string buildHash; - buildHash.assign(link.begin()+link.find_last_of("/")+1, link.end()); - json = gogGalaxy->getManifestV2(buildHash); - std::cout << json << std::endl; + + return; } std::vector Downloader::galaxyGetOrphanedFiles(const std::vector& items, const std::string& install_path) diff --git a/src/galaxyapi.cpp b/src/galaxyapi.cpp index 5d9eb8d..56edb82 100644 --- a/src/galaxyapi.cpp +++ b/src/galaxyapi.cpp @@ -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;