0
0
mirror of https://github.com/TrianguloY/UrlChecker.git synced 2024-09-19 20:02:16 +02:00

fix usage_count not always present

from #226
This commit is contained in:
TrianguloY 2023-05-13 16:41:02 +02:00
parent 0a707ac95a
commit 010b3b8910

View File

@ -110,7 +110,7 @@ class UnshortenDialog extends AModuleDialog {
// get response
var response = new JSONObject(StreamUtils.readFromUrl("https://unshorten.me/json/" + getUrl()));
var resolved_url = response.getString("resolved_url");
var usage_count = Integer.parseInt(response.getString("usage_count"));
var usage_count = Integer.parseInt(response.optString("usage_count", "0"));
var ref = new Object() { // reference object to allow using these inside lambdas
int usage_limit = 10; // documented but hardcoded
int remaining_calls = usage_limit - usage_count;