1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2024-12-29 10:56:01 +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
APP_TITLE := All-in-One Switch Updater
APP_AUTHOR := HamletDuFromage
APP_VERSION := 2.3.4
APP_VERSION := 2.3.5
TARGET := $(notdir $(CURDIR))
ROMFS := resources

View file

@ -10,7 +10,7 @@
#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 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 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::string fetchTitle(const char *url);
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);
return running;
};
}
Result smAtmosphereHasService(bool *out, SmServiceName name) {
u8 tmp = 0;
@ -31,7 +31,7 @@ CFW getCFW(){
}
else { // use old method just in case
if(isServiceRunning("rnx")) return rnx;
else if(isServiceRunning("tx")) return sxos;
if(isServiceRunning("tx")) return sxos;
}
return ams;
};
}

View file

@ -198,12 +198,12 @@ std::string downloadPage(const char* url, std::vector<std::string> headers, std:
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;
request = downloadPage(url.c_str(), headers, body);
if(json::accept(request)) return json::parse(request);
else return json::object();
if(json::accept(request)) return nlohmann::ordered_json::parse(request);
else return nlohmann::ordered_json::object();
}
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 page = downloadPage(url);
try{
nlohmann::json tags = nlohmann::json::parse(page);
nlohmann::json:: iterator latest = tags.begin();
return latest.value()["name"];
}
catch (...){
nlohmann::json tag = getRequest(url, {"accept: application/vnd.github.v3+json"});
if(tag.find("tag_name") != tag.end())
return tag["tag_name"];
else
return "";
}
}
void cp(const char *from, const char *to){