1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2025-01-01 12:16:02 +00:00

change way to fetch latest release tag

This commit is contained in:
flb 2021-02-26 19:21:49 +01:00
parent 4a76e4e9bf
commit 3db55a410d
6 changed files with 14 additions and 18 deletions

View file

@ -22,7 +22,7 @@ DATA := data
INCLUDES := include lib/zipper/include INCLUDES := include lib/zipper/include
APP_TITLE := All-in-One Switch Updater APP_TITLE := All-in-One Switch Updater
APP_AUTHOR := HamletDuFromage APP_AUTHOR := HamletDuFromage
APP_VERSION := 2.3.4 APP_VERSION := 2.3.5
TARGET := $(notdir $(CURDIR)) TARGET := $(notdir $(CURDIR))
ROMFS := resources ROMFS := resources

View file

@ -10,7 +10,7 @@
#define RCM_PAYLOAD_PATH "romfs:/aio_rcm.bin" #define RCM_PAYLOAD_PATH "romfs:/aio_rcm.bin"
#define APP_URL "https://github.com/HamletDuFromage/aio-switch-updater/releases/latest/download/aio-switch-updater.zip" #define APP_URL "https://github.com/HamletDuFromage/aio-switch-updater/releases/latest/download/aio-switch-updater.zip"
#define TAGS_INFO "https://api.github.com/repos/HamletDuFromage/aio-switch-updater/tags" #define TAGS_INFO "https://api.github.com/repos/HamletDuFromage/aio-switch-updater/releases/latest"
#define APP_FILENAME "/config/aio-switch-updater/app.zip" #define APP_FILENAME "/config/aio-switch-updater/app.zip"
#define SIGPATCHES_URL "https://raw.githubusercontent.com/HamletDuFromage/nx-links/master/sigpatches.json" #define SIGPATCHES_URL "https://raw.githubusercontent.com/HamletDuFromage/nx-links/master/sigpatches.json"

View file

@ -9,4 +9,4 @@ void downloadFile(const char *url, const char *output, int api);
std::vector<std::pair<std::string, std::string>> getLinks(const char *url); std::vector<std::pair<std::string, std::string>> getLinks(const char *url);
std::string fetchTitle(const char *url); std::string fetchTitle(const char *url);
std::string downloadPage(const char* url, std::vector<std::string> headers = {}, std::string body = ""); std::string downloadPage(const char* url, std::vector<std::string> headers = {}, std::string body = "");
nlohmann::json getRequest(std::string url, std::vector<std::string> headers = {}, std::string body = ""); nlohmann::ordered_json getRequest(std::string url, std::vector<std::string> headers = {}, std::string body = "");

View file

@ -10,7 +10,7 @@ bool isServiceRunning(const char *serviceName) {
smUnregisterService(service_name); smUnregisterService(service_name);
return running; return running;
}; }
Result smAtmosphereHasService(bool *out, SmServiceName name) { Result smAtmosphereHasService(bool *out, SmServiceName name) {
u8 tmp = 0; u8 tmp = 0;
@ -31,7 +31,7 @@ CFW getCFW(){
} }
else { // use old method just in case else { // use old method just in case
if(isServiceRunning("rnx")) return rnx; if(isServiceRunning("rnx")) return rnx;
else if(isServiceRunning("tx")) return sxos; if(isServiceRunning("tx")) return sxos;
} }
return ams; return ams;
}; }

View file

@ -198,12 +198,12 @@ std::string downloadPage(const char* url, std::vector<std::string> headers, std:
return res; return res;
} }
json getRequest(std::string url, std::vector<std::string> headers, std::string body) { nlohmann::ordered_json getRequest(std::string url, std::vector<std::string> headers, std::string body) {
std::string request; std::string request;
request = downloadPage(url.c_str(), headers, body); request = downloadPage(url.c_str(), headers, body);
if(json::accept(request)) return json::parse(request); if(json::accept(request)) return nlohmann::ordered_json::parse(request);
else return json::object(); else return nlohmann::ordered_json::object();
} }
std::vector<std::pair<std::string, std::string>> getLinks(const char *url) { std::vector<std::pair<std::string, std::string>> getLinks(const char *url) {

View file

@ -263,15 +263,11 @@ void shut_down(bool reboot){
} }
std::string getLatestTag(const char *url){ std::string getLatestTag(const char *url){
std::string page = downloadPage(url); nlohmann::json tag = getRequest(url, {"accept: application/vnd.github.v3+json"});
try{ if(tag.find("tag_name") != tag.end())
nlohmann::json tags = nlohmann::json::parse(page); return tag["tag_name"];
nlohmann::json:: iterator latest = tags.begin(); else
return latest.value()["name"];
}
catch (...){
return ""; return "";
}
} }
void cp(const char *from, const char *to){ void cp(const char *from, const char *to){