From d13a6aaa7c4eb3d79c0997de56410d754513d261 Mon Sep 17 00:00:00 2001 From: yangqiang3504 <412594121@qq.com> Date: Mon, 5 Sep 2022 16:24:32 +0800 Subject: [PATCH] add - Upyso88888 --- .../com/github/catvod/parser/Base64Utils.java | 2 +- .../com/github/catvod/spider/Upyunso.java | 28 ++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/github/catvod/parser/Base64Utils.java b/app/src/main/java/com/github/catvod/parser/Base64Utils.java index 7a1f162..136657c 100644 --- a/app/src/main/java/com/github/catvod/parser/Base64Utils.java +++ b/app/src/main/java/com/github/catvod/parser/Base64Utils.java @@ -16,7 +16,7 @@ import org.json.JSONObject; public class Base64Utils { public static JSONArray getJSONByUrl(String url){ - JSONArray a2 = null; + JSONArray a2 = new JSONArray(); try { String json = OkHttpUtil.string(url, Misc.Headers(1,url)); String s = getBase64(json),title="",uri="",atime="",zt=""; diff --git a/app/src/main/java/com/github/catvod/spider/Upyunso.java b/app/src/main/java/com/github/catvod/spider/Upyunso.java index adb21de..6b8d576 100644 --- a/app/src/main/java/com/github/catvod/spider/Upyunso.java +++ b/app/src/main/java/com/github/catvod/spider/Upyunso.java @@ -45,20 +45,22 @@ public class Upyunso extends Spider { try { JSONArray jSONArray = new JSONArray(); JSONArray arr = Base64Utils.getJSONByUrl("https://api.upyunso.com/search?keyword=" + key); - String pic = "http://image.xinjun58.com/image/tv/ups.jpg"; - for (int i = 0; i < arr.length(); i++) { - JSONObject v = arr.getJSONObject(i); - String id = v.getString("url"); - String title = v.getString("title"); - v.put("vod_id", id + "$$$" + pic + "$$$" + title); - v.put("vod_name", title); - v.put("remark", ""); - v.put("vod_pic", pic); - jSONArray.put(v); + if (arr.length() > 0) { + String pic = "http://image.xinjun58.com/image/tv/ups.jpg"; + for (int i = 0; i < arr.length(); i++) { + JSONObject v = arr.getJSONObject(i); + String id = v.getString("url"); + String title = v.getString("title"); + v.put("vod_id", id + "$$$" + pic + "$$$" + title); + v.put("vod_name", title); + v.put("remark", ""); + v.put("vod_pic", pic); + jSONArray.put(v); + } + JSONObject jSONObject2 = new JSONObject(); + jSONObject2.put("list", jSONArray); + return jSONObject2.toString(); } - JSONObject jSONObject2 = new JSONObject(); - jSONObject2.put("list", jSONArray); - return jSONObject2.toString(); } catch (Exception e) { e.printStackTrace(); }