1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2024-12-29 10:56:01 +00:00

handle quota exceeded for cheatslips

This commit is contained in:
flb 2021-02-06 19:42:14 +01:00
parent f216393487
commit 4e02841839
5 changed files with 61 additions and 36 deletions

View file

@ -5,12 +5,8 @@
![GitHub](https://img.shields.io/github/license/HamletDuFromage/aio-switch-updater)
[![btc](https://img.shields.io/badge/BTC-1CoFc1bY5AHLP6Noe1zmqnJnp7ZWBxyo79-yellow)](https://github.com/HamletDuFromage/aio-switch-updater#like-the-app)
[![eth](https://img.shields.io/badge/ETH-0xf68f568e21a15934e0e9a6949288c3ca009140ba-purple)](https://github.com/HamletDuFromage/aio-switch-updater#like-the-app)
[![eth](https://img.shields.io/badge/LINK-0xf68f568e21a15934e0e9a6949288c3ca009140ba-lightblue
)](https://github.com/HamletDuFromage/aio-switch-updater#like-the-app)
[//]: ([![ko-fi](https://img.shields.io/badge/ko--fi-buy%20me%20a%20coffee-ff69b4)](https://ko-fi.com/hamletdufromage))

View file

@ -14,6 +14,7 @@ class ListDownloadTab : public brls::List
brls::ListItem *cheatslipsItem;
brls::Label *notFound;
brls::Label *description;
brls::Label *cheatSlipLabel;
public:
ListDownloadTab(archiveType type);
~ListDownloadTab();

View file

@ -77,9 +77,11 @@
"cheat_All_done": "All done!",
"get_cheatslips": "Download CheatSlips.com cheat sheets",
"cheatslips_label": "\uE016 Log into CheatSlips.com and download cheat sheets for your games.",
"download_cheatslips": "Download a selection of cheat sheets from CheatSlips.com.\nThose cheat codes will be added to the end of your existing cheat file.",
"delete_cheat": "Delete existing cheat file",
"couldnt_dl_cheats": "Could not fetch selected cheat codes/invalid token.\nYou may have reached your daily download quota. Head on to 'https://www.cheatslips.com/subscriptions' to see increase it.\n",
"couldnt_dl_cheats": "Could not fetch selected cheat codes/invalid token.",
"quota_cheatslips": "Quota exceeded for today!\nHead on to 'https://www.cheatslips.com/subscriptions' to see increase it.",
"cheat_cheat_content": "Cheatsheet content: ",
"app_cheatslips_label": "Select a game to download cheats for.",
"/wrong_cheatslips_id": "Couldn't retrieve token, make you enter you login properly",

View file

@ -56,6 +56,7 @@ DownloadCheatsPage::DownloadCheatsPage(uint64_t tid) : AppletFrame(true, true)
ids.push_back(e.second);
}
}
int error = 0;
if(!ids.empty()) {
json token;
std::ifstream tokenFile(TOKEN_PATH);
@ -69,12 +70,29 @@ DownloadCheatsPage::DownloadCheatsPage(uint64_t tid) : AppletFrame(true, true)
if(cheatsInfo.find("cheats") != cheatsInfo.end()) {
for (const auto& p : cheatsInfo["cheats"].items()) {
if(std::find(ids.begin(), ids.end(), p.value()["id"]) != ids.end()) {
WriteCheats(tid, bid, p.value()["content"]);
if(p.value()["content"].get<std::string>() == "Quota exceeded for today !"){
error = 1;
}
else {
WriteCheats(tid, bid, p.value()["content"]);
}
}
}
}
else {
brls::Dialog* dialog = new brls::Dialog("menus/couldnt_dl_cheats"_i18n);
error = 2;
}
if(error != 0){
brls::Dialog* dialog;
switch(error){
case 1:
dialog = new brls::Dialog("menus/quota_cheatslips"_i18n);
break;
case 2:
dialog = new brls::Dialog("menus/couldnt_dl_cheats"_i18n);
break;
}
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
@ -83,7 +101,7 @@ DownloadCheatsPage::DownloadCheatsPage(uint64_t tid) : AppletFrame(true, true)
dialog->open();
}
}
brls::Application::popView();
if(error == 0) brls::Application::popView();
return true;
});

View file

@ -65,7 +65,43 @@ ListDownloadTab::ListDownloadTab(archiveType type) :
}
this->addView(description);
int nbLinks = std::get<0>(links).size();
if(nbLinks){
for (int i = 0; i<nbLinks; i++){
std::string url = std::get<1>(links)[i];
std::string text("menus/list_down"_i18n + std::get<0>(links)[i] + "menus/list_from"_i18n + url);
listItem = new brls::ListItem(std::get<0>(links)[i]);
listItem->setHeight(LISTITEM_HEIGHT);
listItem->getClickEvent()->subscribe([&, text, url, type, operation](brls::View* view) {
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->setTitle(operation);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, text)
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "menus/list_downing"_i18n , [url, type](){downloadArchive(url, type);})
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "menus/list_extracting"_i18n , [type](){extractArchive(type);})
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "menus/list_All"_i18n , true)
);
brls::Application::pushView(stagedFrame);
});
this->addView(listItem);
}
}
if(type == cheats){
cheatSlipLabel = new brls::Label(
brls::LabelStyle::DESCRIPTION,
"menus/cheatslips_label"_i18n ,
true
);
this->addView(cheatSlipLabel);
cheatslipsItem = new brls::ListItem("menus/get_cheatslips"_i18n);
cheatslipsItem->setHeight(LISTITEM_HEIGHT);
cheatslipsItem->getClickEvent()->subscribe([&](brls::View* view) {
@ -122,34 +158,6 @@ ListDownloadTab::ListDownloadTab(archiveType type) :
this->addView(cheatslipsItem);
}
int nbLinks = std::get<0>(links).size();
if(nbLinks){
for (int i = 0; i<nbLinks; i++){
std::string url = std::get<1>(links)[i];
std::string text("menus/list_down"_i18n + std::get<0>(links)[i] + "menus/list_from"_i18n + url);
listItem = new brls::ListItem(std::get<0>(links)[i]);
listItem->setHeight(LISTITEM_HEIGHT);
listItem->getClickEvent()->subscribe([&, text, url, type, operation](brls::View* view) {
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->setTitle(operation);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, text)
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "menus/list_downing"_i18n , [url, type](){downloadArchive(url, type);})
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "menus/list_extracting"_i18n , [type](){extractArchive(type);})
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "menus/list_All"_i18n , true)
);
brls::Application::pushView(stagedFrame);
});
this->addView(listItem);
}
}
else{
notFound = new brls::Label(
brls::LabelStyle::DESCRIPTION,