diff --git a/app/src/main/java/com/github/catvod/spider/Bili.java b/app/src/main/java/com/github/catvod/spider/Bili.java index b4c9358c..6acc6de7 100644 --- a/app/src/main/java/com/github/catvod/spider/Bili.java +++ b/app/src/main/java/com/github/catvod/spider/Bili.java @@ -33,7 +33,7 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; /** - * @author ColaMint & FongMi + * @author ColaMint & FongMi & 唐三 */ public class Bili extends Spider { @@ -47,11 +47,8 @@ public class Bili extends Spider { private String getCookie() { String cache = Prefers.getString("BiliCookie"); if (!TextUtils.isEmpty(cache)) return cache; - if (!ext.optString("cookie").isEmpty()) { - if (ext.optString("cookie").startsWith("http")) return OkHttp.string(ext.optString("cookie")).replace("\n", "").trim(); - return ext.optString("cookie"); - } - return "buvid3=84B0395D-C9F2-C490-E92E-A09AB48FE26E71636infoc"; + if (ext.optString("cookie").startsWith("http")) return OkHttp.string(ext.optString("cookie")).replace("\n", "").trim(); + return ext.optString("cookie", "buvid3=84B0395D-C9F2-C490-E92E-A09AB48FE26E71636infoc"); } private void setHeader() { @@ -60,27 +57,27 @@ public class Bili extends Spider { header.put("User-Agent", Utils.CHROME); } + private void generate() throws Exception { + ext = new JSONObject(); + JSONArray classes = new JSONArray(); + JSONObject filters = new JSONObject(); + ext.put("classes", classes); + ext.put("filter", filters); + JSONArray filter = new JSONArray("[{\"key\":\"order\",\"name\":\"排序\",\"value\":[{\"n\":\"综合排序\",\"v\":\"0\"},{\"n\":\"最多点击\",\"v\":\"click\"},{\"n\":\"最新发布\",\"v\":\"pubdate\"},{\"n\":\"最多弹幕\",\"v\":\"dm\"},{\"n\":\"最多收藏\",\"v\":\"stow\"}]},{\"key\":\"duration\",\"name\":\"时长\",\"value\":[{\"n\":\"全部时长\",\"v\":\"0\"},{\"n\":\"60分钟以上\",\"v\":\"4\"},{\"n\":\"30~60分钟\",\"v\":\"3\"},{\"n\":\"10~30分钟\",\"v\":\"2\"},{\"n\":\"10分钟以下\",\"v\":\"1\"}]}]"); + String[] types = extend.split("#"); + for (String type : types) { + JSONObject c = new JSONObject(); + c.put("type_name", type); + c.put("type_id", type); + filters.put(type, filter); + classes.put(c); + } + } + private void fetchRule() throws Exception { if (header.containsKey("cookie") && header.get("cookie").length() > 0) return; - if (extend.startsWith("http")) { - extend = OkHttp.string(extend); - ext = new JSONObject(extend); - } else { - JSONArray newFilter = new JSONArray("[{\"key\":\"order\",\"name\":\"排序\",\"value\":[{\"n\":\"综合排序\",\"v\":\"0\"},{\"n\":\"最多点击\",\"v\":\"click\"},{\"n\":\"最新发布\",\"v\":\"pubdate\"},{\"n\":\"最多弹幕\",\"v\":\"dm\"},{\"n\":\"最多收藏\",\"v\":\"stow\"}]},{\"key\":\"duration\",\"name\":\"时长\",\"value\":[{\"n\":\"全部时长\",\"v\":\"0\"},{\"n\":\"60分钟以上\",\"v\":\"4\"},{\"n\":\"30~60分钟\",\"v\":\"3\"},{\"n\":\"10~30分钟\",\"v\":\"2\"},{\"n\":\"10分钟以下\",\"v\":\"1\"}]}]"); - String[] typeC = extend.split("#"); - JSONArray classes = new JSONArray(); - JSONObject filters = new JSONObject(); - for (String kk : typeC) { - JSONObject c = new JSONObject(); - c.put("type_name", kk); - c.put("type_id", kk); - classes.put(c); - filters.put(kk, newFilter); - } - ext = new JSONObject(); - ext.put("classes", classes); - ext.put("filter", filters); - } + if (extend.startsWith("http")) ext = new JSONObject(extend = OkHttp.string(extend)); + else generate(); setHeader(); } diff --git a/jar/custom_spider.jar b/jar/custom_spider.jar index 3baa4274..69620b75 100644 Binary files a/jar/custom_spider.jar and b/jar/custom_spider.jar differ diff --git a/jar/custom_spider.jar.md5 b/jar/custom_spider.jar.md5 index 67a4d674..1c3d32bc 100644 --- a/jar/custom_spider.jar.md5 +++ b/jar/custom_spider.jar.md5 @@ -1 +1 @@ -af37ed94ebfb6af49a33d48a6fe005da +c57209d88a3ae109cfdb505aa864302c