From 3388b9cac6437855821e7f90c44005e4e6651b8e Mon Sep 17 00:00:00 2001 From: yangqiang3504 <412594121@qq.com> Date: Tue, 6 Sep 2022 09:24:20 +0800 Subject: [PATCH] =?UTF-8?q?add=20-=20=E8=AF=A6=E6=83=85=E9=A1=B5=E6=92=AD?= =?UTF-8?q?=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/github/catvod/parser/Base64Utils.java | 2 +- .../com/github/catvod/spider/PushAgent.java | 12 +++++-- .../com/github/catvod/spider/PushAgentQQ.java | 36 +++++++------------ .../com/github/catvod/spider/Upyunso.java | 14 ++++---- .../com/github/catvod/spider/XBiubiu.java | 9 ++--- .../java/com/github/catvod/utils/Misc.java | 2 +- 6 files changed, 33 insertions(+), 42 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 bacb223..9028727 100644 --- a/app/src/main/java/com/github/catvod/parser/Base64Utils.java +++ b/app/src/main/java/com/github/catvod/parser/Base64Utils.java @@ -46,7 +46,7 @@ public class Base64Utils { uri = o.optString("page_url", ""); o2.put("title", title); - o2.put("url", uri); + o2.put("url", "upyunso.com/"+uri); a2.put(o2); } } diff --git a/app/src/main/java/com/github/catvod/spider/PushAgent.java b/app/src/main/java/com/github/catvod/spider/PushAgent.java index 3ee35c0..8ff4e70 100644 --- a/app/src/main/java/com/github/catvod/spider/PushAgent.java +++ b/app/src/main/java/com/github/catvod/spider/PushAgent.java @@ -41,11 +41,15 @@ public class PushAgent extends Spider { public static Pattern Folder = Pattern.compile("www.aliyundrive.com/s/([^/]+)(/folder/([^/]+))?"); public static String Token="http://catvod.fun:8001/tv/ali.txt"; public static JSONObject siteRule = null; - public static String jsonUrl = "http://test.xinjun58.com/sp/d.json"; @Override public void init(Context context, String extend) { super.init(context, extend); + if (extend != null && !extend.equals("")) { + if (extend.startsWith("http")) { + Misc.jsonUrl = extend; + } + } fetchRule(false,0); } @@ -58,7 +62,7 @@ public class PushAgent extends Spider { public static JSONObject fetchRule(boolean flag,int t) { try { if (flag || siteRule == null) { - String json = OkHttpUtil.string(jsonUrl+"?t="+Time(), null); + String json = OkHttpUtil.string(Misc.jsonUrl+"?t="+Time(), null); JSONObject jo = new JSONObject(json); if(t==0) { String[] fenleis = getRuleVal(jo,"fenlei", "").split("#"); @@ -87,7 +91,7 @@ public class PushAgent extends Spider { return v; } - public String getRuleVal(JSONObject o,String key) { + public static String getRuleVal(JSONObject o,String key) { return getRuleVal(o,key, ""); } @@ -469,6 +473,7 @@ public class PushAgent extends Spider { } String join2 = TextUtils.join("$$$", arrayList3); jSONObject6.put("vod_play_url", join2); + jSONObject6.put("vod_area", type + Token); JSONObject result = new JSONObject(); JSONArray jSONArray2 = new JSONArray(); jSONArray2.put(jSONObject6); @@ -490,6 +495,7 @@ public class PushAgent extends Spider { String url = list.get(0).trim(); String[] idInfo = url.split("\\$\\$\\$"); if (idInfo.length > 0) url = idInfo[0].trim(); + url = Upyunso.getRealUrl(url); String pic = null; if (idInfo.length>1&&!idInfo[1].equals("")) { pic = idInfo[1].trim(); diff --git a/app/src/main/java/com/github/catvod/spider/PushAgentQQ.java b/app/src/main/java/com/github/catvod/spider/PushAgentQQ.java index 1402331..e222aa6 100644 --- a/app/src/main/java/com/github/catvod/spider/PushAgentQQ.java +++ b/app/src/main/java/com/github/catvod/spider/PushAgentQQ.java @@ -13,25 +13,15 @@ import java.util.HashMap; import java.util.List; public class PushAgentQQ extends Spider { - private PushAgent pushAgent; - private static String j = ""; - private static final long n = 0; - protected String ext = null; protected JSONObject rule = null; @Override public void init(Context context, String extend) { super.init(context, extend); - pushAgent = new PushAgent(); - if (extend != null) { - if (!extend.startsWith("http")) { - String[] arr = extend.split(";"); - this.ext = arr[1]; - pushAgent.jsonUrl = arr[1]; - }else { - this.ext = extend; + if (extend != null && !extend.equals("")) { + if (extend.startsWith("http")) { + Misc.jsonUrl = extend; } } - pushAgent.init(context, extend); } @Override @@ -40,7 +30,7 @@ public class PushAgentQQ extends Spider { fetchRule(true); JSONObject result = new JSONObject(); JSONArray classes = new JSONArray(); - String[] fenleis = pushAgent.getRuleVal(rule,"fenlei", "").split("#"); + String[] fenleis = PushAgent.getRuleVal(rule,"fenlei", "").split("#"); for (String fenlei : fenleis) { String[] info = fenlei.split("\\$"); JSONObject jsonObject = new JSONObject(); @@ -57,15 +47,15 @@ public class PushAgentQQ extends Spider { return ""; } protected JSONObject fetchRule(boolean flag) { - rule = pushAgent.fetchRule(flag, 0); + rule = PushAgent.fetchRule(flag, 0); return rule; } @Override public String homeVideoContent() { try { - JSONObject jo = pushAgent.fetchRule(true,1); + JSONObject jo = PushAgent.fetchRule(true,1); JSONArray videos = new JSONArray(); - String[] fenleis = pushAgent.getRuleVal(jo, "fenlei", "").split("#"); + String[] fenleis = PushAgent.getRuleVal(jo, "fenlei", "").split("#"); for (String fenlei : fenleis) { String[] info = fenlei.split("\\$"); JSONObject data = category(info[1], "1", false, new HashMap<>(),jo); @@ -91,16 +81,16 @@ public class PushAgentQQ extends Spider { private JSONObject category(String tid, String pg, boolean filter, HashMap extend,JSONObject jo) { try { - if (jo == null) jo = pushAgent.fetchRule(true,1); + if (jo == null) jo = PushAgent.fetchRule(true,1); JSONArray videos = new JSONArray(); JSONArray array = jo.getJSONArray(tid); JSONObject jsonObject = null, v = null; String url=null,name=null,pic=null; for (int i = 0; i < array.length(); i++) { jsonObject = array.getJSONObject(i); - url = pushAgent.getRuleVal(jsonObject, "url"); - name = pushAgent.getRuleVal(jsonObject, "name"); - pic = pushAgent.getRuleVal(jsonObject, "pic"); + url = PushAgent.getRuleVal(jsonObject, "url"); + name = PushAgent.getRuleVal(jsonObject, "name"); + pic = PushAgent.getRuleVal(jsonObject, "pic"); if(pic.equals("")) pic = Misc.getWebName(url, 1); v = new JSONObject(); v.put("vod_id", url + "$$$" + pic + "$$$" + name); @@ -134,13 +124,13 @@ public class PushAgentQQ extends Spider { @Override public String detailContent(List list) { - return pushAgent.detailContent(list); + return PushAgent.getDetail(list); } @Override public String playerContent(String str, String str2, List list) { - return pushAgent.playerContent(str, str2, list); + return PushAgent.player(str, str2, list); } @Override 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 d296749..171f9aa 100644 --- a/app/src/main/java/com/github/catvod/spider/Upyunso.java +++ b/app/src/main/java/com/github/catvod/spider/Upyunso.java @@ -21,13 +21,6 @@ public class Upyunso extends Spider { @Override public String detailContent(List list) { try { - String id = list.get(0); - String[] idInfo = id.split("\\$\\$\\$"); - String url = idInfo[0]; - String pic = idInfo[1]; - String title = idInfo[2]; - url = Base64Utils.sendGet(url); - list.set(0, url + "$$$" + pic + "$$$" + title); return PushAgent.getDetail(list); } catch (Exception e) { e.printStackTrace(); @@ -35,6 +28,13 @@ public class Upyunso extends Spider { } } + public static String getRealUrl(String url){ + if (url.contains("upyunso.com/download")) { + url = Base64Utils.sendGet(url); + } + return url; + } + @Override public String playerContent(String str, String str2, List list) { return PushAgent.player(str, str2, list); diff --git a/app/src/main/java/com/github/catvod/spider/XBiubiu.java b/app/src/main/java/com/github/catvod/spider/XBiubiu.java index 8f057fe..1cc177d 100644 --- a/app/src/main/java/com/github/catvod/spider/XBiubiu.java +++ b/app/src/main/java/com/github/catvod/spider/XBiubiu.java @@ -23,15 +23,12 @@ import okhttp3.Call; import org.jsoup.Jsoup; public class XBiubiu extends Spider { - private static PushAgent pushAgent= null; @Override public void init(Context context) { super.init(context); } public void init(Context context, String extend) { - pushAgent= new PushAgent(); - pushAgent.init(context, ""); super.init(context, extend); this.ext = extend; } @@ -61,9 +58,7 @@ public class XBiubiu extends Spider { protected HashMap getHeaders(String url) { HashMap headers = new HashMap<>(); - String ua = getRuleVal("UserW", Misc.UaWinChrome).trim(); - if (ua.isEmpty()) - ua = Misc.UaWinChrome; + String ua = getRuleVal("ua", Misc.UaWinChrome).trim(); headers.put("User-Agent", ua); return headers; } @@ -309,7 +304,7 @@ public class XBiubiu extends Spider { list.put(vod); result.put("list", list); return result.toString(); - } else return pushAgent.detailContent(ids); + } else return PushAgent.getDetail(ids); } catch (Exception e) { SpiderDebug.log(e); } diff --git a/app/src/main/java/com/github/catvod/utils/Misc.java b/app/src/main/java/com/github/catvod/utils/Misc.java index 4d2731f..70bcfde 100644 --- a/app/src/main/java/com/github/catvod/utils/Misc.java +++ b/app/src/main/java/com/github/catvod/utils/Misc.java @@ -15,7 +15,7 @@ public class Misc { public static final String UaWinChrome = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"; public static final String DeAgent = "Dalvik/2.1.0 (Linux; U; Android " + Build.VERSION.RELEASE + "; " + Build.MODEL + " Build/" + Build.ID + ")"; public static final String MoAgent = "Mozilla/5.0 (Linux; Android 11; Ghxi Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/76.0.3809.89 Mobile Safari/537.36 T7/12.16 SearchCraft/3.9.1 (Baidu; P1 11)"; - + public static String jsonUrl = "http://test.xinjun58.com/sp/d.json"; public static boolean isVip(String url) { // 适配2.0.6的调用应用内解析列表的支持, 需要配合直连分析一起使用,参考cjt影视和极品直连 try {