This commit is contained in:
FongMi 2024-02-02 09:55:00 +08:00
parent dbc4c767ad
commit 2205d18819
5 changed files with 13 additions and 3 deletions

View File

@ -85,7 +85,7 @@ public class Bili extends Spider {
@Override
public void init(Context context, String extend) throws Exception {
this.extend = Json.parse(extend).getAsJsonObject();
this.extend = Json.safeObject(extend);
setCookie();
setAudio();
}

View File

@ -42,7 +42,7 @@ public class Wogg extends Ali {
@Override
public void init(Context context, String extend) {
ext = Json.parse(extend).getAsJsonObject();
ext = Json.safeObject(extend);
super.init(context, ext.has("token") ? ext.get("token").getAsString() : "");
}

View File

@ -1,6 +1,7 @@
package com.github.catvod.utils;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class Json {
@ -12,4 +13,13 @@ public class Json {
return new JsonParser().parse(json);
}
}
public static JsonObject safeObject(String json) {
try {
JsonObject obj = parse(json).getAsJsonObject();
return obj == null ? new JsonObject() : obj;
} catch (Throwable e) {
return new JsonObject();
}
}
}

Binary file not shown.

View File

@ -1 +1 @@
73e1be1009c6a267fc30ea51b446e304
4795d43e5d59d58d6d4a92361f73974e