keys = headerJson.keys();
- while (keys.hasNext()) {
- String key = keys.next();
- reqHeaders.put(key, headerJson.optString(key, ""));
- }
- }
- reqHeaders.put("url", newUrl);
- } catch (Throwable th) {
-
- }
- }
- return reqHeaders;
- }
-}
diff --git a/CatVodTVSpider/app/src/main/java/com/github/catvod/parser/JsonParallel.java b/CatVodTVSpider/app/src/main/java/com/github/catvod/parser/JsonParallel.java
deleted file mode 100644
index 0de41a6..0000000
--- a/CatVodTVSpider/app/src/main/java/com/github/catvod/parser/JsonParallel.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package com.github.catvod.parser;
-
-import com.github.catvod.crawler.SpiderDebug;
-import com.github.catvod.utils.Misc;
-import com.github.catvod.utils.okhttp.OkHttpUtil;
-
-import org.json.JSONObject;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CompletionService;
-import java.util.concurrent.ExecutorCompletionService;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
-/**
- * 并发解析,直到获得第一个结果
- *
- * 默认解析超时时间为15秒,如果需要请自定义SpiderReq的HttpClient
- *
- * Author: CatVod
- */
-public class JsonParallel {
- private static final String ParseOKTag = "p_json_parse";
-
- public static JSONObject parse(LinkedHashMap jx, String url) {
- try {
- if (jx.size() > 0) {
- ExecutorService executorService = Executors.newFixedThreadPool(3);
- CompletionService completionService = new ExecutorCompletionService(executorService);
- List> futures = new ArrayList<>();
- Set jxNames = jx.keySet();
- for (String jxName : jxNames) {
- String parseUrl = jx.get(jxName);
- futures.add(completionService.submit(new Callable() {
- @Override
- public JSONObject call() throws Exception {
- try {
- HashMap reqHeaders = JsonBasic.getReqHeader(parseUrl);
- String realUrl = reqHeaders.get("url");
- reqHeaders.remove("url");
- SpiderDebug.log(realUrl + url);
- String json = OkHttpUtil.string(realUrl + url, ParseOKTag, reqHeaders);
- JSONObject taskResult = Misc.jsonParse(url, json);
- taskResult.put("jxFrom", jxName);
- SpiderDebug.log(taskResult.toString());
- return taskResult;
- } catch (Throwable th) {
- SpiderDebug.log(th);
- return null;
- }
- }
- }));
- }
- JSONObject pTaskResult = null;
- for (int i = 0; i < futures.size(); ++i) {
- Future completed = completionService.take();
- try {
- pTaskResult = completed.get();
- if (pTaskResult != null) {
- OkHttpUtil.cancel(ParseOKTag);
- for (int j = 0; j < futures.size(); j++) {
- try {
- futures.get(j).cancel(true);
- } catch (Throwable th) {
- SpiderDebug.log(th);
- }
- }
- futures.clear();
- break;
- }
- } catch (Throwable th) {
- SpiderDebug.log(th);
- }
- }
- try {
- executorService.shutdownNow();
- } catch (Throwable th) {
- SpiderDebug.log(th);
- }
- if (pTaskResult != null)
- return pTaskResult;
- }
- } catch (Throwable th) {
- SpiderDebug.log(th);
- }
- return new JSONObject();
- }
-}
diff --git a/CatVodTVSpider/app/src/main/java/com/github/catvod/parser/JsonSequence.java b/CatVodTVSpider/app/src/main/java/com/github/catvod/parser/JsonSequence.java
deleted file mode 100644
index de78928..0000000
--- a/CatVodTVSpider/app/src/main/java/com/github/catvod/parser/JsonSequence.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.github.catvod.parser;
-
-import com.github.catvod.crawler.SpiderDebug;
-import com.github.catvod.utils.Misc;
-import com.github.catvod.utils.okhttp.OkHttpUtil;
-
-import org.json.JSONObject;
-
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Set;
-
-/**
- * 依次解析,失败尝试下一个
- *
- * 默认解析超时时间为15秒,如果需要请自定义SpiderReq的HttpClient
- *
- * Author: CatVod
- */
-public class JsonSequence {
- public static JSONObject parse(LinkedHashMap jx, String url) {
- try {
- if (jx.size() > 0) {
- Set jxNames = jx.keySet();
- for (String jxName : jxNames) {
- String parseUrl = jx.get(jxName);
- try {
- HashMap reqHeaders = JsonBasic.getReqHeader(parseUrl);
- String realUrl = reqHeaders.get("url");
- reqHeaders.remove("url");
- SpiderDebug.log(realUrl + url);
- String json = OkHttpUtil.string(realUrl + url, reqHeaders);
- JSONObject taskResult = Misc.jsonParse(url, json);
- if (taskResult == null)
- continue;
- taskResult.put("jxFrom", jxName);
- return taskResult;
- } catch (Throwable th) {
- SpiderDebug.log(th);
- }
- }
- }
- } catch (Throwable th) {
- SpiderDebug.log(th);
- }
- return new JSONObject();
- }
-}
diff --git a/CatVodTVSpider/app/src/main/java/com/github/catvod/parser/MixDemo.java b/CatVodTVSpider/app/src/main/java/com/github/catvod/parser/MixDemo.java
deleted file mode 100644
index 921ddaf..0000000
--- a/CatVodTVSpider/app/src/main/java/com/github/catvod/parser/MixDemo.java
+++ /dev/null
@@ -1,189 +0,0 @@
-package com.github.catvod.parser;
-
-import android.util.Base64;
-
-import com.github.catvod.crawler.SpiderDebug;
-
-import org.json.JSONArray;
-import org.json.JSONObject;
-
-import java.io.ByteArrayInputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-
-public class MixDemo {
-
- /*
- "parses": [
- {
- "name": "聚合",
- "type": 3,
- "url": "Demo"
- },
- {
- "name": "解析",
- "type": 1,
- "url": "https://192.168.10.88/jx.php?url=",
- "ext": {
- "flag": [
- "qq",
- "iqiyi",
- "qiyi",
- "爱奇艺",
- "腾讯",
- "letv",
- "sohu",
- "tudou",
- "pptv",
- "mgtv",
- "wasu",
- "bilibili"
- ]
- }
- }]
- */
-
- public static HashMap> flagWebJx = new HashMap<>();
-
- static HashMap> configs = null;
-
- public static JSONObject parse(LinkedHashMap> jx, String nameMe, String flag, String url) {
- try {
- if (configs == null) {
- configs = new HashMap<>();
- Iterator keys = jx.keySet().iterator();
- while (keys.hasNext()) {
- String key = keys.next();
- HashMap parseBean = jx.get(key);
- String type = parseBean.get("type");
- if (type.equals("1") || type.equals("0")) {
- try {
- JSONArray flags = new JSONObject(parseBean.get("ext")).getJSONArray("flag");
- for (int j = 0; j < flags.length(); j++) {
- String flagKey = flags.getString(j);
- ArrayList flagJx = configs.get(flagKey);
- if (flagJx == null) {
- flagJx = new ArrayList<>();
- configs.put(flagKey, flagJx);
- }
- flagJx.add(key);
- }
- } catch (Throwable th) {
-
- }
- }
- }
- }
- // 通过上面的配置获得解析列表
- LinkedHashMap jsonJx = new LinkedHashMap<>();
- ArrayList webJx = new ArrayList<>();
- ArrayList flagJx = configs.get(flag);
- if (flagJx != null && !flagJx.isEmpty()) {
- for (int i = 0; i < flagJx.size(); i++) {
- String key = flagJx.get(i);
- HashMap parseBean = jx.get(key);
- String type = parseBean.get("type");
- if (type.equals("1")) {
- jsonJx.put(key, mixUrl(parseBean.get("url"), parseBean.get("ext")));
- } else if (type.equals("0")) {
- webJx.add(parseBean.get("url"));
- }
- }
- } else {
- Iterator keys = jx.keySet().iterator();
- while (keys.hasNext()) {
- String key = keys.next();
- HashMap parseBean = jx.get(key);
- String type = parseBean.get("type");
- if (type.equals("1")) {
- jsonJx.put(key, mixUrl(parseBean.get("url"), parseBean.get("ext")));
- } else if (type.equals("0")) {
- webJx.add(parseBean.get("url"));
- }
- }
- }
- if (!webJx.isEmpty()) {
- flagWebJx.put(flag, webJx);
- }
- // 优先使用json并发解析
- JSONObject jsonResult = JsonParallel.parse(jsonJx, url);
- if (jsonResult != null && jsonResult.has("url")) {
- return jsonResult;
- }
- // json解析没有得到结果 用webview解析
- if (!webJx.isEmpty()) {
- JSONObject webResult = new JSONObject();
- webResult.put("url", "proxy://do=parseMix&flag=" + flag + "&url=" + Base64.encodeToString(url.getBytes(), Base64.DEFAULT | Base64.URL_SAFE | Base64.NO_WRAP));
- webResult.put("parse", 1);
- return webResult;
- }
- } catch (Throwable th) {
- SpiderDebug.log(th);
- }
- return new JSONObject();
- }
-
- private static String mixUrl(String url, String ext) {
- if (ext.trim().length() > 0) {
- int idx = url.indexOf("?");
- if (idx > 0) {
- return url.substring(0, idx + 1) + "cat_ext=" + Base64.encodeToString(ext.getBytes(), Base64.DEFAULT | Base64.URL_SAFE | Base64.NO_WRAP) + "&" + url.substring(idx + 1);
- }
- }
- return url;
- }
-
- public static Object[] loadHtml(String flag, String url) {
- try {
- url = new String(Base64.decode(url, Base64.DEFAULT | Base64.URL_SAFE | Base64.NO_WRAP), "UTF-8");
- String html = "\n" +
- "\n" +
- "\n" +
- "\n" +
- "解析\n" +
- "\n" +
- "\n" +
- "\n" +
- "\n" +
- "\n" +
- "\n" +
- "\n" +
- "\n" +
- "";
-
- StringBuilder jxs = new StringBuilder();
- if (flagWebJx.containsKey(flag)) {
- ArrayList jxUrls = flagWebJx.get(flag);
- for (int i = 0; i < jxUrls.size(); i++) {
- jxs.append("\"");
- jxs.append(jxUrls.get(i));
- jxs.append("\"");
- if (i < jxUrls.size() - 1) {
- jxs.append(",");
- }
- }
- }
- html = html.replace("#url#", url).replace("#jxs#", jxs.toString());
- Object[] result = new Object[3];
- result[0] = 200;
- result[1] = "text/html; charset=\"UTF-8\"";
- ByteArrayInputStream baos = new ByteArrayInputStream(html.toString().getBytes("UTF-8"));
- result[2] = baos;
- return result;
- } catch (Throwable th) {
- th.printStackTrace();
- }
- return null;
- }
-}
diff --git a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Aidi.java b/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Aidi.java
deleted file mode 100644
index d72c5f8..0000000
--- a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Aidi.java
+++ /dev/null
@@ -1,466 +0,0 @@
-package com.github.catvod.spider;
-
-import android.content.Context;
-import android.text.TextUtils;
-
-import com.github.catvod.crawler.Spider;
-import com.github.catvod.crawler.SpiderDebug;
-import com.github.catvod.utils.okhttp.OkHttpUtil;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
-
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Demo for spider
- *
- * Author: CatVod
- */
-public class Aidi extends Spider {
- private static final String siteUrl = "https://aidi.tv";
- private static final String siteHost = "aidi.tv";
-
- /**
- * 播放源配置
- */
- private JSONObject playerConfig;
- /**
- * 筛选配置
- */
- private JSONObject filterConfig;
-
- private Pattern regexCategory = Pattern.compile("/v/(\\w+).html");
- private Pattern regexVid = Pattern.compile("/movie/(\\w+).html");
- private Pattern regexPlay = Pattern.compile("\\S+/play/(\\w+)-(\\d+)-(\\d+).html");
- private Pattern regexPage = Pattern.compile("/show/(\\S+).html");
-
- @Override
- public void init(Context context) {
- super.init(context);
- try {
- playerConfig = new JSONObject("{\"xg_app_player\":{\"sh\":\"app全局解析\",\"pu\":\"\",\"sn\":0,\"or\":999},\"dplayer\":{\"sh\":\"dplayer\",\"pu\":\"\",\"sn\":0,\"or\":999},\"videojs\":{\"sh\":\"videojs-H5播放器\",\"pu\":\"\",\"sn\":0,\"or\":999},\"iva\":{\"sh\":\"iva-H5播放器\",\"pu\":\"\",\"sn\":0,\"or\":999},\"iframe\":{\"sh\":\"iframe外链数据\",\"pu\":\"\",\"sn\":0,\"or\":999},\"link\":{\"sh\":\"外链数据\",\"pu\":\"top.\",\"sn\":0,\"or\":999},\"swf\":{\"sh\":\"Flash文件\",\"pu\":\"\",\"sn\":0,\"or\":999},\"flv\":{\"sh\":\"Flv文件\",\"pu\":\"\",\"sn\":0,\"or\":999},\"qiepian\":{\"sh\":\"爱迪云播\",\"pu\":\"\",\"sn\":0,\"or\":999},\"ckm3u8\":{\"sh\":\"爱迪影视\",\"pu\":\"\",\"sn\":0,\"or\":999},\"xin\":{\"sh\":\"爱迪高速\",\"pu\":\"\",\"sn\":0,\"or\":999},\"ppyun\":{\"sh\":\"爱迪云链\",\"pu\":\"\",\"sn\":0,\"or\":999},\"jisu\":{\"sh\":\"极速路线\",\"pu\":\"\",\"sn\":0,\"or\":999},\"ppayun\":{\"sh\":\"pp云\",\"pu\":\"https://wy.ppayun.cn/api/ShowVideoWy/973ed6d6891c43269706718cb0aedb72/\",\"sn\":0,\"or\":999},\"yun3edu\":{\"sh\":\"爱迪云三\",\"pu\":\"\",\"sn\":0,\"or\":999},\"guoji\":{\"sh\":\"國際路線\",\"pu\":\"\",\"sn\":0,\"or\":999},\"ddyunp\":{\"sh\":\"蓝光线路\",\"pu\":\"\",\"sn\":0,\"or\":999},\"eduyun\":{\"sh\":\"爱迪云二\",\"pu\":\"\",\"sn\":0,\"or\":999},\"dbm3u8\":{\"sh\":\"720P线路\",\"pu\":\"\",\"sn\":0,\"or\":999},\"yjm3u8\":{\"sh\":\"备用线路\",\"pu\":\"\",\"sn\":0,\"or\":999}}");
- filterConfig = new JSONObject("{\"dianying\":[{\"key\":0,\"name\":\"分类\",\"value\":[{\"n\":\"全部\",\"v\":\"dianying\"},{\"n\":\"动作片\",\"v\":\"dongzuopian\"},{\"n\":\"喜剧片\",\"v\":\"xijupian\"},{\"n\":\"爱情片\",\"v\":\"aiqingpian\"},{\"n\":\"科幻片\",\"v\":\"kehuanpian\"},{\"n\":\"恐怖片\",\"v\":\"kongbupian\"},{\"n\":\"剧情片\",\"v\":\"juqingpian\"},{\"n\":\"战争片\",\"v\":\"zhanzhengpian\"},{\"n\":\"传记\",\"v\":\"zhuanji\"}]},{\"key\":3,\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"喜剧\",\"v\":\"喜剧\"},{\"n\":\"爱情\",\"v\":\"爱情\"},{\"n\":\"恐怖\",\"v\":\"恐怖\"},{\"n\":\"动作\",\"v\":\"动作\"},{\"n\":\"科幻\",\"v\":\"科幻\"},{\"n\":\"剧情\",\"v\":\"剧情\"},{\"n\":\"战争\",\"v\":\"战争\"},{\"n\":\"警匪\",\"v\":\"警匪\"},{\"n\":\"犯罪\",\"v\":\"犯罪\"},{\"n\":\"动画\",\"v\":\"动画\"},{\"n\":\"奇幻\",\"v\":\"奇幻\"},{\"n\":\"武侠\",\"v\":\"武侠\"},{\"n\":\"冒险\",\"v\":\"冒险\"},{\"n\":\"枪战\",\"v\":\"枪战\"},{\"n\":\"恐怖\",\"v\":\"恐怖\"},{\"n\":\"悬疑\",\"v\":\"悬疑\"},{\"n\":\"惊悚\",\"v\":\"惊悚\"},{\"n\":\"经典\",\"v\":\"经典\"},{\"n\":\"青春\",\"v\":\"青春\"},{\"n\":\"文艺\",\"v\":\"文艺\"},{\"n\":\"微电影\",\"v\":\"微电影\"},{\"n\":\"古装\",\"v\":\"古装\"},{\"n\":\"历史\",\"v\":\"历史\"},{\"n\":\"运动\",\"v\":\"运动\"},{\"n\":\"农村\",\"v\":\"农村\"},{\"n\":\"儿童\",\"v\":\"儿童\"},{\"n\":\"网络电影\",\"v\":\"网络电影\"},{\"n\":\"情色\",\"v\":\"情色\"}]},{\"key\":1,\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"大陆\",\"v\":\"大陆\"},{\"n\":\"香港\",\"v\":\"香港\"},{\"n\":\"台湾\",\"v\":\"台湾\"},{\"n\":\"美国\",\"v\":\"美国\"},{\"n\":\"法国\",\"v\":\"法国\"},{\"n\":\"英国\",\"v\":\"英国\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"韩国\",\"v\":\"韩国\"},{\"n\":\"德国\",\"v\":\"德国\"},{\"n\":\"泰国\",\"v\":\"泰国\"},{\"n\":\"印度\",\"v\":\"印度\"},{\"n\":\"意大利\",\"v\":\"意大利\"},{\"n\":\"西班牙\",\"v\":\"西班牙\"},{\"n\":\"加拿大\",\"v\":\"加拿大\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":11,\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"}]},{\"key\":4,\"name\":\"语言\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"国语\",\"v\":\"国语\"},{\"n\":\"英语\",\"v\":\"英语\"},{\"n\":\"粤语\",\"v\":\"粤语\"},{\"n\":\"闽南语\",\"v\":\"闽南语\"},{\"n\":\"韩语\",\"v\":\"韩语\"},{\"n\":\"日语\",\"v\":\"日语\"},{\"n\":\"法语\",\"v\":\"法语\"},{\"n\":\"德语\",\"v\":\"德语\"},{\"n\":\"其它\",\"v\":\"其它\"}]},{\"key\":2,\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"time\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"lianxuju\":[{\"key\":0,\"name\":\"分类\",\"value\":[{\"n\":\"全部\",\"v\":\"lianxuju\"},{\"n\":\"国产剧\",\"v\":\"guochanju\"},{\"n\":\"港台剧\",\"v\":\"gangtaiju\"},{\"n\":\"韩剧\",\"v\":\"hanju\"},{\"n\":\"美剧\",\"v\":\"meiju\"},{\"n\":\"日剧\",\"v\":\"riju\"},{\"n\":\"英剧\",\"v\":\"yingju\"},{\"n\":\"泰剧\",\"v\":\"taiju\"}]},{\"key\":3,\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"古装\",\"v\":\"古装\"},{\"n\":\"战争\",\"v\":\"战争\"},{\"n\":\"青春偶像\",\"v\":\"青春偶像\"},{\"n\":\"喜剧\",\"v\":\"喜剧\"},{\"n\":\"家庭\",\"v\":\"家庭\"},{\"n\":\"犯罪\",\"v\":\"犯罪\"},{\"n\":\"动作\",\"v\":\"动作\"},{\"n\":\"奇幻\",\"v\":\"奇幻\"},{\"n\":\"剧情\",\"v\":\"剧情\"},{\"n\":\"历史\",\"v\":\"历史\"},{\"n\":\"经典\",\"v\":\"经典\"},{\"n\":\"乡村\",\"v\":\"乡村\"},{\"n\":\"情景\",\"v\":\"情景\"},{\"n\":\"商战\",\"v\":\"商战\"},{\"n\":\"网剧\",\"v\":\"网剧\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":1,\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"内地\",\"v\":\"内地\"},{\"n\":\"韩国\",\"v\":\"韩国\"},{\"n\":\"香港\",\"v\":\"香港\"},{\"n\":\"台湾\",\"v\":\"台湾\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"美国\",\"v\":\"美国\"},{\"n\":\"泰国\",\"v\":\"泰国\"},{\"n\":\"英国\",\"v\":\"英国\"},{\"n\":\"新加坡\",\"v\":\"新加坡\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":11,\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"}]},{\"key\":4,\"name\":\"语言\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"国语\",\"v\":\"国语\"},{\"n\":\"英语\",\"v\":\"英语\"},{\"n\":\"粤语\",\"v\":\"粤语\"},{\"n\":\"闽南语\",\"v\":\"闽南语\"},{\"n\":\"韩语\",\"v\":\"韩语\"},{\"n\":\"日语\",\"v\":\"日语\"},{\"n\":\"其它\",\"v\":\"其它\"}]},{\"key\":2,\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"time\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"zongyi\":[{\"key\":0,\"name\":\"分类\",\"value\":[{\"n\":\"全部\",\"v\":\"zongyi\"},{\"n\":\"内地综艺\",\"v\":\"ndzy\"},{\"n\":\"港台综艺\",\"v\":\"gtzy\"},{\"n\":\"韩国综艺节目\",\"v\":\"variety\"},{\"n\":\"欧美综艺\",\"v\":\"oumeizongyi\"}]},{\"key\":3,\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"选秀\",\"v\":\"选秀\"},{\"n\":\"情感\",\"v\":\"情感\"},{\"n\":\"访谈\",\"v\":\"访谈\"},{\"n\":\"播报\",\"v\":\"播报\"},{\"n\":\"旅游\",\"v\":\"旅游\"},{\"n\":\"音乐\",\"v\":\"音乐\"},{\"n\":\"美食\",\"v\":\"美食\"},{\"n\":\"纪实\",\"v\":\"纪实\"},{\"n\":\"曲艺\",\"v\":\"曲艺\"},{\"n\":\"生活\",\"v\":\"生活\"},{\"n\":\"游戏互动\",\"v\":\"游戏互动\"},{\"n\":\"财经\",\"v\":\"财经\"},{\"n\":\"求职\",\"v\":\"求职\"}]},{\"key\":1,\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"内地\",\"v\":\"内地\"},{\"n\":\"港台\",\"v\":\"港台\"},{\"n\":\"日韩\",\"v\":\"日韩\"},{\"n\":\"欧美\",\"v\":\"欧美\"}]},{\"key\":11,\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"}]},{\"key\":4,\"name\":\"语言\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"国语\",\"v\":\"国语\"},{\"n\":\"英语\",\"v\":\"英语\"},{\"n\":\"粤语\",\"v\":\"粤语\"},{\"n\":\"闽南语\",\"v\":\"闽南语\"},{\"n\":\"韩语\",\"v\":\"韩语\"},{\"n\":\"日语\",\"v\":\"日语\"},{\"n\":\"其它\",\"v\":\"其它\"}]},{\"key\":2,\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"time\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"dongman\":[{\"key\":0,\"name\":\"分类\",\"value\":[{\"n\":\"全部\",\"v\":\"dongman\"},{\"n\":\"日韩动漫\",\"v\":\"rihan\"},{\"n\":\"国产动漫\",\"v\":\"guoman\"},{\"n\":\"欧美动漫\",\"v\":\"oumei\"},{\"n\":\"动漫电影\",\"v\":\"cartoon\"}]},{\"key\":3,\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"情感\",\"v\":\"情感\"},{\"n\":\"科幻\",\"v\":\"科幻\"},{\"n\":\"热血\",\"v\":\"热血\"},{\"n\":\"推理\",\"v\":\"推理\"},{\"n\":\"搞笑\",\"v\":\"搞笑\"},{\"n\":\"冒险\",\"v\":\"冒险\"},{\"n\":\"萝莉\",\"v\":\"萝莉\"},{\"n\":\"校园\",\"v\":\"校园\"},{\"n\":\"动作\",\"v\":\"动作\"},{\"n\":\"机战\",\"v\":\"机战\"},{\"n\":\"运动\",\"v\":\"运动\"},{\"n\":\"战争\",\"v\":\"战争\"},{\"n\":\"少年\",\"v\":\"少年\"},{\"n\":\"少女\",\"v\":\"少女\"},{\"n\":\"社会\",\"v\":\"社会\"},{\"n\":\"原创\",\"v\":\"原创\"},{\"n\":\"亲子\",\"v\":\"亲子\"},{\"n\":\"益智\",\"v\":\"益智\"},{\"n\":\"励志\",\"v\":\"励志\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":1,\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"国产\",\"v\":\"国产\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"欧美\",\"v\":\"欧美\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":11,\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"}]},{\"key\":4,\"name\":\"语言\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"国语\",\"v\":\"国语\"},{\"n\":\"英语\",\"v\":\"英语\"},{\"n\":\"粤语\",\"v\":\"粤语\"},{\"n\":\"闽南语\",\"v\":\"闽南语\"},{\"n\":\"韩语\",\"v\":\"韩语\"},{\"n\":\"日语\",\"v\":\"日语\"},{\"n\":\"其它\",\"v\":\"其它\"}]},{\"key\":2,\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"time\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"jilu\":[{\"key\":11,\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"}]},{\"key\":4,\"name\":\"语言\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"国语\",\"v\":\"国语\"},{\"n\":\"英语\",\"v\":\"英语\"},{\"n\":\"粤语\",\"v\":\"粤语\"},{\"n\":\"闽南语\",\"v\":\"闽南语\"},{\"n\":\"韩语\",\"v\":\"韩语\"},{\"n\":\"日语\",\"v\":\"日语\"},{\"n\":\"其它\",\"v\":\"其它\"}]},{\"key\":2,\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"time\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}]}");
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- }
-
- /**
- * 爬虫headers
- *
- * @param url
- * @return
- */
- protected HashMap getHeaders(String url) {
- HashMap headers = new HashMap<>();
- headers.put("method", "GET");
- headers.put("Host", siteHost);
- headers.put("Upgrade-Insecure-Requests", "1");
- headers.put("DNT", "1");
- headers.put("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36");
- headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
- headers.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
- return headers;
- }
-
- /**
- * 获取分类数据 + 首页最近更新视频列表数据
- *
- * @param filter 是否开启筛选 关联的是 软件设置中 首页数据源里的筛选开关
- * @return
- */
- @Override
- public String homeContent(boolean filter) {
- try {
- Document doc = Jsoup.parse(OkHttpUtil.string(siteUrl, getHeaders(siteUrl)));
- // 分类节点
- Elements elements = doc.select("ul.nav_list > li a");
- JSONArray classes = new JSONArray();
- for (Element ele : elements) {
- String name = ele.select("span").text();
- if (name.equals("樱花动漫")) {
- name = "动漫";
- }
- boolean show = name.equals("电影") ||
- name.equals("连续剧") ||
- name.equals("动漫") ||
- name.equals("纪录片") ||
- name.equals("综艺");
- if (show) {
- Matcher mather = regexCategory.matcher(ele.attr("href"));
- if (!mather.find())
- continue;
- // 把分类的id和名称取出来加到列表里
- String id = mather.group(1).trim();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("type_id", id);
- jsonObject.put("type_name", name);
- classes.put(jsonObject);
- }
- }
- JSONObject result = new JSONObject();
- if (filter) {
- result.put("filters", filterConfig);
- }
- result.put("class", classes);
- try {
- // 取首页推荐视频列表
- Element homeList = doc.select("div.vod_row").get(1);
- Elements list = homeList.select("div.cbox1 > ul.vodlist li a.vodlist_thumb");
- JSONArray videos = new JSONArray();
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.attr("title");
- String cover = vod.attr("data-original");
- String remark = vod.selectFirst("span.pic_text").text();
- Matcher matcher = regexVid.matcher(vod.attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- result.put("list", videos);
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 获取分类信息数据
- *
- * @param tid 分类id
- * @param pg 页数
- * @param filter 同homeContent方法中的filter
- * @param extend 筛选参数{k:v, k1:v1}
- * @return
- */
- @Override
- public String categoryContent(String tid, String pg, boolean filter, HashMap extend) {
- try {
- String[] urlParams = new String[]{"", "", "", "", "", "", "", "", "", "", "", ""};
- urlParams[0] = tid;
- urlParams[8] = pg;
- if (extend != null && extend.size() > 0) {
- for (Iterator it = extend.keySet().iterator(); it.hasNext(); ) {
- String key = it.next();
- String value = extend.get(key);
- urlParams[Integer.parseInt(key)] = URLEncoder.encode(value);
- }
- }
- // 获取分类数据的url
- String url = siteUrl + "/show/" + TextUtils.join("-", urlParams) + ".html";
- String html = OkHttpUtil.string(url, getHeaders(url));
- Document doc = Jsoup.parse(html);
- JSONObject result = new JSONObject();
- int pageCount = 0;
- int page = -1;
-
- // 取页码相关信息
- Elements pageInfo = doc.select("ul.page li");
- if (pageInfo.size() == 0) {
- page = Integer.parseInt(pg);
- pageCount = page;
- } else {
- for (int i = 0; i < pageInfo.size(); i++) {
- Element li = pageInfo.get(i);
- Element a = li.selectFirst("a");
- if (a == null)
- continue;
- String name = a.text();
- if (page == -1 && li.hasClass("active")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- page = Integer.parseInt(matcher.group(1).split("-")[8]);
- } else {
- page = 0;
- }
- }
- if (name.equals("尾页")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- pageCount = Integer.parseInt(matcher.group(1).split("-")[8]);
- } else {
- pageCount = 0;
- }
- break;
- }
- }
- }
-
- JSONArray videos = new JSONArray();
- if (!html.contains("没有找到您想要的结果哦")) {
- // 取当前分类页的视频列表
- Elements list = doc.select("ul.vodlist li a.vodlist_thumb");
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.attr("title");
- String cover = vod.attr("data-original");
- String remark = vod.selectFirst("span.pic_text").text();
- Matcher matcher = regexVid.matcher(vod.attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- }
- result.put("page", page);
- result.put("pagecount", pageCount);
- result.put("limit", 60);
- result.put("total", pageCount <= 1 ? videos.length() : pageCount * 60);
-
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 视频详情信息
- *
- * @param ids 视频id
- * @return
- */
- @Override
- public String detailContent(List ids) {
- try {
- // 视频详情url
- String url = siteUrl + "/movie/" + ids.get(0) + ".html";
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- JSONObject result = new JSONObject();
- JSONObject vodList = new JSONObject();
-
- // 取基本数据
- String cover = doc.selectFirst("div.detail_list_box a.vodlist_thumb img").attr("data-original");
- String title = doc.selectFirst("div.detail_list_box h2.title").text();
- String desc = Jsoup.parse(doc.selectFirst("meta[name=description]").attr("content")).text();
- String category = "", area = "", year = "", remark = "", director = "", actor = "";
- Elements span_text_muted = doc.select("div.detail_list_box div.content_detail span");
- for (int i = 0; i < span_text_muted.size(); i++) {
- Element text = span_text_muted.get(i);
- String info = text.text();
- if (info.equals("类型:")) {
- category = text.nextElementSibling().text();
- } else if (info.equals("年份:")) {
- year = text.nextElementSibling().text();
- } else if (info.equals("地区:")) {
- area = text.nextElementSibling().text();
- } else if (info.equals("状态:")) {
- remark = text.nextElementSibling().text();
- } else if (info.equals("导演:")) {
- List directors = new ArrayList<>();
- Elements aa = text.parent().select("a");
- for (int j = 0; j < aa.size(); j++) {
- directors.add(aa.get(j).text());
- }
- director = TextUtils.join(",", directors);
- } else if (info.equals("主演:")) {
- List actors = new ArrayList<>();
- Elements aa = text.parent().select("a");
- for (int j = 0; j < aa.size(); j++) {
- actors.add(aa.get(j).text());
- }
- actor = TextUtils.join(",", actors);
- }
- }
-
- vodList.put("vod_id", ids.get(0));
- vodList.put("vod_name", title);
- vodList.put("vod_pic", cover);
- vodList.put("type_name", category);
- vodList.put("vod_year", year);
- vodList.put("vod_area", area);
- vodList.put("vod_remarks", remark);
- vodList.put("vod_actor", actor);
- vodList.put("vod_director", director);
- vodList.put("vod_content", desc);
-
- Map vod_play = new TreeMap<>(new Comparator() {
- @Override
- public int compare(String o1, String o2) {
- try {
- int sort1 = playerConfig.getJSONObject(o1).getInt("or");
- int sort2 = playerConfig.getJSONObject(o2).getInt("or");
-
- if (sort1 == sort2) {
- return 1;
- }
- return sort1 - sort2 > 0 ? 1 : -1;
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- return 1;
- }
- });
-
- // 取播放列表数据
- Elements sources = doc.select("div.play_source_tab > a");
- Elements sourceList = doc.select("div.play_list_box > div.playlist_full");
-
- for (int i = 0; i < sources.size(); i++) {
- Element source = sources.get(i);
- String sourceName = source.attr("alt");
- boolean found = false;
- for (Iterator it = playerConfig.keys(); it.hasNext(); ) {
- String flag = it.next();
- if (playerConfig.getJSONObject(flag).getString("sh").equals(sourceName)) {
- sourceName = flag;
- found = true;
- break;
- }
- }
- if (!found)
- continue;
- String playList = "";
- Elements playListA = sourceList.get(i).select("li > a");
- List vodItems = new ArrayList<>();
-
- for (int j = 0; j < playListA.size(); j++) {
- Element vod = playListA.get(j);
- Matcher matcher = regexPlay.matcher(vod.attr("href"));
- if (!matcher.find())
- continue;
- String playURL = matcher.group(1) + "-" + matcher.group(2) + "-" + matcher.group(3);
- vodItems.add(vod.text() + "$" + playURL);
- }
- if (vodItems.size() > 0)
- playList = TextUtils.join("#", vodItems);
-
- if (playList.length() == 0)
- continue;
-
- vod_play.put(sourceName, playList);
- }
-
- if (vod_play.size() > 0) {
- String vod_play_from = TextUtils.join("$$$", vod_play.keySet());
- String vod_play_url = TextUtils.join("$$$", vod_play.values());
- vodList.put("vod_play_from", vod_play_from);
- vodList.put("vod_play_url", vod_play_url);
- }
- JSONArray list = new JSONArray();
- list.put(vodList);
- result.put("list", list);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 获取视频播放信息
- *
- * @param flag 播放源
- * @param id 视频id
- * @param vipFlags 所有可能需要vip解析的源
- * @return
- */
- @Override
- public String playerContent(String flag, String id, List vipFlags) {
- try {
- // 播放页 url
- String url = siteUrl + "/play/" + id + ".html";
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- Elements allScript = doc.select("script");
- JSONObject result = new JSONObject();
- for (int i = 0; i < allScript.size(); i++) {
- String scContent = allScript.get(i).html().trim();
- if (scContent.startsWith("var player_")) { // 取直链
- int start = scContent.indexOf('{');
- int end = scContent.lastIndexOf('}') + 1;
- String json = scContent.substring(start, end);
- JSONObject player = new JSONObject(json);
- if (playerConfig.has(player.getString("from"))) {
- JSONObject pCfg = playerConfig.getJSONObject(player.getString("from"));
- String videoUrl = player.getString("url");
- String playUrl = pCfg.getString("pu");
- result.put("parse", pCfg.getInt("sn"));
- result.put("playUrl", playUrl);
- result.put("url", videoUrl);
- result.put("header", "");
- }
- break;
- }
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 搜索
- *
- * @param key
- * @param quick 是否播放页的快捷搜索
- * @return
- */
- @Override
- public String searchContent(String key, boolean quick) {
- try {
- if (quick)
- return "";
- String url = siteUrl + "/vsearch/-------------.html?wd=" + URLEncoder.encode(key) + "&submit=";
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- JSONObject result = new JSONObject();
-
- JSONArray videos = new JSONArray();
- Elements list = doc.select("div.search_box li.searchlist_item a.vodlist_thumb");
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.attr("title");
- String cover = vod.attr("data-original");
- String remark = vod.selectFirst("span.pic_text").text();
- Matcher matcher = regexVid.matcher(vod.attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
-
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-}
diff --git a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/AppYs.java b/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/AppYs.java
deleted file mode 100644
index a406414..0000000
--- a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/AppYs.java
+++ /dev/null
@@ -1,1124 +0,0 @@
-package com.github.catvod.spider;
-
-import android.content.Context;
-import android.text.TextUtils;
-
-import com.github.catvod.crawler.Spider;
-import com.github.catvod.crawler.SpiderDebug;
-import com.github.catvod.utils.Misc;
-import com.github.catvod.utils.okhttp.OkHttpUtil;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * M浏览器中的App影视
- *
- * Author: 群友 不负此生
- */
-public class AppYs extends Spider {
-
- private String extString = "";
-
- @Override
- public void init(Context context, String extend) {
- super.init(context, extend);
- this.extString = extend;
- }
-
- @Override
- public String homeContent(boolean filter) {
- try {
- String url = getCateUrl(extString);
- JSONArray jsonArray = null;
- if (!url.isEmpty()) {
- SpiderDebug.log(url);
- String json = OkHttpUtil.string(url, getHeaders(url));
- JSONObject obj = new JSONObject(json);
- if (obj.has("list") && obj.get("list") instanceof JSONArray) {
- jsonArray = obj.getJSONArray("list");
- } else if (obj.has("data") && obj.get("data") instanceof JSONObject && obj.getJSONObject("data").has("list") && obj.getJSONObject("data").get("list") instanceof JSONArray) {
- jsonArray = obj.getJSONObject("data").getJSONArray("list");
- } else if (obj.has("data") && obj.get("data") instanceof JSONArray) {
- jsonArray = obj.getJSONArray("data");
- }
- } else { // 通过filter列表读分类
- String filterStr = getFilterTypes(url, null);
- String[] classes = filterStr.split("\n")[0].split("\\+");
- jsonArray = new JSONArray();
- for (int i = 1; i < classes.length; i++) {
- String[] kv = classes[i].trim().split("=");
- if (kv.length < 2)
- continue;
- JSONObject newCls = new JSONObject();
- newCls.put("type_name", kv[0].trim());
- newCls.put("type_id", kv[1].trim());
- jsonArray.put(newCls);
- }
- }
- JSONObject result = new JSONObject();
- JSONArray classes = new JSONArray();
- if (jsonArray != null) {
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject jObj = jsonArray.getJSONObject(i);
- String typeName = jObj.getString("type_name");
- if (isBan(typeName))
- continue;
- String typeId = jObj.getString("type_id");
- JSONObject newCls = new JSONObject();
- newCls.put("type_id", typeId);
- newCls.put("type_name", typeName);
- JSONObject typeExtend = jObj.optJSONObject("type_extend");
- if (filter) {
- String filterStr = getFilterTypes(url, typeExtend);
- String[] filters = filterStr.split("\n");
- JSONArray filterArr = new JSONArray();
- for (int k = url.isEmpty() ? 1 : 0; k < filters.length; k++) {
- String l = filters[k].trim();
- if (l.isEmpty())
- continue;
- String[] oneLine = l.split("\\+");
- String type = oneLine[0].trim();
- String typeN = type;
- if (type.contains("筛选")) {
- type = type.replace("筛选", "");
- if (type.equals("class"))
- typeN = "类型";
- else if (type.equals("area"))
- typeN = "地区";
- else if (type.equals("lang"))
- typeN = "语言";
- else if (type.equals("year"))
- typeN = "年份";
- }
- JSONObject jOne = new JSONObject();
- jOne.put("key", type);
- jOne.put("name", typeN);
- JSONArray valueArr = new JSONArray();
- for (int j = 1; j < oneLine.length; j++) {
- JSONObject kvo = new JSONObject();
- String kv = oneLine[j].trim();
- int sp = kv.indexOf("=");
- if (sp == -1) {
- if (isBan(kv))
- continue;
- kvo.put("n", kv);
- kvo.put("v", kv);
- } else {
- String n = kv.substring(0, sp);
- if (isBan(n))
- continue;
- kvo.put("n", n.trim());
- kvo.put("v", kv.substring(sp + 1).trim());
- }
- valueArr.put(kvo);
- }
- jOne.put("value", valueArr);
- filterArr.put(jOne);
- }
- if (!result.has("filters")) {
- result.put("filters", new JSONObject());
- }
- result.getJSONObject("filters").put(typeId, filterArr);
- }
- classes.put(newCls);
- }
- }
- result.put("class", classes);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- @Override
- public String homeVideoContent() {
- try {
- String apiUrl = extString;
- String url = getRecommendUrl(apiUrl);
- boolean isTV = false;
- if (url.isEmpty()) {
- url = getCateFilterUrlPrefix(apiUrl) + "movie&page=1&area=&type=&start=";
- isTV = true;
- }
- SpiderDebug.log(url);
- String json = OkHttpUtil.string(url, getHeaders(url));
- JSONObject obj = new JSONObject(json);
- JSONArray videos = new JSONArray();
- if (isTV) {
- JSONArray jsonArray = obj.getJSONArray("data");
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject vObj = jsonArray.getJSONObject(i);
- JSONObject v = new JSONObject();
- v.put("vod_id", vObj.getString("nextlink"));
- v.put("vod_name", vObj.getString("title"));
- v.put("vod_pic", vObj.getString("pic"));
- v.put("vod_remarks", vObj.getString("state"));
- videos.put(v);
- }
- } else {
- ArrayList arrays = new ArrayList<>();
- findJsonArray(obj, "vlist", arrays);
- if (arrays.isEmpty()) {
- findJsonArray(obj, "vod_list", arrays);
- }
- List ids = new ArrayList<>();
- for (JSONArray jsonArray : arrays) {
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject vObj = jsonArray.getJSONObject(i);
- String vid = vObj.getString("vod_id");
- if (ids.contains(vid))
- continue;
- ids.add(vid);
- JSONObject v = new JSONObject();
- v.put("vod_id", vid);
- v.put("vod_name", vObj.getString("vod_name"));
- v.put("vod_pic", vObj.getString("vod_pic"));
- v.put("vod_remarks", vObj.getString("vod_remarks"));
- videos.put(v);
- }
- }
- }
- JSONObject result = new JSONObject();
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- @Override
- public String categoryContent(String tid, String pg, boolean filter, HashMap extend) {
- try {
- String apiUrl = extString;
- String url = getCateFilterUrlPrefix(apiUrl) + tid + getCateFilterUrlSuffix(apiUrl);
- url = url.replace("#PN#", pg);
- url = url.replace("筛选class", (extend != null && extend.containsKey("class")) ? extend.get("class") : "");
- url = url.replace("筛选area", (extend != null && extend.containsKey("area")) ? extend.get("area") : "");
- url = url.replace("筛选lang", (extend != null && extend.containsKey("lang")) ? extend.get("lang") : "");
- url = url.replace("筛选year", (extend != null && extend.containsKey("year")) ? extend.get("year") : "");
- url = url.replace("排序", (extend != null && extend.containsKey("排序")) ? extend.get("排序") : "");
- SpiderDebug.log(url);
- String json = OkHttpUtil.string(url, getHeaders(url));
- JSONObject obj = new JSONObject(json);
- int totalPg = Integer.MAX_VALUE;
- try {
- if (obj.has("totalpage") && obj.get("totalpage") instanceof Integer) {
- totalPg = obj.getInt("totalpage");
- } else if (obj.has("pagecount") && obj.get("pagecount") instanceof Integer) {
- totalPg = obj.getInt("pagecount");
- } else if (obj.has("data") && obj.get("data") instanceof JSONObject &&
- (obj.getJSONObject("data").has("total") && obj.getJSONObject("data").get("total") instanceof Integer &&
- obj.getJSONObject("data").has("limit") && obj.getJSONObject("data").get("limit") instanceof Integer)) {
- int limit = obj.getJSONObject("data").getInt("limit");
- int total = obj.getJSONObject("data").getInt("total");
- totalPg = total % limit == 0 ? (total / limit) : (total / limit + 1);
- }
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
-
- JSONArray jsonArray = null;
- JSONArray videos = new JSONArray();
- if (obj.has("list") && obj.get("list") instanceof JSONArray) {
- jsonArray = obj.getJSONArray("list");
- } else if (obj.has("data") && obj.get("data") instanceof JSONObject && obj.getJSONObject("data").has("list") && obj.getJSONObject("data").get("list") instanceof JSONArray) {
- jsonArray = obj.getJSONObject("data").getJSONArray("list");
- } else if (obj.has("data") && obj.get("data") instanceof JSONArray) {
- jsonArray = obj.getJSONArray("data");
- }
- if (jsonArray != null) {
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject vObj = jsonArray.getJSONObject(i);
- if (vObj.has("vod_id")) {
- JSONObject v = new JSONObject();
- v.put("vod_id", vObj.getString("vod_id"));
- v.put("vod_name", vObj.getString("vod_name"));
- v.put("vod_pic", vObj.getString("vod_pic"));
- v.put("vod_remarks", vObj.getString("vod_remarks"));
- videos.put(v);
- } else {
- JSONObject v = new JSONObject();
- v.put("vod_id", vObj.getString("nextlink"));
- v.put("vod_name", vObj.getString("title"));
- v.put("vod_pic", vObj.getString("pic"));
- v.put("vod_remarks", vObj.getString("state"));
- videos.put(v);
- }
- }
- }
- JSONObject result = new JSONObject();
- result.put("page", pg);
- result.put("pagecount", totalPg);
- result.put("limit", 90);
- result.put("total", Integer.MAX_VALUE);
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- @Override
- public String detailContent(List ids) {
- try {
- String apiUrl = extString;
- String url = getPlayUrlPrefix(apiUrl) + ids.get(0);
- SpiderDebug.log(url);
- String json = OkHttpUtil.string(url, getHeaders(url));
- JSONObject obj = new JSONObject(json);
- JSONObject result = new JSONObject();
- JSONObject vod = new JSONObject();
- genPlayList(apiUrl, obj, json, vod, ids.get(0));
- JSONArray list = new JSONArray();
- list.put(vod);
- result.put("list", list);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- @Override
- public String searchContent(String key, boolean quick) {
- try {
- String apiUrl = extString;
- String url = getSearchUrl(apiUrl, URLEncoder.encode(key));
- String json = OkHttpUtil.string(url, getHeaders(url));
- JSONObject obj = new JSONObject(json);
- JSONArray jsonArray = null;
- JSONArray videos = new JSONArray();
- if (obj.has("list") && obj.get("list") instanceof JSONArray) {
- jsonArray = obj.getJSONArray("list");
- } else if (obj.has("data") && obj.get("data") instanceof JSONObject && obj.getJSONObject("data").has("list") && obj.getJSONObject("data").get("list") instanceof JSONArray) {
- jsonArray = obj.getJSONObject("data").getJSONArray("list");
- } else if (obj.has("data") && obj.get("data") instanceof JSONArray) {
- jsonArray = obj.getJSONArray("data");
- }
- if (jsonArray != null) {
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject vObj = jsonArray.getJSONObject(i);
- if (vObj.has("vod_id")) {
- JSONObject v = new JSONObject();
- v.put("vod_id", vObj.getString("vod_id"));
- v.put("vod_name", vObj.getString("vod_name"));
- v.put("vod_pic", vObj.getString("vod_pic"));
- v.put("vod_remarks", vObj.getString("vod_remarks"));
- videos.put(v);
- } else {
- JSONObject v = new JSONObject();
- v.put("vod_id", vObj.getString("nextlink"));
- v.put("vod_name", vObj.getString("title"));
- v.put("vod_pic", vObj.getString("pic"));
- v.put("vod_remarks", vObj.getString("state"));
- videos.put(v);
- }
- }
- }
- JSONObject result = new JSONObject();
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- @Override
- public String playerContent(String flag, String id, List vipFlags) {
- try {
- String apiUrl = extString;
- String parseUrl = getParseUrl(apiUrl, flag);
- String playerUrl = getPlayerUrl(apiUrl, parseUrl, id);
- JSONObject result = new JSONObject();
- getFinalVideo(playerUrl, result);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- private void findJsonArray(JSONObject obj, String match, ArrayList result) {
- Iterator keys = obj.keys();
- while (keys.hasNext()) {
- String k = keys.next();
- try {
- Object o = obj.get(k);
- if (k.equals(match) && o instanceof JSONArray)
- result.add((JSONArray) o);
- if (o instanceof JSONObject) {
- findJsonArray((JSONObject) o, match, result);
- } else if (o instanceof JSONArray) {
- JSONArray array = (JSONArray) o;
- for (int i = 0; i < array.length(); i++) {
- findJsonArray(array.getJSONObject(i), match, result);
- }
- }
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- }
- }
-
- private String jsonArr2Str(JSONArray array) {
- try {
- ArrayList strings = new ArrayList<>();
- for (int i = 0; i < array.length(); i++) {
- strings.add(array.getString(i));
- }
- return TextUtils.join(",", strings);
- } catch (JSONException e) {
- }
- return "";
- }
-
- private static HashMap fakeVips = null;
- private static final Object lock = new Object();
-
- private static String stopVipFlag(String flag) {
- synchronized (lock) {
- if (fakeVips == null) {
- fakeVips = new HashMap<>();
- fakeVips.put("youku", "优酷M");
- fakeVips.put("qq", "腾讯M");
- fakeVips.put("iqiyi", "爱奇艺M");
- fakeVips.put("qiyi", "奇艺M");
- fakeVips.put("letv", "乐视M");
- fakeVips.put("sohu", "搜狐M");
- fakeVips.put("tudou", "土豆M");
- fakeVips.put("pptv", "PPTVM");
- fakeVips.put("mgtv", "芒果TVM");
- fakeVips.put("wasu", "华数M");
- fakeVips.put("bilibili", "哔哩M");
- }
- if (fakeVips.containsKey(flag)) {
- return fakeVips.get(flag);
- }
- return flag;
- }
- }
-
- private HashMap getHeaders(String URL) {
- HashMap headers = new HashMap<>();
- headers.put("User-Agent", UA(URL));
- return headers;
- }
-
- private boolean isBan(String key) {
- return key.equals("伦理") || key.equals("情色") || key.equals("福利");
- }
-
- // M 扩展方法
-
- // ######重组搜索
- private String getSearchUrl(String URL, String KEY) {
- if (URL.contains(".vod")) {
- if (URL.contains("iopenyun.com")) {
- return URL + "/list?wd=" + KEY + "&page=";
- } else {
- return URL + "?wd=" + KEY + "&page=";
- }
- } else if (URL.contains("api.php/app") || URL.contains("xgapp")) {
- return URL + "search?text=" + KEY + "&pg=";
- } else if (urlPattern1.matcher(URL).find()) {
- if (URL.contains("esellauto")
- || URL.contains("1.14.63.101")
- || URL.contains("zjys")
- || URL.contains("dcd")
- || URL.contains("lxue")
- || URL.contains("weetai.cn")
- || URL.contains("haokanju1")
- || URL.contains("fit:8")
- || URL.contains("zjj.life")
- || URL.contains("love9989")
- || URL.contains("8d8q")
- || URL.contains("lk.pxun")
- || URL.contains("hgyx")
- || URL.contains("521x5")
- || URL.contains("lxyyy")
- || URL.contains("0818tv")
- || URL.contains("diyoui")
- || URL.contains("diliktv")
- || URL.contains("ppzhu")
- || URL.contains("aitesucai")
- || URL.contains("zz.ci")
- || URL.contains("chxjon")
- || URL.contains("watchmi")
- || URL.contains("vipbp")
- || URL.contains("bhtv")
- || URL.contains("xfykl")) {
- return URL + "?ac=list&" + "wd=" + KEY + "&page=";
- } else {
- return URL + "?ac=list&" + "zm=" + KEY + "&page=";
- }
- }
- return "";
- }
-
- // ######UA
- private static final Pattern urlPattern1 = Pattern.compile("api\\.php/.*?/vod");
- private static final Pattern urlPattern2 = Pattern.compile("api\\.php/.+?\\.vod");
- private static final Pattern parsePattern = Pattern.compile("/.+\\?.+=");
- private static final Pattern parsePattern1 = Pattern.compile(".*(url|v|vid|php\\?id)=");
- private static final Pattern parsePattern2 = Pattern.compile("https?://[^/]*");
- private static final Pattern[] parseMatchForDotVod = new Pattern[]{
- Pattern.compile("jx\\.+huimaojia\\.+com/player"),
- Pattern.compile("py\\.+789pan\\.+cn/player/tm\\.php\\?url="),
- Pattern.compile("ztys\\.+waruanzy\\.+com/player/\\?url="),
- Pattern.compile("yingshi\\.+waruanzy\\.+com/789pan/\\?url="),
- Pattern.compile("vip\\.+parwix\\.+com:4433/player/\\?url="),
- Pattern.compile("api\\.+cxitco\\.+cn"),
- Pattern.compile("/vip\\.+renrenmi.cc"),
- Pattern.compile("yanbing\\.+parwix\\.+com:4433/player"),
- Pattern.compile("json\\.+cantin\\.+cc/apijson\\.php"),
- Pattern.compile("ffdm\\.+miaoletv\\.+com/\\?url="),
- Pattern.compile("vip\\.+sylwl\\.+cn/api/\\?key="),
- Pattern.compile("jx\\.+dikotv\\.+com/\\?url="),
- Pattern.compile("zly\\.+xjqxz\\.+top/player/\\?url="),
- Pattern.compile("5znn\\.+xyz/m3u8\\.+php"),
- Pattern.compile("uid=1735&my="),
- Pattern.compile("api\\.+xkvideo\\.+design/m3u8\\.+php\\?url="),
- Pattern.compile("play\\.+szbodankyy\\.+com/xxoocnmb"),
- Pattern.compile("vip\\.+fj6080\\.+xyz/player/\\?url="),
- Pattern.compile("a\\.+dxzj88\\.+com/jiexi"),
- Pattern.compile("host\\.+q-q\\.+wang/api"),
- Pattern.compile("保佑")
- };
-
- private static final Pattern[] htmlVideoKeyMatch = new Pattern[]{
- Pattern.compile("player=new"),
- Pattern.compile(" typeExtendKeys = typeExtend.keys();
- while (typeExtendKeys.hasNext()) {
- String key = typeExtendKeys.next();
- if (key.equals("class") || key.equals("area") || key.equals("lang") || key.equals("year")) {
- try {
- str = str + "筛选" + key + "+全部=+" + typeExtend.getString(key).replace(",", "+") + "\n";
- } catch (JSONException e) {
- }
- }
- }
- }
- if (URL.contains(".vod")) {
- str += "\n" + "排序+全部=+最新=time+最热=hits+评分=score";
- } else if (URL.contains("api.php/app") || URL.contains("xgapp")) {
- } else {
- str = "分类+全部=+电影=movie+连续剧=tvplay+综艺=tvshow+动漫=comic+4K=movie_4k+体育=tiyu\n筛选class+全部=+喜剧+爱情+恐怖+动作+科幻+剧情+战争+警匪+犯罪+动画+奇幻+武侠+冒险+枪战+恐怖+悬疑+惊悚+经典+青春+文艺+微电影+古装+历史+运动+农村+惊悚+惊悚+伦理+情色+福利+三级+儿童+网络电影\n筛选area+全部=+大陆+香港+台湾+美国+英国+法国+日本+韩国+德国+泰国+印度+西班牙+加拿大+其他\n筛选year+全部=+2022+2021+2020+2019+2018+2017+2016+2015+2014+2013+2012+2011+2010+2009+2008+2007+2006+2005+2004+2003+2002+2001+2000";
- }
- return str;
- }
-
- // ######推荐地址
- String getRecommendUrl(String URL) {
- if (URL.contains("api.php/app") || URL.contains("xgapp")) {
- return URL + "index_video?token=";
- } else if (URL.contains(".vod")) {
- return URL + "/vodPhbAll";
- } else {
- return "";
- }
- }
-
- // ######播放器前缀地址
- String getPlayUrlPrefix(String URL) {
- if (URL.contains("api.php/app") || URL.contains("xgapp")) {
- if (URL.contains("dijiaxia")) {
- URL = "https://www.dijiaxia.com/api.php/app/";
- return URL + "video_detail?id=";
- } else if (URL.contains("1010dy")) {
- URL = "http://www.1010dy.cc/api.php/app/";
- return URL + "video_detail?id=";
- } else {
- return URL + "video_detail?id=";
- }
- } else if (URL.contains(".vod")) {
- if (URL.contains("iopenyun")) {
- return URL + "/detailID?vod_id=";
- } else {
- return URL + "/detail?vod_id=";
- }
- } else {
- return "";
- }
- }
-
- // ######选集
- private final HashMap
parseUrlMap = new HashMap<>();
-
- private void genPlayList(String URL, JSONObject object, String json, JSONObject vod, String vid) throws JSONException {
- ArrayList playUrls = new ArrayList<>();
- ArrayList playFlags = new ArrayList<>();
- if (URL.contains("api.php/app/")) {
- JSONObject data = object.getJSONObject("data");
- vod.put("vod_id", data.optString("vod_id", vid));
- vod.put("vod_name", data.getString("vod_name"));
- vod.put("vod_pic", data.getString("vod_pic"));
- vod.put("type_name", data.optString("vod_class"));
- vod.put("vod_year", data.optString("vod_year"));
- vod.put("vod_area", data.optString("vod_area"));
- vod.put("vod_remarks", data.optString("vod_remarks"));
- vod.put("vod_actor", data.optString("vod_actor"));
- vod.put("vod_director", data.optString("vod_director"));
- vod.put("vod_content", data.optString("vod_content"));
- JSONArray vodUrlWithPlayer = data.getJSONArray("vod_url_with_player");
- for (int i = 0; i < vodUrlWithPlayer.length(); i++) {
- JSONObject from = vodUrlWithPlayer.getJSONObject(i);
- String flag = stopVipFlag(from.getString("name"));
- playFlags.add(flag);
- playUrls.add(from.getString("url"));
- String purl = from.optString("parse_api");
- if (purl.contains("jpg.hou.lu/jm/za/index.php")) {
- purl = "http://vip.mengx.vip/home/api?type=ys&uid=3249696&key=aefqrtuwxyEFHKNOQY&url=";
- }
- parseUrlMap.put(flag, purl);
- }
- } else if (URL.contains("xgapp")) {
- JSONObject data = object.getJSONObject("data").getJSONObject("vod_info");
- vod.put("vod_id", data.optString("vod_id", vid));
- vod.put("vod_name", data.getString("vod_name"));
- vod.put("vod_pic", data.getString("vod_pic"));
- vod.put("type_name", data.optString("vod_class"));
- vod.put("vod_year", data.optString("vod_year"));
- vod.put("vod_area", data.optString("vod_area"));
- vod.put("vod_remarks", data.optString("vod_remarks"));
- vod.put("vod_actor", data.optString("vod_actor"));
- vod.put("vod_director", data.optString("vod_director"));
- vod.put("vod_content", data.optString("vod_content"));
- JSONArray vodUrlWithPlayer = data.getJSONArray("vod_url_with_player");
- for (int i = 0; i < vodUrlWithPlayer.length(); i++) {
- JSONObject from = vodUrlWithPlayer.getJSONObject(i);
- String flag = stopVipFlag(from.getString("name"));
- playFlags.add(flag);
- playUrls.add(from.getString("url"));
- String purl = from.optString("parse_api");
- if (purl.contains("jpg.hou.lu/jm/za/index.php")) {
- purl = "http://vip.mengx.vip/home/api?type=ys&uid=3249696&key=aefqrtuwxyEFHKNOQY&url=";
- }
- parseUrlMap.put(flag, purl);
- }
- } else if (/*urlPattern2.matcher(URL).find()*/URL.contains(".vod")) {
- JSONObject data = object.getJSONObject("data");
- vod.put("vod_id", data.optString("vod_id", vid));
- vod.put("vod_name", data.getString("vod_name"));
- vod.put("vod_pic", data.getString("vod_pic"));
- vod.put("type_name", data.optString("vod_class"));
- vod.put("vod_year", data.optString("vod_year"));
- vod.put("vod_area", data.optString("vod_area"));
- vod.put("vod_remarks", data.optString("vod_remarks"));
- vod.put("vod_actor", data.optString("vod_actor"));
- vod.put("vod_director", data.optString("vod_director"));
- vod.put("vod_content", data.optString("vod_content"));
- JSONArray vodUrlWithPlayer = data.getJSONArray("vod_play_list");
- for (int i = 0; i < vodUrlWithPlayer.length(); i++) {
- JSONObject from = vodUrlWithPlayer.getJSONObject(i);
- String flag = stopVipFlag(from.getJSONObject("player_info").getString("show"));
- playFlags.add(flag);
- playUrls.add(from.getString("url"));
- try {
- ArrayList parses = new ArrayList<>();
- String[] parse1 = from.getJSONObject("player_info").optString("parse").split(",");
- String[] parse2 = from.getJSONObject("player_info").optString("parse2").split(",");
- for (String p : parse1) {
- if (parsePattern.matcher(p).find()) {
- boolean add = true;
- for (Pattern pt : parseMatchForDotVod) {
- if (pt.matcher(p).find()) {
- add = false;
- break;
- }
- }
- if (add) {
- parses.add(p);
- }
- }
- }
- for (String p : parse2) {
- if (parsePattern.matcher(p).find()) {
- boolean add = true;
- for (Pattern pt : parseMatchForDotVod) {
- if (pt.matcher(p).find()) {
- add = false;
- break;
- }
- }
- if (add) {
- parses.add(p);
- }
- }
- }
- if (parses.size() > 0 && parses.get(0).contains("=")) {
- String purl = parses.get(0);
- if (purl.contains("http")) {
- Matcher matcher = parsePattern1.matcher(purl);
- if (matcher.find()) {
- purl = matcher.group(0).replace("..", ".").replace("vip.aotian.love", "vip.gaotian.love");
- }
- } else if (purl.contains("//")) {
- Matcher matcher = parsePattern1.matcher(purl);
- if (matcher.find()) {
- purl = "http:" + matcher.group(0).replace("..", ".");
- }
- } else {
- Matcher matcher = parsePattern2.matcher(URL);
- if (matcher.find()) {
- Matcher matcher1 = parsePattern1.matcher(URL);
- if (matcher1.find()) {
- purl = matcher.group(0) + matcher1.group(0).replace("..", ".");
- }
- }
- }
- parseUrlMap.put(flag, purl);
- } else {
- parseUrlMap.put(flag, "http://1.117.152.239:39000/?url=");
- }
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- }
- } else if (urlPattern1.matcher(URL).find()) {
- JSONObject data = object;
- vod.put("vod_id", data.optString("vod_id", vid));
- vod.put("vod_name", data.getString("title"));
- vod.put("vod_pic", data.getString("img_url"));
- vod.put("type_name", jsonArr2Str(data.optJSONArray("type")));
- vod.put("vod_year", data.optString("pubtime"));
- vod.put("vod_area", jsonArr2Str(data.optJSONArray("area")));
- vod.put("vod_remarks", data.optString("trunk"));
- vod.put("vod_actor", jsonArr2Str(data.optJSONArray("actor")));
- vod.put("vod_director", jsonArr2Str(data.optJSONArray("director")));
- vod.put("vod_content", data.optString("intro"));
- JSONObject playList = data.getJSONObject("videolist");
- Iterator playListKeys = playList.keys();
- while (playListKeys.hasNext()) {
- String from = playListKeys.next();
- JSONArray playListUrls = playList.getJSONArray(from);
- ArrayList urls = new ArrayList<>();
- for (int j = 0; j < playListUrls.length(); j++) {
- JSONObject urlObj = playListUrls.getJSONObject(j);
- urls.add(urlObj.getString("title") + "$" + urlObj.getString("url"));
- }
- playFlags.add(stopVipFlag(from));
- playUrls.add(TextUtils.join("#", urls));
- }
- }
-// for (int i = 0; i < playFlags.size(); i++) {
-// String pu = playUrls.get(i).split("#")[0].split("\\$")[1];
-// System.out.println(pu + " is video?" + isVideoFormat(pu));
-// playerContent(playFlags.get(i), pu, new ArrayList<>());
-// }
- vod.put("vod_play_from", TextUtils.join("$$$", playFlags));
- vod.put("vod_play_url", TextUtils.join("$$$", playUrls));
- }
-
- private String getParseUrl(String URL, String flag) {
- String parseUrl = "";
- if (urlPattern2.matcher(URL).find()) {
- if (parseUrlMap.containsKey(flag))
- parseUrl = parseUrlMap.get(flag);
- } else if (URL.contains("api.php/app/") || URL.contains("xgapp")) {
- if (parseUrlMap.containsKey(flag))
- parseUrl = parseUrlMap.get(flag);
- } else {
- parseUrl = URL;
- }
- if (parseUrl.contains("svip.jhyun.jx.cn") || parseUrl.contains("svip.jhdyw.vip")) {
- if (flag.contains("人人迷")) {
- parseUrl = "http://www.1080kan.cc/jiexi/rrmi.php?url=";
- } else if (flag.contains("人人")) {
- parseUrl = "http://www.1080kan.cc/jiexi/rr.php?url=";
- } else if (flag.contains("番茄")) {
- parseUrl = "http://www.1080kan.cc/jiexi/fq.php?url=";
- } else {
- parseUrl = "https://jx.parwix.com:4433/player/?url=";
- }
- } else if (parseUrl.contains("jhsj.manduhu.com") || parseUrl.contains("v.jhdyw.vip/nhdz666")) {
- parseUrl = "https://jx.parwix.com:4433/player/?url=";
- } else if (parseUrl.contains("x-n.cc")) {
- parseUrl = "https://jx.parwix.com:4433/player/?url=";
- }
- return parseUrl;
- }
-
- private String getPlayerUrl(String URL, String parseUrl, String playUrl) {
- if (URL.contains("xgapp") || URL.contains("api.php/app/") || /*urlPattern2.matcher(URL).find()*/URL.contains(".vod")) {
- if (playUrl.indexOf(".m3u8") > 15 || playUrl.indexOf(".mp4") > 15 || playUrl.contains("/obj/tos")) {
- if (playUrl.contains("url=")) {
- return "https://www.baidu.com/s?wd=" + playUrl.split("url=")[1];
- } else {
- return "https://www.baidu.com/s?wd=" + playUrl;
- }
- } else if (!parseUrl.contains("url=") && playUrl.contains("RongXingVR")) {
- return "https://www.baidu.com/s?wd=https://fast.rongxingvr.cn:8866/api/?key=nShWumGdMIbTwngTbI&url=" + playUrl;
- } else if (!parseUrl.contains("url=") && playUrl.contains("LT")) {
- return "https://www.baidu.com/s?wd=https://f7.pyxddc.com/bcjx/4k.php?url=" + playUrl;
- } else if (!parseUrl.contains("url=") && playUrl.contains("renrenmi")) {
- return "https://www.baidu.com/s?wd=https://kuba.renrenmi.cc:2266/api/?key=Y6UYLYtjImTCKe98JD&url=" + playUrl;
- } else if (!parseUrl.contains("url=") && playUrl.contains(".html")) {
- return "https://www.baidu.com/s?wd=http://1.117.152.239:39000/?url=" + playUrl;
- } else if (playUrl.contains("xfy")) {
- return "https://www.baidu.com/s?wd=http://jiexi.yunl.cc/api/?key=xYNESYSvHp1DV2ckKs&url=" + playUrl;
- } else {
- return "https://www.baidu.com/s?wd=" + parseUrl + playUrl;
- }
- } else if (urlPattern1.matcher(URL).find()) {
- if (playUrl.indexOf(".m3u8") > 15 || playUrl.indexOf(".mp4") > 15 || playUrl.contains("/obj/tos")) {
- if (playUrl.contains("url=")) {
- return "https://www.baidu.com/s?wd=" + playUrl.split("url=")[1];
- } else {
- return "https://www.baidu.com/s?wd=" + playUrl;
- }
- } else if (playUrl.contains("xfy")) {
- if (playUrl.contains("url=")) {
- return "https://www.baidu.com/s?wd=http://cache.dmtt.xyz/xfyjx/xfyjx.php?url=" + playUrl.split("url=")[1];
- } else {
- return "https://www.baidu.com/s?wd=https://json.hfyrw.com/mao.go?url=" + playUrl;
- }
- } else if (playUrl.contains("www.bilibili.com")) {
- String spUrl = playUrl.split("url=")[1];
- return "https://www.baidu.com/s?wd=https://jx.parwix.com:4433/player/?url=" + spUrl;
- } else if (URL.contains("zhenfy") || URL.contains("cztv") || URL.contains("1.14.63.101") || URL.contains("fit:8") || URL.contains("diliktv.xyz") || URL.contains("ppzhu.vip") || URL.contains("api.8d8q.com") || URL.contains("haokanju1.cc") || URL.contains("cztv")) {
- return "https://www.baidu.com/s?wd=" + playUrl + "&app=10000&account=272775028&password=qq272775028";
- } else if (URL.contains("lxyyy") || URL.contains("j.zjj.life") || URL.contains("lktv") || URL.contains("0818tv") || URL.contains("ruoxinew")) {
- return "https://www.baidu.com/s?wd=https://play.tkys.tv/?url=" + playUrl.split("url=")[1];
- } else {
- return "https://www.baidu.com/s?wd=" + playUrl;
- }
- } else {
- return "https://www.baidu.com/s?wd=" + playUrl;
- }
- }
-
- // ######视频地址
- private void getFinalVideo(String uu, JSONObject result) throws JSONException {
- if (uu.contains("baidu.com")) {
- String playurl = uu.split("wd=")[1];
- if (playurl.contains("duoduozy.com") || playurl.contains("suoyo.cc")) {
- String uuu = "https://www.6080kan.cc/app.php?url=" + playurl;
- String content = OkHttpUtil.string(uuu, null);
- JSONObject obj = new JSONObject(content);
- result.put("parse", 0);
- result.put("playUrl", "");
- result.put("url", obj.getString("url"));
- result.put("header", "{\"User-Agent\":\" Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.81 Safari/537.36 SE 2.X MetaSr 1.0\",\"referer\":\" https://player.duoduozy.com\",\"origin\":\" https://dp.duoduozy.com\",\"Host\":\" cache.m3u8.suoyo.cc\"}");
- } else if (playurl.contains("xfy")) {
- String content = OkHttpUtil.string(playurl, null);
- JSONObject obj = new JSONObject(content);
- result.put("parse", 0);
- result.put("playUrl", "");
- result.put("url", obj.getString("url"));
- result.put("header", "{\"referer\":\" appguapi.lihaoyun.top:11543\",\"User-Agent\":\" Dart/2.14 (dart:io)\"}}");
- } else if (playurl.contains("api.iopenyun.com:88")) {
- if (playurl.contains("html")) {
- String content = OkHttpUtil.string("https://api.m3u8.tv:5678/home/api?type=ys&uid=233711&key=dgilouvFKNRSWX2467&url=" + playurl.split("=")[1], null);
- JSONObject obj = new JSONObject(content);
- String ppurl = obj.getString("url");
- result.put("parse", 0);
- result.put("playUrl", "");
- result.put("url", ppurl);
- } else {
- result.put("parse", 1);
- result.put("playUrl", "");
- result.put("url", playurl);
- result.put("ua", "Mozilla/5.0 Windows10");
- result.put("header", "{\"Referer\":\"https://user.iopenyun.com:520/user/video/\"}");
- }
- } else if (playurl.contains("cat.wkfile.com")) {
- result.put("parse", 0);
- result.put("playUrl", "");
- result.put("url", playurl);
- result.put("header", "{\"User-Agent\":\" Lavf/58.12.100\",\"Referer\":\" wkfile.com\"}");
- } else if (!playurl.contains("=") && playurl.indexOf(".m3u8") > 15 || playurl.indexOf(".mp4") > 15 || playurl.contains("/obj/tos")) {
- if (playurl.contains("hsl.ysgc.xyz")) {
- String content = OkHttpUtil.string("https://jx.ysgc.xyz/?url=" + playurl, null);
- JSONObject obj = new JSONObject(content);
- String ppurl = obj.getString("url");
- result.put("parse", 0);
- result.put("playUrl", "");
- result.put("url", ppurl);
- result.put("header", "{\"Referer\":\" https://ysgc.cc\"}");
- } else if (playurl.contains("1.ruifenglb.com")) {
- result.put("parse", 0);
- result.put("playUrl", "");
- result.put("url", playurl);
- result.put("header", "{\"Referer\":\" https://1.ruifenglb.com\"}");
- } else {
- Matcher matcher = Pattern.compile(".*(http.*)").matcher(playurl);
- if (matcher.find()) {
- result.put("parse", 0);
- result.put("playUrl", "");
- result.put("url", matcher.group(1));
- } else {
- result.put("parse", 0);
- result.put("playUrl", "");
- result.put("url", playurl);
- }
- }
- } else if (playurl.contains("=")) {
- HashMap headers = new HashMap();
- headers.put("User-Agent", "Mozilla/5.0 Android");
- Map> respHeaders = new TreeMap<>();
- String content = OkHttpUtil.stringNoRedirect(playurl, headers, respHeaders);
- String redLoc = OkHttpUtil.getRedirectLocation(respHeaders);
- if (redLoc != null) {
- String finalurl = "";
- while (redLoc != null) {
- finalurl = redLoc;
- if (redLoc.indexOf(".mp4") > 30) {
- break;
- } else {
- headers.put("User-Agent", "Mozilla/5.0 Android");
- content = OkHttpUtil.stringNoRedirect(finalurl, headers, respHeaders);
- redLoc = OkHttpUtil.getRedirectLocation(respHeaders);
- }
- }
- String realurl = finalurl;
- if (realurl.contains("=http") || realurl.contains("url=")) {
- if (content.contains(" 1) {
- String realurl = jsonUrl;
- if (playurl.contains("mgtv.com")) {
- result.put("parse", 0);
- result.put("playUrl", "");
- result.put("url", realurl);
- result.put("header", "{\"User-Agent\":\" Mozilla/5.0\", \"Referer\":\" \"}");
- } else if (playurl.contains("bilibili.com")) {
- result.put("parse", 0);
- result.put("playUrl", "");
- result.put("url", realurl);
- } else {
- result.put("parse", 0);
- result.put("playUrl", "");
- result.put("url", realurl);
- }
- } else if (playurl.split("url=")[1].contains("http")) {
- result.put("parse", 1);
- result.put("playUrl", "");
- result.put("url", "http://1.117.152.239:39000/?url=" + playurl.split("url=")[1]);
- } else if (playurl.split("url=")[1].contains("renrenmi")) {
- result.put("parse", 1);
- result.put("playUrl", "");
- result.put("url", "http://www.1080kan.cc/jiexi/rrmi.php?url=" + playurl.split("url=")[1]);
- result.put("header", "{\"Referer\":\"http://www.1080kan.cc/\"}");
- } else {
- String id = playurl.split("url=")[1];
- /*
- String uuu = "https://vip.gaotian.love/api/?key=sRy0QAq8hqXRlrEtrq&url=" + id;
- content = OkHttpUtil.string(uuu, null);
- JSONObject obj = new JSONObject(content);
- String realurl = obj.optString("url", "");
- if (realurl.isEmpty())
- realurl = obj.optString("msg", "");
- result.put("parse", 0);
- result.put("playUrl", "");
- result.put("url", realurl);
- */
- result.put("parse", 1);
- result.put("playUrl", "");
- result.put("url", "https://jx.banyung.xyz:7799/player/?url=" + playurl.split("url=")[1]);
- }
- }
- }
- } else {
- result.put("parse", 0);
- result.put("playUrl", "");
- result.put("url", playurl);
- }
- } else {
- result.put("parse", 1);
- result.put("playUrl", "");
- result.put("url", uu);
- }
- }
-
- @Override
- public boolean manualVideoCheck() {
- return true;
- }
-
- @Override
- public boolean isVideoFormat(String url) {
- return Misc.isVideoFormat(url);
- }
-}
diff --git a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/AppYsV2.java b/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/AppYsV2.java
deleted file mode 100644
index 69c41b8..0000000
--- a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/AppYsV2.java
+++ /dev/null
@@ -1,833 +0,0 @@
-package com.github.catvod.spider;
-
-import android.content.Context;
-import android.text.TextUtils;
-
-import com.github.catvod.crawler.Spider;
-import com.github.catvod.crawler.SpiderDebug;
-import com.github.catvod.utils.Misc;
-import com.github.catvod.utils.okhttp.OkHttpUtil;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * M浏览器中的App影视
- *
- * Author: 群友 不负此生
- */
-public class AppYsV2 extends Spider {
-
- @Override
- public void init(Context context, String extend) {
- super.init(context, extend);
- try {
- extInfos = extend.split("###");
- } catch (Throwable th) {
- }
- }
-
- @Override
- public String homeContent(boolean filter) {
- try {
- String url = getCateUrl(getApiUrl());
- JSONArray jsonArray = null;
- if (!url.isEmpty()) {
- SpiderDebug.log(url);
- String json = desc(OkHttpUtil.string(url, getHeaders(url)), (byte) 0);
- JSONObject obj = new JSONObject(json);
- if (obj.has("list") && obj.get("list") instanceof JSONArray) {
- jsonArray = obj.getJSONArray("list");
- } else if (obj.has("data") && obj.get("data") instanceof JSONObject && obj.getJSONObject("data").has("list") && obj.getJSONObject("data").get("list") instanceof JSONArray) {
- jsonArray = obj.getJSONObject("data").getJSONArray("list");
- } else if (obj.has("data") && obj.get("data") instanceof JSONArray) {
- jsonArray = obj.getJSONArray("data");
- }
- } else { // 通过filter列表读分类
- String filterStr = getFilterTypes(url, null);
- String[] classes = filterStr.split("\n")[0].split("\\+");
- jsonArray = new JSONArray();
- for (int i = 1; i < classes.length; i++) {
- String[] kv = classes[i].trim().split("=");
- if (kv.length < 2)
- continue;
- JSONObject newCls = new JSONObject();
- newCls.put("type_name", kv[0].trim());
- newCls.put("type_id", kv[1].trim());
- jsonArray.put(newCls);
- }
- }
- JSONObject result = new JSONObject();
- JSONArray classes = new JSONArray();
- if (jsonArray != null) {
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject jObj = jsonArray.getJSONObject(i);
- String typeName = jObj.getString("type_name");
- if (isBan(typeName))
- continue;
- String typeId = jObj.getString("type_id");
- JSONObject newCls = new JSONObject();
- newCls.put("type_id", typeId);
- newCls.put("type_name", typeName);
- JSONObject typeExtend = jObj.optJSONObject("type_extend");
- if (filter) {
- String filterStr = getFilterTypes(url, typeExtend);
- String[] filters = filterStr.split("\n");
- JSONArray filterArr = new JSONArray();
- for (int k = url.isEmpty() ? 1 : 0; k < filters.length; k++) {
- String l = filters[k].trim();
- if (l.isEmpty())
- continue;
- String[] oneLine = l.split("\\+");
- String type = oneLine[0].trim();
- String typeN = type;
- if (type.contains("筛选")) {
- type = type.replace("筛选", "");
- if (type.equals("class"))
- typeN = "类型";
- else if (type.equals("area"))
- typeN = "地区";
- else if (type.equals("lang"))
- typeN = "语言";
- else if (type.equals("year"))
- typeN = "年份";
- }
- JSONObject jOne = new JSONObject();
- jOne.put("key", type);
- jOne.put("name", typeN);
- JSONArray valueArr = new JSONArray();
- for (int j = 1; j < oneLine.length; j++) {
- JSONObject kvo = new JSONObject();
- String kv = oneLine[j].trim();
- int sp = kv.indexOf("=");
- if (sp == -1) {
- if (isBan(kv))
- continue;
- kvo.put("n", kv);
- kvo.put("v", kv);
- } else {
- String n = kv.substring(0, sp);
- if (isBan(n))
- continue;
- kvo.put("n", n.trim());
- kvo.put("v", kv.substring(sp + 1).trim());
- }
- valueArr.put(kvo);
- }
- jOne.put("value", valueArr);
- filterArr.put(jOne);
- }
- if (!result.has("filters")) {
- result.put("filters", new JSONObject());
- }
- result.getJSONObject("filters").put(typeId, filterArr);
- }
- classes.put(newCls);
- }
- }
- result.put("class", classes);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- @Override
- public String homeVideoContent() {
- try {
- String apiUrl = getApiUrl();
- String url = getRecommendUrl(apiUrl);
- boolean isTV = false;
- if (url.isEmpty()) {
- url = getCateFilterUrlPrefix(apiUrl) + "movie&page=1&area=&type=&start=";
- isTV = true;
- }
- SpiderDebug.log(url);
- String json = desc(OkHttpUtil.string(url, getHeaders(url)), (byte) 1);
- JSONObject obj = new JSONObject(json);
- JSONArray videos = new JSONArray();
- if (isTV) {
- JSONArray jsonArray = obj.getJSONArray("data");
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject vObj = jsonArray.getJSONObject(i);
- JSONObject v = new JSONObject();
- v.put("vod_id", vObj.getString("nextlink"));
- v.put("vod_name", vObj.getString("title"));
- v.put("vod_pic", vObj.getString("pic"));
- v.put("vod_remarks", vObj.getString("state"));
- videos.put(v);
- }
- } else {
- ArrayList arrays = new ArrayList<>();
- findJsonArray(obj, "vlist", arrays);
- if (arrays.isEmpty()) {
- findJsonArray(obj, "vod_list", arrays);
- }
- List ids = new ArrayList<>();
- for (JSONArray jsonArray : arrays) {
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject vObj = jsonArray.getJSONObject(i);
- String vid = vObj.getString("vod_id");
- if (ids.contains(vid))
- continue;
- ids.add(vid);
- JSONObject v = new JSONObject();
- v.put("vod_id", vid);
- v.put("vod_name", vObj.getString("vod_name"));
- v.put("vod_pic", vObj.getString("vod_pic"));
- v.put("vod_remarks", vObj.getString("vod_remarks"));
- videos.put(v);
- }
- }
- }
- JSONObject result = new JSONObject();
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- @Override
- public String categoryContent(String tid, String pg, boolean filter, HashMap extend) {
- try {
- String apiUrl = getApiUrl();
- String url = getCateFilterUrlPrefix(apiUrl) + tid + getCateFilterUrlSuffix(apiUrl);
- url = url.replace("#PN#", pg);
- url = url.replace("筛选class", (extend != null && extend.containsKey("class")) ? extend.get("class") : "");
- url = url.replace("筛选area", (extend != null && extend.containsKey("area")) ? extend.get("area") : "");
- url = url.replace("筛选lang", (extend != null && extend.containsKey("lang")) ? extend.get("lang") : "");
- url = url.replace("筛选year", (extend != null && extend.containsKey("year")) ? extend.get("year") : "");
- url = url.replace("排序", (extend != null && extend.containsKey("排序")) ? extend.get("排序") : "");
- SpiderDebug.log(url);
- String json = desc(OkHttpUtil.string(url, getHeaders(url)), (byte) 2);
- JSONObject obj = new JSONObject(json);
- int totalPg = Integer.MAX_VALUE;
- try {
- if (obj.has("totalpage") && obj.get("totalpage") instanceof Integer) {
- totalPg = obj.getInt("totalpage");
- } else if (obj.has("pagecount") && obj.get("pagecount") instanceof Integer) {
- totalPg = obj.getInt("pagecount");
- } else if (obj.has("data") && obj.get("data") instanceof JSONObject &&
- (obj.getJSONObject("data").has("total") && obj.getJSONObject("data").get("total") instanceof Integer &&
- obj.getJSONObject("data").has("limit") && obj.getJSONObject("data").get("limit") instanceof Integer)) {
- int limit = obj.getJSONObject("data").getInt("limit");
- int total = obj.getJSONObject("data").getInt("total");
- totalPg = total % limit == 0 ? (total / limit) : (total / limit + 1);
- }
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
-
- JSONArray jsonArray = null;
- JSONArray videos = new JSONArray();
- if (obj.has("list") && obj.get("list") instanceof JSONArray) {
- jsonArray = obj.getJSONArray("list");
- } else if (obj.has("data") && obj.get("data") instanceof JSONObject && obj.getJSONObject("data").has("list") && obj.getJSONObject("data").get("list") instanceof JSONArray) {
- jsonArray = obj.getJSONObject("data").getJSONArray("list");
- } else if (obj.has("data") && obj.get("data") instanceof JSONArray) {
- jsonArray = obj.getJSONArray("data");
- }
- if (jsonArray != null) {
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject vObj = jsonArray.getJSONObject(i);
- if (vObj.has("vod_id")) {
- JSONObject v = new JSONObject();
- v.put("vod_id", vObj.getString("vod_id"));
- v.put("vod_name", vObj.getString("vod_name"));
- v.put("vod_pic", vObj.getString("vod_pic"));
- v.put("vod_remarks", vObj.getString("vod_remarks"));
- videos.put(v);
- } else {
- JSONObject v = new JSONObject();
- v.put("vod_id", vObj.getString("nextlink"));
- v.put("vod_name", vObj.getString("title"));
- v.put("vod_pic", vObj.getString("pic"));
- v.put("vod_remarks", vObj.getString("state"));
- videos.put(v);
- }
- }
- }
- JSONObject result = new JSONObject();
- result.put("page", pg);
- result.put("pagecount", totalPg);
- result.put("limit", 90);
- result.put("total", Integer.MAX_VALUE);
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- @Override
- public String detailContent(List ids) {
- try {
- String apiUrl = getApiUrl();
- String url = getPlayUrlPrefix(apiUrl) + ids.get(0);
- SpiderDebug.log(url);
- String json = desc(OkHttpUtil.string(url, getHeaders(url)), (byte) 3);
- JSONObject obj = new JSONObject(json);
- JSONObject result = new JSONObject();
- JSONObject vod = new JSONObject();
- genPlayList(apiUrl, obj, json, vod, ids.get(0));
- JSONArray list = new JSONArray();
- list.put(vod);
- result.put("list", list);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- @Override
- public String searchContent(String key, boolean quick) {
- try {
- String apiUrl = getApiUrl();
- String url = getSearchUrl(apiUrl, URLEncoder.encode(key));
- //System.out.println(url);
- String json = desc(OkHttpUtil.string(url, getHeaders(url)), (byte) 5);
- JSONObject obj = new JSONObject(json);
- JSONArray jsonArray = null;
- JSONArray videos = new JSONArray();
- if (obj.has("list") && obj.get("list") instanceof JSONArray) {
- jsonArray = obj.getJSONArray("list");
- } else if (obj.has("data") && obj.get("data") instanceof JSONObject && obj.getJSONObject("data").has("list") && obj.getJSONObject("data").get("list") instanceof JSONArray) {
- jsonArray = obj.getJSONObject("data").getJSONArray("list");
- } else if (obj.has("data") && obj.get("data") instanceof JSONArray) {
- jsonArray = obj.getJSONArray("data");
- }
- if (jsonArray != null) {
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject vObj = jsonArray.getJSONObject(i);
- if (vObj.has("vod_id")) {
- JSONObject v = new JSONObject();
- v.put("vod_id", vObj.getString("vod_id"));
- v.put("vod_name", vObj.getString("vod_name"));
- v.put("vod_pic", vObj.getString("vod_pic"));
- v.put("vod_remarks", vObj.getString("vod_remarks"));
- videos.put(v);
- } else {
- JSONObject v = new JSONObject();
- v.put("vod_id", vObj.getString("nextlink"));
- v.put("vod_name", vObj.getString("title"));
- v.put("vod_pic", vObj.getString("pic"));
- v.put("vod_remarks", vObj.getString("state"));
- videos.put(v);
- }
- }
- }
- JSONObject result = new JSONObject();
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- @Override
- public String playerContent(String flag, String id, List vipFlags) {
- try {
- ArrayList parseUrls = parseUrlMap.get(flag);
- if (parseUrls == null)
- parseUrls = new ArrayList<>();
- if (!parseUrls.isEmpty()) {
- JSONObject result = getFinalVideo(flag, parseUrls, id);
- if (result != null)
- return result.toString();
- }
- if (Misc.isVideoFormat(id)) {
- JSONObject result = new JSONObject();
- result.put("parse", 0);
- result.put("playUrl", "");
- result.put("url", id);
- return result.toString();
- } else {
- JSONObject result = new JSONObject();
- result.put("parse", 1);
- result.put("jx", "1");
- result.put("url", id);
- return result.toString();
- }
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- private void findJsonArray(JSONObject obj, String match, ArrayList result) {
- Iterator keys = obj.keys();
- while (keys.hasNext()) {
- String k = keys.next();
- try {
- Object o = obj.get(k);
- if (k.equals(match) && o instanceof JSONArray)
- result.add((JSONArray) o);
- if (o instanceof JSONObject) {
- findJsonArray((JSONObject) o, match, result);
- } else if (o instanceof JSONArray) {
- JSONArray array = (JSONArray) o;
- for (int i = 0; i < array.length(); i++) {
- findJsonArray(array.getJSONObject(i), match, result);
- }
- }
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- }
- }
-
- private String jsonArr2Str(JSONArray array) {
- try {
- ArrayList strings = new ArrayList<>();
- for (int i = 0; i < array.length(); i++) {
- strings.add(array.getString(i));
- }
- return TextUtils.join(",", strings);
- } catch (JSONException e) {
- }
- return "";
- }
-
- private HashMap getHeaders(String URL) {
- HashMap headers = new HashMap<>();
- headers.put("User-Agent", UA(URL));
- return headers;
- }
-
- private boolean isBan(String key) {
- return key.equals("伦理") || key.equals("情色") || key.equals("福利");
- }
-
- // M 扩展方法
-
- // ######重组搜索
- private String getSearchUrl(String URL, String KEY) {
- if (URL.contains(".vod")) {
- if (URL.contains("iopenyun.com")) {
- return URL + "/list?wd=" + KEY + "&page=";
- } else {
- return URL + "?wd=" + KEY + "&page=";
- }
- } else if (URL.contains("api.php/app") || URL.contains("xgapp")) {
- return URL + "search?text=" + KEY + "&pg=";
- } else if (urlPattern1.matcher(URL).find()) {
- if (URL.contains("esellauto")
- || URL.contains("1.14.63.101")
- || URL.contains("zjys")
- || URL.contains("dcd")
- || URL.contains("lxue")
- || URL.contains("weetai.cn")
- || URL.contains("haokanju1")
- || URL.contains("fit:8")
- || URL.contains("zjj.life")
- || URL.contains("love9989")
- || URL.contains("8d8q")
- || URL.contains("lk.pxun")
- || URL.contains("hgyx")
- || URL.contains("521x5")
- || URL.contains("lxyyy")
- || URL.contains("0818tv")
- || URL.contains("diyoui")
- || URL.contains("diliktv")
- || URL.contains("ppzhu")
- || URL.contains("aitesucai")
- || URL.contains("zz.ci")
- || URL.contains("chxjon")
- || URL.contains("watchmi")
- || URL.contains("vipbp")
- || URL.contains("bhtv")
- || URL.contains("xfykl")) {
- return URL + "?ac=list&" + "wd=" + KEY + "&page=";
- } else {
- return URL + "?ac=list&" + "zm=" + KEY + "&page=";
- }
- }
- return "";
- }
-
- // ######UA
- private static final Pattern urlPattern1 = Pattern.compile("api\\.php/.*?/vod");
- private static final Pattern urlPattern2 = Pattern.compile("api\\.php/.+?\\.vod");
- private static final Pattern parsePattern = Pattern.compile("/.+\\?.+=");
- private static final Pattern parsePattern1 = Pattern.compile(".*(url|v|vid|php\\?id)=");
- private static final Pattern parsePattern2 = Pattern.compile("https?://[^/]*");
-
- private static final Pattern[] htmlVideoKeyMatch = new Pattern[]{
- Pattern.compile("player=new"),
- Pattern.compile(" typeExtendKeys = typeExtend.keys();
- while (typeExtendKeys.hasNext()) {
- String key = typeExtendKeys.next();
- if (key.equals("class") || key.equals("area") || key.equals("lang") || key.equals("year")) {
- try {
- str = str + "筛选" + key + "+全部=+" + typeExtend.getString(key).replace(",", "+") + "\n";
- } catch (JSONException e) {
- }
- }
- }
- }
- if (URL.contains(".vod")) {
- str += "\n" + "排序+全部=+最新=time+最热=hits+评分=score";
- } else if (URL.contains("api.php/app") || URL.contains("xgapp")) {
- } else {
- str = "分类+全部=+电影=movie+连续剧=tvplay+综艺=tvshow+动漫=comic+4K=movie_4k+体育=tiyu\n筛选class+全部=+喜剧+爱情+恐怖+动作+科幻+剧情+战争+警匪+犯罪+动画+奇幻+武侠+冒险+枪战+恐怖+悬疑+惊悚+经典+青春+文艺+微电影+古装+历史+运动+农村+惊悚+惊悚+伦理+情色+福利+三级+儿童+网络电影\n筛选area+全部=+大陆+香港+台湾+美国+英国+法国+日本+韩国+德国+泰国+印度+西班牙+加拿大+其他\n筛选year+全部=+2022+2021+2020+2019+2018+2017+2016+2015+2014+2013+2012+2011+2010+2009+2008+2007+2006+2005+2004+2003+2002+2001+2000";
- }
- return str;
- }
-
- // ######推荐地址
- String getRecommendUrl(String URL) {
- if (URL.contains("api.php/app") || URL.contains("xgapp")) {
- return URL + "index_video?token=";
- } else if (URL.contains(".vod")) {
- return URL + "/vodPhbAll";
- } else {
- return "";
- }
- }
-
- // ######播放器前缀地址
- String getPlayUrlPrefix(String URL) {
- if (URL.contains("api.php/app") || URL.contains("xgapp")) {
- if (URL.contains("dijiaxia")) {
- URL = "https://www.dijiaxia.com/api.php/app/";
- return URL + "video_detail?id=";
- } else if (URL.contains("1010dy")) {
- URL = "http://www.1010dy.cc/api.php/app/";
- return URL + "video_detail?id=";
- } else {
- return URL + "video_detail?id=";
- }
- } else if (URL.contains(".vod")) {
- if (URL.contains("iopenyun")) {
- return URL + "/detailID?vod_id=";
- } else {
- return URL + "/detail?vod_id=";
- }
- } else {
- return "";
- }
- }
-
- // ######选集
- private final HashMap
> parseUrlMap = new HashMap<>();
-
- private void genPlayList(String URL, JSONObject object, String json, JSONObject vod, String vid) throws JSONException {
- ArrayList playUrls = new ArrayList<>();
- ArrayList playFlags = new ArrayList<>();
- if (URL.contains("api.php/app/")) {
- JSONObject data = object.getJSONObject("data");
- vod.put("vod_id", data.optString("vod_id", vid));
- vod.put("vod_name", data.getString("vod_name"));
- vod.put("vod_pic", data.getString("vod_pic"));
- vod.put("type_name", data.optString("vod_class"));
- vod.put("vod_year", data.optString("vod_year"));
- vod.put("vod_area", data.optString("vod_area"));
- vod.put("vod_remarks", data.optString("vod_remarks"));
- vod.put("vod_actor", data.optString("vod_actor"));
- vod.put("vod_director", data.optString("vod_director"));
- vod.put("vod_content", data.optString("vod_content"));
- JSONArray vodUrlWithPlayer = data.getJSONArray("vod_url_with_player");
- for (int i = 0; i < vodUrlWithPlayer.length(); i++) {
- JSONObject from = vodUrlWithPlayer.getJSONObject(i);
- String flag = from.optString("code").trim();
- if (flag.isEmpty())
- flag = from.getString("name").trim();
- playFlags.add(flag);
- playUrls.add(from.getString("url"));
- String purl = from.optString("parse_api").trim();
- ArrayList parseUrls = parseUrlMap.get(flag);
- if (parseUrls == null) {
- parseUrls = new ArrayList<>();
- parseUrlMap.put(flag, parseUrls);
- }
- if (!purl.isEmpty() && !parseUrls.contains(purl))
- parseUrls.add(purl);
- }
- } else if (URL.contains("xgapp")) {
- JSONObject data = object.getJSONObject("data").getJSONObject("vod_info");
- vod.put("vod_id", data.optString("vod_id", vid));
- vod.put("vod_name", data.getString("vod_name"));
- vod.put("vod_pic", data.getString("vod_pic"));
- vod.put("type_name", data.optString("vod_class"));
- vod.put("vod_year", data.optString("vod_year"));
- vod.put("vod_area", data.optString("vod_area"));
- vod.put("vod_remarks", data.optString("vod_remarks"));
- vod.put("vod_actor", data.optString("vod_actor"));
- vod.put("vod_director", data.optString("vod_director"));
- vod.put("vod_content", data.optString("vod_content"));
- JSONArray vodUrlWithPlayer = data.getJSONArray("vod_url_with_player");
- for (int i = 0; i < vodUrlWithPlayer.length(); i++) {
- JSONObject from = vodUrlWithPlayer.getJSONObject(i);
- String flag = from.optString("code").trim();
- if (flag.isEmpty())
- flag = from.getString("name").trim();
- playFlags.add(flag);
- playUrls.add(from.getString("url"));
- String purl = from.optString("parse_api").trim();
- ArrayList parseUrls = parseUrlMap.get(flag);
- if (parseUrls == null) {
- parseUrls = new ArrayList<>();
- parseUrlMap.put(flag, parseUrls);
- }
- if (!purl.isEmpty() && !parseUrls.contains(purl))
- parseUrls.add(purl);
- }
- } else if (/*urlPattern2.matcher(URL).find()*/URL.contains(".vod")) {
- JSONObject data = object.getJSONObject("data");
- vod.put("vod_id", data.optString("vod_id", vid));
- vod.put("vod_name", data.getString("vod_name"));
- vod.put("vod_pic", data.getString("vod_pic"));
- vod.put("type_name", data.optString("vod_class"));
- vod.put("vod_year", data.optString("vod_year"));
- vod.put("vod_area", data.optString("vod_area"));
- vod.put("vod_remarks", data.optString("vod_remarks"));
- vod.put("vod_actor", data.optString("vod_actor"));
- vod.put("vod_director", data.optString("vod_director"));
- vod.put("vod_content", data.optString("vod_content"));
- JSONArray vodUrlWithPlayer = data.getJSONArray("vod_play_list");
- for (int i = 0; i < vodUrlWithPlayer.length(); i++) {
- JSONObject from = vodUrlWithPlayer.getJSONObject(i);
- String flag = from.getJSONObject("player_info").optString("from").trim();
- if (flag.isEmpty())
- flag = from.getJSONObject("player_info").optString("show").trim();
- playFlags.add(flag);
- playUrls.add(from.getString("url"));
- try {
- ArrayList parses = new ArrayList<>();
- String[] parse1 = from.getJSONObject("player_info").optString("parse").split(",");
- String[] parse2 = from.getJSONObject("player_info").optString("parse2").split(",");
- parses.addAll(Arrays.asList(parse1));
- parses.addAll(Arrays.asList(parse2));
- ArrayList parseUrls = parseUrlMap.get(flag);
- if (parseUrls == null) {
- parseUrls = new ArrayList<>();
- parseUrlMap.put(flag, parseUrls);
- }
- for (String purl : parses) {
- if (purl.contains("http")) {
- Matcher matcher = parsePattern1.matcher(purl);
- if (matcher.find()) {
- purl = matcher.group(0);
- }
- } else if (purl.contains("//")) {
- Matcher matcher = parsePattern1.matcher(purl);
- if (matcher.find()) {
- purl = "http:" + matcher.group(0);
- }
- } else {
- Matcher matcher = parsePattern2.matcher(URL);
- if (matcher.find()) {
- Matcher matcher1 = parsePattern1.matcher(URL);
- if (matcher1.find()) {
- purl = matcher.group(0) + matcher1.group(0);
- }
- }
- }
- purl = purl.replace("..", ".").trim();
- if (!purl.isEmpty() && !parseUrls.contains(purl))
- parseUrls.add(purl);
- }
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- }
- } else if (urlPattern1.matcher(URL).find()) {
- JSONObject data = object;
- vod.put("vod_id", data.optString("vod_id", vid));
- vod.put("vod_name", data.getString("title"));
- vod.put("vod_pic", data.getString("img_url"));
- vod.put("type_name", jsonArr2Str(data.optJSONArray("type")));
- vod.put("vod_year", data.optString("pubtime"));
- vod.put("vod_area", jsonArr2Str(data.optJSONArray("area")));
- vod.put("vod_remarks", data.optString("trunk"));
- vod.put("vod_actor", jsonArr2Str(data.optJSONArray("actor")));
- vod.put("vod_director", jsonArr2Str(data.optJSONArray("director")));
- vod.put("vod_content", data.optString("intro"));
- JSONObject playList = data.getJSONObject("videolist");
- Iterator playListKeys = playList.keys();
- while (playListKeys.hasNext()) {
- String flag = playListKeys.next();
- ArrayList parseUrls = parseUrlMap.get(flag);
- if (parseUrls == null) {
- parseUrls = new ArrayList<>();
- parseUrlMap.put(flag, parseUrls);
- }
- JSONArray playListUrls = playList.getJSONArray(flag);
- ArrayList urls = new ArrayList<>();
- for (int j = 0; j < playListUrls.length(); j++) {
- JSONObject urlObj = playListUrls.getJSONObject(j);
- String url = urlObj.getString("url");
- if (url.contains("url=")) {
- int spIdx = url.indexOf("url=") + 4;
- String pUrl = url.substring(0, spIdx).trim();
- if (!pUrl.isEmpty() && !parseUrls.contains(pUrl))
- parseUrls.add(pUrl);
- urls.add(urlObj.getString("title") + "$" + url.substring(spIdx).trim());
- } else {
- urls.add(urlObj.getString("title") + "$" + url);
- }
- }
- playFlags.add(flag);
- playUrls.add(TextUtils.join("#", urls));
- }
- }
- vod.put("vod_play_from", TextUtils.join("$$$", playFlags));
- vod.put("vod_play_url", TextUtils.join("$$$", playUrls));
- }
-
- // ######视频地址
- private JSONObject getFinalVideo(String flag, ArrayList parseUrls, String url) throws JSONException {
- String htmlPlayUrl = "";
- for (String parseUrl : parseUrls) {
- if (parseUrl.isEmpty() || parseUrl.equals("null"))
- continue;
- String playUrl = parseUrl + url;
- String content = desc(OkHttpUtil.string(playUrl, null), (byte) 4);
- JSONObject tryJson = null;
- try {
- tryJson = Misc.jsonParse(url, content);
- } catch (Throwable th) {
-
- }
- if (tryJson != null && tryJson.has("url") && tryJson.has("header")) {
- tryJson.put("header", tryJson.getJSONObject("header").toString());
- return tryJson;
- }
- if (content.contains(" 1) {
- String descFlag = extInfos[1];
- if (descFlag.equals("nftv")) {
-
- }
- }
- return src;
- }
-}
diff --git a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Auete.java b/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Auete.java
deleted file mode 100644
index e51c577..0000000
--- a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Auete.java
+++ /dev/null
@@ -1,533 +0,0 @@
-package com.github.catvod.spider;
-
-import android.content.Context;
-import android.text.TextUtils;
-import android.util.Base64;
-
-import com.github.catvod.crawler.Spider;
-import com.github.catvod.crawler.SpiderDebug;
-import com.github.catvod.utils.okhttp.OkHttpUtil;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
-
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class Auete extends Spider {
- private static final String siteUrl = "https://auete.com";
- private static final String siteHost = "auete.com";
-
- /**
- * 播放源配置
- */
- private JSONObject playerConfig;
- /**
- * 筛选配置
- */
- private JSONObject filterConfig;
- //分类页URL规则
- private Pattern regexCategory = Pattern.compile("/(\\w+)/index.html");
- //详情页URL规则
- private Pattern regexVid = Pattern.compile("/(\\w+/\\w+/\\w+)/");
- //播放页URL规则
- private Pattern regexPlay = Pattern.compile("(/\\w+/\\w+/\\w+/play-\\d+-\\d+.html)");
- //筛选页URL规则
- //private Pattern regexPage = Pattern.compile("/\\w+/\\w+/index(\\d+).html");
- private Pattern regexPage = Pattern.compile("/index(\\d+).html");
-
- @Override
- public void init(Context context) {
- super.init(context);
- try {
- playerConfig = new JSONObject("{\"dphd\":{\"sh\":\"云播A线\",\"pu\":\"\",\"sn\":0,\"or\":999},\"cyun\":{\"sh\":\"云播C线\",\"pu\":\"\",\"sn\":0,\"or\":999},\"dbm3u8\":{\"sh\":\"云播D线\",\"pu\":\"\",\"sn\":0,\"or\":999},\"i8i\":{\"sh\":\"云播E线\",\"pu\":\"\",\"sn\":0,\"or\":999},\"m3u8hd\":{\"sh\":\"云播F线\",\"pu\":\"https://auete.com/api/?url=\",\"sn\":1,\"or\":999},\"languang\":{\"sh\":\"云播G线\",\"pu\":\"https://auete.com/api/?url=\",\"sn\":1,\"or\":999},\"hyun\":{\"sh\":\"云播H线\",\"pu\":\"https://auete.com/api/?url=\",\"sn\":1,\"or\":999},\"kyun\":{\"sh\":\"云播K线\",\"pu\":\"https://auete.com/api/?url=\",\"sn\":1,\"or\":999},\"bpyueyu\":{\"sh\":\"云播粤语\",\"pu\":\"\",\"sn\":0,\"or\":999},\"bpguoyu\":{\"sh\":\"云播国语\",\"pu\":\"\",\"sn\":0,\"or\":999}}");
- filterConfig = new JSONObject("{\"Movie\":[{\"key\":0,\"name\":\"分类\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"喜剧片\",\"v\":\"xjp\"},{\"n\":\"动作片\",\"v\":\"dzp\"},{\"n\":\"爱情片\",\"v\":\"aqp\"},{\"n\":\"科幻片\",\"v\":\"khp\"},{\"n\":\"恐怖片\",\"v\":\"kbp\"},{\"n\":\"惊悚片\",\"v\":\"jsp\"},{\"n\":\"战争片\",\"v\":\"zzp\"},{\"n\":\"剧情片\",\"v\":\"jqp\"}]}],\"Tv\":[{\"key\":0,\"name\":\"分类\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"美剧\",\"v\":\"oumei\"},{\"n\":\"韩剧\",\"v\":\"hanju\"},{\"n\":\"日剧\",\"v\":\"riju\"},{\"n\":\"泰剧\",\"v\":\"yataiju\"},{\"n\":\"网剧\",\"v\":\"wangju\"},{\"n\":\"台剧\",\"v\":\"taiju\"},{\"n\":\"国产\",\"v\":\"neidi\"},{\"n\":\"港剧\",\"v\":\"tvbgj\"}]}],\"Zy\":[{\"key\":0,\"name\":\"分类\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"国综\",\"v\":\"guozong\"},{\"n\":\"韩综\",\"v\":\"hanzong\"},{\"n\":\"美综\",\"v\":\"meizong\"}]}],\"Dm\":[{\"key\":0,\"name\":\"分类\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"动画\",\"v\":\"donghua\"},{\"n\":\"日漫\",\"v\":\"riman\"},{\"n\":\"国漫\",\"v\":\"guoman\"},{\"n\":\"美漫\",\"v\":\"meiman\"}]}],\"qita\":[{\"key\":0,\"name\":\"分类\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"纪录片\",\"v\":\"Jlp\"},{\"n\":\"经典片\",\"v\":\"Jdp\"},{\"n\":\"经典剧\",\"v\":\"Jdj\"},{\"n\":\"网大电影\",\"v\":\"wlp\"},{\"n\":\"国产老电影\",\"v\":\"laodianying\"}]}]}");
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- }
-
- /**
- * 爬虫headers
- *
- * @param url
- * @return
- */
- protected HashMap getHeaders(String url) {
- HashMap headers = new HashMap<>();
- headers.put("method", "GET");
- headers.put("Host", siteHost);
- headers.put("Upgrade-Insecure-Requests", "1");
- headers.put("DNT", "1");
- headers.put("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36");
- headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
- headers.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
- return headers;
- }
-
- /**
- * 获取分类数据 + 首页最近更新视频列表数据
- *
- * @param filter 是否开启筛选 关联的是 软件设置中 首页数据源里的筛选开关
- * @return
- */
- @Override
- public String homeContent(boolean filter) {
- try {
- Document doc = Jsoup.parse(OkHttpUtil.string(siteUrl, getHeaders(siteUrl)));
- // 分类节点
- Elements elements = doc.select("ul[class='navbar-nav mr-auto']> li a");
- JSONArray classes = new JSONArray();
- for (Element ele : elements) {
- //分类名
- String name = ele.text();
- boolean show = name.equals("电影") ||
- name.equals("电视剧") ||
- name.equals("综艺") ||
- name.equals("动漫") ||
- name.equals("其他");
- if (show) {
- Matcher mather = regexCategory.matcher(ele.attr("href"));
- if (!mather.find())
- continue;
- // 把分类的id和名称取出来加到列表里
- String id = mather.group(1).trim();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("type_id", id);
- jsonObject.put("type_name", name);
- classes.put(jsonObject);
- }
- }
- JSONObject result = new JSONObject();
- if (filter) {
- result.put("filters", filterConfig);
- }
- result.put("class", classes);
- try {
- // 取首页推荐视频列表
- Element homeList = doc.select("ul.threadlist").get(0);
- Elements list = homeList.select("li");
- JSONArray videos = new JSONArray();
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.selectFirst("h2 a").attr("title");
- String cover = vod.selectFirst("a img").attr("src");
- String remark = vod.selectFirst("a button").text();
- Matcher matcher = regexVid.matcher(vod.selectFirst("a").attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- result.put("list", videos);
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 获取分类信息数据
- *
- * @param tid 分类id
- * @param pg 页数
- * @param filter 同homeContent方法中的filter
- * @param extend 筛选参数{k:v, k1:v1}
- * @return
- */
- @Override
- public String categoryContent(String tid, String pg, boolean filter, HashMap extend) {
- // 获取分类数据的url
- String url = "";
- try {
- if (extend != null && extend.size() > 0) {
- for (Iterator it = extend.keySet().iterator(); it.hasNext(); ) {
- String key = it.next();
- String value = extend.get(key);
- if (value != null && value.length() != 0 && value != " ") {
- url = siteUrl + "/" + tid + "/" + value;
- } else {
- url = siteUrl + "/" + tid;
- }
- ;
- }
- } else {
- url = siteUrl + "/" + tid;
- }
- ;
- if (pg.equals("1")) {
- url = url + "/index.html";
- } else {
- url = url + "/index" + pg + ".html";
- }
- //System.out.println(url);
- String html = OkHttpUtil.string(url, getHeaders(url));
- Document doc = Jsoup.parse(html);
- JSONObject result = new JSONObject();
- int pageCount = 0;
- int page = -1;
-
- // 取页码相关信息
- Elements pageInfo = doc.select("ul.pagination li");
- if (pageInfo.size() == 0) {
- page = Integer.parseInt(pg);
- pageCount = page;
- } else {
- for (int i = 0; i < pageInfo.size(); i++) {
- Element li = pageInfo.get(i);
- Element a = li.selectFirst("a");
- if (a == null)
- continue;
- String name = a.text();
- //System.out.println("名称"+name);
- if (page == -1 && li.hasClass("active")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- //System.out.println("哈哈"+matcher.group(1));
- page = Integer.parseInt(matcher.group(1));
- } else {
- Elements list = doc.select("ul.threadlist li");
- if (list.size() > 0) {
- page = 1;
- } else {
- page = 0;
- }
- }
- }
- if (name.equals("尾页")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- //System.out.println("尾页" + matcher.group(1));
- pageCount = Integer.parseInt(matcher.group(1));
- } else {
- pageCount = 0;
- }
- break;
- }
- }
- }
-
- JSONArray videos = new JSONArray();
- if (!html.contains("没有找到您想要的结果哦")) {
- // 取当前分类页的视频列表
- Elements list = doc.select("ul.threadlist li");
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.selectFirst("h2 a").attr("title");
- String cover = vod.selectFirst("a img").attr("src");
- String remark = vod.selectFirst("a button").text();
- Matcher matcher = regexVid.matcher(vod.selectFirst("a").attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- }
- result.put("page", page);
- result.put("pagecount", pageCount);
- result.put("limit", 20);
- result.put("total", pageCount <= 1 ? videos.length() : pageCount * 20);
-
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 视频详情信息
- *
- * @param ids 视频id
- * @return
- */
- @Override
- public String detailContent(List ids) {
- try {
- // 视频详情url
- String url = siteUrl + "/" + ids.get(0) + "/";
- //System.out.println(url);
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- JSONObject result = new JSONObject();
- JSONObject vodList = new JSONObject();
-
- // 取基本数据
- String cover = doc.selectFirst("div.cover a").attr("href");
- String title = doc.selectFirst("div.cover a").attr("title");
- Elements list1 = doc.select("div.message>p");
- String desc = doc.select("div.message>p").get(list1.size() - 1).text();
- String category = "", area = "", year = "", remark = "", director = "", actor = "";
- Elements span_text_muted = doc.select("div.message>p");
- for (int i = 0; i < span_text_muted.size() - 2; i++) {
- Element text = span_text_muted.get(i);
- String info = text.text();
- if (info.contains("分类")) {
- try {
- category = text.text().split(": ")[1];
- } catch (Exception e) {
- category = "";
- }
- } else if (info.contains("年份")) {
- try {
- year = text.text().split(": ")[1];
- } catch (Exception e) {
- year = "";
- }
- } else if (info.contains("地区")) {
- try {
- area = text.text().split(": ")[1];
- } catch (Exception e) {
- area = "";
- }
- } else if (info.contains("影片备注")) {
- try {
- remark = text.text().split(": ")[1];
- } catch (Exception e) {
- remark = "";
- }
- } else if (info.contains("导演")) {
- try {
- director = text.text().split(": ")[1];
- } catch (Exception e) {
- director = "";
- }
- } else if (info.contains("主演")) {
- try {
- actor = text.text().split(": ")[1];
- } catch (Exception e) {
- actor = "";
- }
- }
- }
-
- vodList.put("vod_id", ids.get(0));
- vodList.put("vod_name", title);
- vodList.put("vod_pic", cover);
- vodList.put("type_name", category);
- vodList.put("vod_year", year);
- vodList.put("vod_area", area);
- vodList.put("vod_remarks", remark);
- vodList.put("vod_actor", actor);
- vodList.put("vod_director", director);
- vodList.put("vod_content", desc);
- //System.out.println(vodList.toString());
- Map vod_play = new TreeMap<>(new Comparator() {
- @Override
- public int compare(String o1, String o2) {
- try {
- int sort1 = playerConfig.getJSONObject(o1).getInt("or");
- int sort2 = playerConfig.getJSONObject(o2).getInt("or");
-
- if (sort1 == sort2) {
- return 1;
- }
- return sort1 - sort2 > 0 ? 1 : -1;
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- return 1;
- }
- });
-
- // 取播放列表数据
- Elements sources = doc.select("div#player_list>h2");
- //System.out.println(sources.size());
- Elements sourceList = doc.select("div#player_list>ul");
- //System.out.println(sourceList.size());
- for (int i = 0; i < sources.size(); i++) {
- Element source = sources.get(i);
- //System.out.println(sources.text().split(":")[0].split("』")[1]);
- String sourceName = source.text().split("』")[1].split(":")[0];
- boolean found = false;
- for (Iterator it = playerConfig.keys(); it.hasNext(); ) {
- String flag = it.next();
- if (playerConfig.getJSONObject(flag).getString("sh").equals(sourceName)) {
- sourceName = flag;
- found = true;
- break;
- }
- }
- if (!found)
- continue;
- String playList = "";
- Elements playListA = sourceList.get(i).select("li > a");
- //System.out.println(playListA.size());
- List vodItems = new ArrayList<>();
-
- for (int j = 0; j < playListA.size(); j++) {
- Element vod = playListA.get(j);
- Matcher matcher = regexPlay.matcher(vod.attr("href"));
- if (!matcher.find())
- continue;
- String playURL = matcher.group(1);
- vodItems.add(vod.text() + "$" + playURL);
- }
- if (vodItems.size() > 0)
- playList = TextUtils.join("#", vodItems);
-
- if (playList.length() == 0)
- continue;
-
- vod_play.put(sourceName, playList);
- }
-
- if (vod_play.size() > 0) {
- String vod_play_from = TextUtils.join("$$$", vod_play.keySet());
- String vod_play_url = TextUtils.join("$$$", vod_play.values());
- vodList.put("vod_play_from", vod_play_from);
- vodList.put("vod_play_url", vod_play_url);
- }
- JSONArray list = new JSONArray();
- list.put(vodList);
- result.put("list", list);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 获取视频播放信息
- *
- * @param flag 播放源
- * @param id 视频id
- * @param vipFlags 所有可能需要vip解析的源
- * @return
- */
- @Override
- public String playerContent(String flag, String id, List vipFlags) {
- try {
- // 播放页 url
- String url = siteUrl + id;
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- /*取得script下面的JS变量*/
- Elements e = doc.select("div>script");
- /*循环遍历script下面的JS变量*/
- String player = "";
- String pn = "";
- JSONObject result = new JSONObject();
- for (Element element : e) {
- /*取得JS变量数组*/
- String[] data = element.data().toString().split("var");
- /*取得单个JS变量*/
- for (String variable : data) {
- /*过滤variable为空的数据*/
- if (variable.contains("=")) {
- /*取到满足条件的JS变量*/
- if (variable.contains("now")) {
- String[] kvp = variable.split("=");
- player = kvp[1].replaceAll("\"", "").replaceAll(";", "");
- if (player.startsWith("base64")) {
- String[] plist1 = player.split("\\(");
- String[] plist2 = plist1[1].split("\\)");
- // 解码
- player = new String(Base64.decode(plist2[0].getBytes(), Base64.DEFAULT));
- //byte[] base64Data = Base64.getDecoder().decode(plist2[0]);
- //player = new String(base64Data, "utf-8");
- }
-
- if (!player.startsWith("http")) {
- player = siteUrl + player;
- }
- }
- if (variable.contains("pn")) {
- String[] kvp = variable.split("=");
- pn = kvp[1].replaceAll("\"", "").replaceAll(";", "");
- }
- }
- }
- if (playerConfig.has(pn)) {
- JSONObject pCfg = playerConfig.getJSONObject(pn);
- String videoUrl = player;
- String playUrl = pCfg.getString("pu");
- result.put("parse", pCfg.getInt("sn"));
- result.put("playUrl", playUrl);
- result.put("url", videoUrl);
- result.put("header", "");
- }
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 搜索
- *
- * @param key
- * @param quick 是否播放页的快捷搜索
- * @return
- */
- @Override
- public String searchContent(String key, boolean quick) {
- try {
- if (quick)
- return "";
- String url = siteUrl + "/search.php?searchword=" + URLEncoder.encode(key);
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- JSONObject result = new JSONObject();
-
- JSONArray videos = new JSONArray();
- Elements list = doc.select("div.card-body>ul>li.media");
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.select("div.media-body>div.subject>a>span").text();
- String cover = "";
- String remark = vod.selectFirst("div.media-body>div.d-flex>div.text-muted>span").text();
- Matcher matcher = regexVid.matcher(vod.select("div.media-body>div.subject>a").attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
-
- // 视频封面
- String vodurl = siteUrl + "/" + id + "/";
- Document voddoc = Jsoup.parse(OkHttpUtil.string(vodurl, getHeaders(vodurl)));
- cover = voddoc.selectFirst("div.cover a").attr("href");
-
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
-
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-}
diff --git a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Buka.java b/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Buka.java
deleted file mode 100644
index 328c2ed..0000000
--- a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Buka.java
+++ /dev/null
@@ -1,483 +0,0 @@
-package com.github.catvod.spider;
-
-import android.content.Context;
-import android.text.TextUtils;
-
-import com.github.catvod.crawler.Spider;
-import com.github.catvod.crawler.SpiderDebug;
-import com.github.catvod.utils.okhttp.OkHttpUtil;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
-
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * 真不卡 播放好像还有问题 需要大佬继续修复
- *
- * Author: 小黄瓜
- */
-public class Buka extends Spider {
- private static final String siteUrl = "https://www.zhenbuka3.com";
- private static final String siteHost = "www.zhenbuka3.com";
- private static final String ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36";
-
- /**
- * 播放源配置
- */
- private JSONObject playerConfig;
- /**
- * 筛选配置
- */
- private JSONObject filterConfig;
-
- private Pattern regexCategory = Pattern.compile("/vodtype/(\\w+)/");
- private Pattern regexVid = Pattern.compile("/voddetail/(\\w+)/");
- private Pattern regexPlay = Pattern.compile("/vodplay/(\\w+)-(\\d+)-(\\d+)/");
- private Pattern regexPage = Pattern.compile("/vodshow/(\\S+)/");
-
- @Override
- public void init(Context context) {
- super.init(context);
- try {
- playerConfig = new JSONObject("{\"qqpic\":{\"sh\":\"不卡超清[推荐]\",\"pu\":\"http://good-vip.mmiyue.com/zhenbuka2/player/index.php?video_id=\",\"sn\":0,\"or\":999},\"niuxyun\":{\"sh\":\"不卡备用[推荐]\",\"pu\":\"http://good-vip.mmiyue.com/jiekou/zbk-bkby/jx.php?id=\",\"sn\":0,\"or\":999},\"vipjx\":{\"sh\":\"不卡备用③[推荐]\",\"pu\":\"https://cq.mmiyue.com/zhenbuka2/player/index.php?url=\",\"sn\":0,\"or\":999},\"bkm3u8\":{\"sh\":\"不卡备用②[推荐]\",\"pu\":\"http://good-vip.mmiyue.com/zhenbuka2/player/index.php?url=//good-vip.mmiyue.com/zhenbuka2/api/dymp4.php?video_id=\",\"sn\":0,\"or\":999},\"cy\":{\"sh\":\"动漫云\",\"pu\":\"https://cq.mmiyue.com/jiekou/zbk-bkby/jx.php?id=\",\"sn\":0,\"or\":999},\"mgtv\":{\"sh\":\"不卡芒果\",\"pu\":\"https://cq.mmiyue.com/zhenbuka2/player/index.php?url=\",\"sn\":0,\"or\":999},\"qiyi\":{\"sh\":\"不卡奇艺\",\"pu\":\"https://cq.mmiyue.com/zhenbuka2/player/index.php?url=\",\"sn\":0,\"or\":999},\"qq\":{\"sh\":\"不卡企鹅\",\"pu\":\"https://cq.mmiyue.com/zhenbuka2/player/index.php?url=\",\"sn\":0,\"or\":999},\"youku\":{\"sh\":\"不卡优酷\",\"pu\":\"https://cq.mmiyue.com/zhenbuka2/player/index.php?url=\",\"sn\":0,\"or\":999},\"dbm3u8\":{\"sh\":\"资源备用[不推荐]\",\"pu\":\"\",\"sn\":0,\"or\":999},\"niuyun\":{\"sh\":\"超清备用\",\"pu\":\"https://api.l32c.cn/danmu/niuyun.php?id=\",\"sn\":0,\"or\":999},\"123kum3u8\":{\"sh\":\"资源备用[不推荐]\",\"pu\":\"\",\"sn\":0,\"or\":999},\"sixpan\":{\"sh\":\"不卡备用②[推荐]\",\"pu\":\"https://cq.mmiyue.com/zhenbuka2/player/index.php?url=//cq.mmiyue.com/m3u8/buka/\",\"sn\":0,\"or\":999},\"qq1\":{\"sh\":\"超清云播\",\"pu\":\"https://api.nixingle.com/zhenbuka/player/index.php?id=\",\"sn\":0,\"or\":999}}");
- filterConfig = new JSONObject("{\"1\":[{\"key\":0,\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"动作片\",\"v\":\"6\"},{\"n\":\"喜剧片\",\"v\":\"7\"},{\"n\":\"爱情片\",\"v\":\"8\"},{\"n\":\"科幻片\",\"v\":\"9\"},{\"n\":\"恐怖片\",\"v\":\"10\"},{\"n\":\"剧情片\",\"v\":\"11\"},{\"n\":\"战争片\",\"v\":\"12\"},{\"n\":\"动画片\",\"v\":\"23\"},{\"n\":\"纪录片\",\"v\":\"25\"},{\"n\":\"犯罪片\",\"v\":\"26\"}]},{\"key\":1,\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"中国大陆\",\"v\":\"中国大陆\"},{\"n\":\"中国香港\",\"v\":\"中国香港\"},{\"n\":\"中国台湾\",\"v\":\"中国台湾\"},{\"n\":\"美国\",\"v\":\"美国\"},{\"n\":\"法国\",\"v\":\"法国\"},{\"n\":\"英国\",\"v\":\"英国\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"韩国\",\"v\":\"韩国\"},{\"n\":\"德国\",\"v\":\"德国\"},{\"n\":\"泰国\",\"v\":\"泰国\"},{\"n\":\"印度\",\"v\":\"印度\"},{\"n\":\"意大利\",\"v\":\"意大利\"},{\"n\":\"西班牙\",\"v\":\"西班牙\"},{\"n\":\"加拿大\",\"v\":\"加拿大\"}]},{\"key\":11,\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"}]}],\"2\":[{\"key\":0,\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"国产剧\",\"v\":\"13\"},{\"n\":\"港台剧\",\"v\":\"14\"},{\"n\":\"日韩剧\",\"v\":\"15\"},{\"n\":\"欧美剧\",\"v\":\"16\"},{\"n\":\"海外剧\",\"v\":\"20\"},{\"n\":\"纪录片\",\"v\":\"24\"}]},{\"key\":1,\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"中国大陆\",\"v\":\"中国大陆\"},{\"n\":\"中国香港\",\"v\":\"中国香港\"},{\"n\":\"中国台湾\",\"v\":\"中国台湾\"},{\"n\":\"韩国\",\"v\":\"韩国\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"美国\",\"v\":\"美国\"},{\"n\":\"泰国\",\"v\":\"泰国\"},{\"n\":\"英国\",\"v\":\"英国\"},{\"n\":\"新加坡\",\"v\":\"新加坡\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":11,\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"}]}],\"3\":[{\"key\":1,\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"中国大陆\",\"v\":\"中国大陆\"},{\"n\":\"中国香港\",\"v\":\"中国香港\"},{\"n\":\"中国台湾\",\"v\":\"中国台湾\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"韩国\",\"v\":\"韩国\"},{\"n\":\"美国\",\"v\":\"美国\"},{\"n\":\"英国\",\"v\":\"英国\"}]},{\"key\":11,\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"},{\"n\":\"2009\",\"v\":\"2009\"},{\"n\":\"2008\",\"v\":\"2008\"},{\"n\":\"2007\",\"v\":\"2007\"},{\"n\":\"2006\",\"v\":\"2006\"},{\"n\":\"2005\",\"v\":\"2005\"},{\"n\":\"2004\",\"v\":\"2004\"}]}],\"4\":[{\"key\":1,\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"中国大陆\",\"v\":\"中国大陆\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"美国\",\"v\":\"美国\"}]},{\"key\":11,\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"},{\"n\":\"2009\",\"v\":\"2009\"},{\"n\":\"2008\",\"v\":\"2008\"},{\"n\":\"2007\",\"v\":\"2007\"},{\"n\":\"2006\",\"v\":\"2006\"},{\"n\":\"2005\",\"v\":\"2005\"},{\"n\":\"2004\",\"v\":\"2004\"}]}]}");
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- }
-
- /**
- * 爬虫headers
- *
- * @param url
- * @return
- */
- protected HashMap getHeaders(String url) {
- HashMap headers = new HashMap<>();
- headers.put("method", "GET");
- headers.put("Host", siteHost);
- headers.put("Upgrade-Insecure-Requests", "1");
- headers.put("DNT", "1");
- headers.put("User-Agent", ua);
- headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
- headers.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
- return headers;
- }
-
- /**
- * 获取分类数据 + 首页最近更新视频列表数据
- *
- * @param filter 是否开启筛选 关联的是 软件设置中 首页数据源里的筛选开关
- * @return
- */
- @Override
- public String homeContent(boolean filter) {
- try {
- Document doc = Jsoup.parse(OkHttpUtil.string(siteUrl, getHeaders(siteUrl)));
- // 分类节点
- Elements elements = doc.select("ul.dropdown > li a");
- JSONArray classes = new JSONArray();
- for (Element ele : elements) {
- String name = ele.text();
- boolean show = true;
- if (filter) {
- show = name.equals("电影") ||
- name.equals("剧集") ||
- name.equals("动漫") ||
- name.equals("综艺");
- }
- if (show) {
- Matcher mather = regexCategory.matcher(ele.attr("href"));
- if (!mather.find())
- continue;
- String id = mather.group(1).trim();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("type_id", id);
- jsonObject.put("type_name", name);
- classes.put(jsonObject);
- }
- }
- JSONObject result = new JSONObject();
- if (filter) {
- result.put("filters", filterConfig);
- }
- result.put("class", classes);
- try {
- Elements list = doc.select("div.stui-pannel_bd ul.stui-vodlist li div.stui-vodlist__box");
- JSONArray videos = new JSONArray();
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- Matcher matcher = regexVid.matcher(vod.selectFirst(".stui-vodlist__thumb").attr("href"));
- if (!matcher.find())
- continue;
- String title = vod.selectFirst(".title").text();
- String cover = vod.selectFirst(".stui-vodlist__thumb").attr("data-original");
- String remark = vod.selectFirst("span.pic-text").text();
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- result.put("list", videos);
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 获取分类信息数据
- *
- * @param tid 分类id
- * @param pg 页数
- * @param filter 同homeContent方法中的filter
- * @param extend 筛选参数{k:v, k1:v1}
- * @return
- */
- @Override
- public String categoryContent(String tid, String pg, boolean filter, HashMap extend) {
- try {
- String[] urlParams = new String[]{"", "", "", "", "", "", "", "", "", "", "", ""};
- urlParams[0] = tid;
- urlParams[8] = pg;
- if (extend != null && extend.size() > 0) {
- for (Iterator it = extend.keySet().iterator(); it.hasNext(); ) {
- String key = it.next();
- String value = extend.get(key);
- if (value.trim().length() == 0)
- continue;
- urlParams[Integer.parseInt(key)] = URLEncoder.encode(value);
- }
- }
- // 获取分类数据的url
- String url = siteUrl + "/vodshow/" + TextUtils.join("-", urlParams) + "/";
- String html = OkHttpUtil.string(url, getHeaders(url));
- Document doc = Jsoup.parse(html);
- JSONObject result = new JSONObject();
- int pageCount = 0;
- int page = -1;
-
- Elements pageInfo = doc.select(".stui-page li");
- if (pageInfo.size() == 0) {
- page = Integer.parseInt(pg);
- pageCount = page;
- } else {
- for (int i = 0; i < pageInfo.size(); i++) {
- Element li = pageInfo.get(i);
- Element a = li.selectFirst("a");
- if (a == null)
- continue;
- String name = a.text();
- if (page == -1 && li.hasClass("active")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- page = Integer.parseInt(matcher.group(1).split("-")[8]);
- } else {
- page = 0;
- }
- }
- if (name.equals("尾页")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- pageCount = Integer.parseInt(matcher.group(1).split("-")[8]);
- } else {
- pageCount = 0;
- }
- break;
- }
- }
- }
-
- JSONArray videos = new JSONArray();
- if (!html.contains("没有找到您想要的结果哦")) {
- Elements list = doc.select("ul.stui-vodlist li div.stui-vodlist__box");
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.selectFirst(".title").text();
- String cover = vod.selectFirst(".stui-vodlist__thumb").attr("data-original");
- String remark = vod.selectFirst("span.pic-text").text();
- Matcher matcher = regexVid.matcher(vod.selectFirst(".stui-vodlist__thumb").attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- }
- result.put("page", page);
- result.put("pagecount", pageCount);
- result.put("limit", 48);
- result.put("total", pageCount <= 1 ? videos.length() : pageCount * 48);
-
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 视频详情信息
- *
- * @param ids 视频id
- * @return
- */
- @Override
- public String detailContent(List ids) {
- try {
- // 视频详情url
- String url = siteUrl + "/voddetail/" + ids.get(0) + "/";
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- JSONObject result = new JSONObject();
- JSONObject vodList = new JSONObject();
-
- // 取基本数据
- String cover = doc.selectFirst("a.stui-vodlist__thumb img").attr("data-original");
- String title = doc.selectFirst("div.stui-content__detail h1.title").text();
- String desc = Jsoup.parse(doc.selectFirst("meta[name=description]").attr("content")).text();
- String category = "", area = "", year = "", remark = "", director = "", actor = "";
- Elements span_text_muted = doc.select("div.stui-content__detail span.text-muted");
- for (int i = 0; i < span_text_muted.size(); i++) {
- Element text = span_text_muted.get(i);
- String info = text.text();
- if (info.equals("类型:")) {
- category = text.nextElementSibling().text();
- } else if (info.equals("年份:")) {
- year = text.nextSibling().outerHtml().trim();
- } else if (info.equals("地区:")) {
- area = text.nextSibling().outerHtml().trim();
- } else if (info.equals("更新:")) {
- remark = text.nextSibling().outerHtml().trim();
- } else if (info.equals("导演:")) {
- List directors = new ArrayList<>();
- Elements aa = text.parent().select("a");
- for (int j = 0; j < aa.size(); j++) {
- directors.add(aa.get(j).text());
- }
- director = TextUtils.join(",", directors);
- } else if (info.equals("主演:")) {
- List actors = new ArrayList<>();
- Elements aa = text.parent().select("a");
- for (int j = 0; j < aa.size(); j++) {
- actors.add(aa.get(j).text());
- }
- actor = TextUtils.join(",", actors);
- }
- }
-
- vodList.put("vod_id", ids.get(0));
- vodList.put("vod_name", title);
- vodList.put("vod_pic", cover);
- vodList.put("type_name", category);
- vodList.put("vod_year", year);
- vodList.put("vod_area", area);
- vodList.put("vod_remarks", remark);
- vodList.put("vod_actor", actor);
- vodList.put("vod_director", director);
- vodList.put("vod_content", desc);
-
- Map vod_play = new TreeMap<>(new Comparator() {
- @Override
- public int compare(String o1, String o2) {
- try {
- int sort1 = playerConfig.getJSONObject(o1).getInt("or");
- int sort2 = playerConfig.getJSONObject(o2).getInt("or");
-
- if (sort1 == sort2) {
- return 1;
- }
- return sort1 - sort2 > 0 ? 1 : -1;
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- return 1;
- }
- });
-
- Elements sources = doc.select("div.playlist");
-
- for (int i = 0; i < sources.size(); i++) {
- Element source = sources.get(i);
- String sourceName = source.selectFirst("h3.title").text().trim();
- String tabHref = source.attr("href");
- boolean found = false;
- for (Iterator it = playerConfig.keys(); it.hasNext(); ) {
- String flag = it.next();
- if (playerConfig.getJSONObject(flag).getString("sh").equals(sourceName)) {
- sourceName = flag;
- found = true;
- break;
- }
- }
- if (!found)
- continue;
- String playList = "";
- Elements playListA = source.select("ul.stui-content__playlist > li > a");
- List vodItems = new ArrayList<>();
-
- for (int j = 0; j < playListA.size(); j++) {
- Element vod = playListA.get(j);
- Matcher matcher = regexPlay.matcher(vod.attr("href"));
- if (!matcher.find())
- continue;
- String playURL = matcher.group(1) + "-" + matcher.group(2) + "-" + matcher.group(3);
- vodItems.add(vod.text() + "$" + playURL);
- }
- if (vodItems.size() > 0)
- playList = TextUtils.join("#", vodItems);
-
- if (playList.length() == 0)
- continue;
-
- vod_play.put(sourceName, playList);
- }
-
- if (vod_play.size() > 0) {
- String vod_play_from = TextUtils.join("$$$", vod_play.keySet());
- String vod_play_url = TextUtils.join("$$$", vod_play.values());
- vodList.put("vod_play_from", vod_play_from);
- vodList.put("vod_play_url", vod_play_url);
- }
- JSONArray list = new JSONArray();
- list.put(vodList);
- result.put("list", list);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 获取视频播放信息
- *
- * @param flag 播放源
- * @param id 视频id
- * @param vipFlags 所有可能需要vip解析的源
- * @return
- */
- @Override
- public String playerContent(String flag, String id, List vipFlags) {
- try {
- // 播放页 url
- String url = siteUrl + "/vodplay/" + id + "/";
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- Elements allScript = doc.select("script");
- JSONObject result = new JSONObject();
- for (int i = 0; i < allScript.size(); i++) {
- String scContent = allScript.get(i).html().trim();
- if (scContent.startsWith("var player_")) {
- int start = scContent.indexOf('{');
- int end = scContent.lastIndexOf('}') + 1;
- String json = scContent.substring(start, end);
- JSONObject player = new JSONObject(json);
- if (playerConfig.has(player.getString("from"))) {
- JSONObject pCfg = playerConfig.getJSONObject(player.getString("from"));
- String videoUrl = player.getString("url");
- String playUrl = pCfg.getString("pu");
- String from = player.getString("from");
- if (from.equals("qqpic")) {
- // 感谢猫大神的直连解密代码
- HashMap hds = getHeaders(url);
- hds.put("Host", "good-vip.mmiyue.com");
- hds.put("Referer", url);
- String content1 = OkHttpUtil.string(playUrl + videoUrl, hds);
- Document doc1 = Jsoup.parse(content1);
- String url2 = "https:" + doc1.selectFirst("iframe#player").attr("src");
- hds.put("Host", "pcc.mmiyue.com");
- hds.put("Referer", "http://good-vip.mmiyue.com/");
- String content2 = OkHttpUtil.string(url2, hds);
- String finder = "var id=\"";
- start = content2.indexOf(finder) + finder.length();
- end = content2.indexOf('\"', start);
- String vvid = content2.substring(start, end);
- finder = "var sk=\"";
- start = content2.indexOf(finder) + finder.length();
- end = content2.indexOf('\"', start);
- String skey = content2.substring(start, end);
- finder = "var pt=\"";
- start = content2.indexOf(finder) + finder.length();
- end = content2.indexOf('\"', start);
- String pt = content2.substring(start, end);
- finder = "var ti=\"";
- start = content2.indexOf(finder) + finder.length();
- end = content2.indexOf('\"', start);
- String time = content2.substring(start, end);
- int bkn = 0x195c;
- for (int j = 0x0, all = skey.length(); all > j; ++j) {
- bkn += ((bkn << 5) + (byte) skey.charAt(j));
- }
- bkn = 0x7fffffff & bkn;
- int gtk1 = 0x0;
- for (int j = 0x0; j < pt.length(); j += 0x4) {
- gtk1 += Integer.parseInt(String.format("%c%c%c%c", pt.charAt(j), pt.charAt(j + 0x1), pt.charAt(j + 0x2), pt.charAt(j + 0x3)), 0x10);
- gtk1 %= 0x400a;
- }
- int offset = gtk1 % 10;
- int gtk = 0x0;
- for (int j = 0x0; j < pt.length(); j++) {
- gtk += ((byte) pt.charAt(j)) * (j + offset);
- gtk %= gtk1;
- }
- String finalVideoUrl = "https://pcc.mmiyue.com/hls/play/" + vvid + "%7C" + time + "%7C" + skey + "%7C" + pt + "%7C" + bkn + "%7C" + gtk + ".m3u8";
- result.put("parse", pCfg.getInt("sn"));
- result.put("playUrl", "");
- result.put("url", finalVideoUrl);
- result.put("header", "");
- } else {
- result.put("parse", pCfg.getInt("sn"));
- result.put("playUrl", playUrl);
- result.put("url", videoUrl);
- result.put("header", "");
- }
- }
- break;
- }
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 搜索
- *
- * @param key
- * @param quick 是否播放页的快捷搜索
- * @return
- */
- @Override
- public String searchContent(String key, boolean quick) {
- // 搜索有验证码 不支持
- return "";
- }
-}
diff --git a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Cokemv.java b/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Cokemv.java
deleted file mode 100644
index 23afa72..0000000
--- a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Cokemv.java
+++ /dev/null
@@ -1,492 +0,0 @@
-package com.github.catvod.spider;
-
-import android.content.Context;
-import android.text.TextUtils;
-
-import com.github.catvod.crawler.Spider;
-import com.github.catvod.crawler.SpiderDebug;
-import com.github.catvod.utils.okhttp.OkHttpUtil;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
-
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class Cokemv extends Spider {
- private static final String siteUrl = "https://cokemv.me";
- private static final String siteHost = "cokemv.me";
-
- /**
- * 播放源配置
- */
- private JSONObject playerConfig;
- /**
- * 筛选配置
- */
- private JSONObject filterConfig;
- private Pattern regexCategory = Pattern.compile("/vodtype/(\\d+).html");
- private Pattern regexVid = Pattern.compile("/voddetail/(\\d+).html");
- private Pattern regexPlay = Pattern.compile("/vodplay/(\\d+)-(\\d+)-(\\d+).html");
- private Pattern regexPage = Pattern.compile("/vodshow/(\\S+).html");
-
-
- @Override
- public void init(Context context) {
- super.init(context);
- try {
- playerConfig = new JSONObject("{\"app\":{\"sh\":\"APP\",\"pu\":\"\",\"sn\":0,\"or\":999},\"cokeqie01\":{\"sh\":\"極速路線\",\"pu\":\"\",\"sn\":0,\"or\":999},\"xin\":{\"sh\":\"高速路線\",\"pu\":\"\",\"sn\":0,\"or\":999},\"90mm\":{\"sh\":\"藍光號路\",\"pu\":\"\",\"sn\":0,\"or\":999},\"age01\":{\"sh\":\"動漫一線\",\"pu\":\"\",\"sn\":0,\"or\":999},\"age02\":{\"sh\":\"動漫二線\",\"pu\":\"\",\"sn\":0,\"or\":999},\"mahua\":{\"sh\":\"采集路線\",\"pu\":\"\",\"sn\":0,\"or\":999},\"toutiao\":{\"sh\":\"蓝光不卡\",\"pu\":\"\",\"sn\":0,\"or\":999}}");
- filterConfig = new JSONObject("{\"5\":[{\"key\":3,\"name\":\"剧情\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"喜剧\",\"v\":\"喜劇\"},{\"n\":\"爱情\",\"v\":\"愛情\"},{\"n\":\"恐怖\",\"v\":\"恐怖\"},{\"n\":\"动作\",\"v\":\"動作\"},{\"n\":\"科幻\",\"v\":\"科幻\"},{\"n\":\"剧情\",\"v\":\"劇情\"},{\"n\":\"战争\",\"v\":\"戰爭\"},{\"n\":\"犯罪\",\"v\":\"犯罪\"},{\"n\":\"动画\",\"v\":\"動畫\"},{\"n\":\"奇幻\",\"v\":\"奇幻\"},{\"n\":\"悬疑\",\"v\":\"懸疑\"},{\"n\":\"微电影\",\"v\":\"微電影\"}]},{\"key\":11,\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"}]},{\"key\":4,\"name\":\"语言\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"国语\",\"v\":\"國語\"},{\"n\":\"英语\",\"v\":\"英語\"},{\"n\":\"粤语\",\"v\":\"粵語\"},{\"n\":\"闽南语\",\"v\":\"閩南語\"},{\"n\":\"韩语\",\"v\":\"韓語\"},{\"n\":\"日语\",\"v\":\"日語\"},{\"n\":\"法语\",\"v\":\"法語\"},{\"n\":\"德语\",\"v\":\"德語\"},{\"n\":\"其它\",\"v\":\"其它\"}]},{\"key\":5,\"name\":\"字母\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"A\",\"v\":\"A\"},{\"n\":\"B\",\"v\":\"B\"},{\"n\":\"C\",\"v\":\"C\"},{\"n\":\"D\",\"v\":\"D\"},{\"n\":\"E\",\"v\":\"E\"},{\"n\":\"F\",\"v\":\"F\"},{\"n\":\"G\",\"v\":\"G\"},{\"n\":\"H\",\"v\":\"H\"},{\"n\":\"I\",\"v\":\"I\"},{\"n\":\"J\",\"v\":\"J\"},{\"n\":\"K\",\"v\":\"K\"},{\"n\":\"L\",\"v\":\"L\"},{\"n\":\"M\",\"v\":\"M\"},{\"n\":\"N\",\"v\":\"N\"},{\"n\":\"O\",\"v\":\"O\"},{\"n\":\"P\",\"v\":\"P\"},{\"n\":\"Q\",\"v\":\"Q\"},{\"n\":\"R\",\"v\":\"R\"},{\"n\":\"S\",\"v\":\"S\"},{\"n\":\"T\",\"v\":\"T\"},{\"n\":\"U\",\"v\":\"U\"},{\"n\":\"V\",\"v\":\"V\"},{\"n\":\"W\",\"v\":\"W\"},{\"n\":\"X\",\"v\":\"X\"},{\"n\":\"Y\",\"v\":\"Y\"},{\"n\":\"Z\",\"v\":\"Z\"},{\"n\":\"0-9\",\"v\":\"0-9\"}]},{\"key\":2,\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"time\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"2\":[{\"key\":0,\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"2\"},{\"n\":\"大陆剧\",\"v\":\"13\"},{\"n\":\"香港剧\",\"v\":\"14\"},{\"n\":\"韩国剧\",\"v\":\"15\"},{\"n\":\"欧美剧\",\"v\":\"16\"},{\"n\":\"日本剧\",\"v\":\"20\"},{\"n\":\"台湾剧\",\"v\":\"21\"},{\"n\":\"泰国剧\",\"v\":\"22\"}]},{\"key\":1,\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"中国大陆\",\"v\":\"中国大陆\"},{\"n\":\"韩国\",\"v\":\"韩国\"},{\"n\":\"中国香港\",\"v\":\"中国香港\"},{\"n\":\"中国台湾\",\"v\":\"中国台湾\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"美国\",\"v\":\"美国\"},{\"n\":\"泰国\",\"v\":\"泰国\"},{\"n\":\"英国\",\"v\":\"英国\"},{\"n\":\"新加坡\",\"v\":\"新加坡\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":11,\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"},{\"n\":\"2009\",\"v\":\"2009\"},{\"n\":\"2008\",\"v\":\"2008\"},{\"n\":\"2007\",\"v\":\"2007\"},{\"n\":\"2006\",\"v\":\"2006\"},{\"n\":\"2005\",\"v\":\"2005\"},{\"n\":\"2004\",\"v\":\"2004\"}]},{\"key\":4,\"name\":\"语言\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"国语\",\"v\":\"国语\"},{\"n\":\"英语\",\"v\":\"英语\"},{\"n\":\"粤语\",\"v\":\"粤语\"},{\"n\":\"闽南语\",\"v\":\"闽南语\"},{\"n\":\"韩语\",\"v\":\"韩语\"},{\"n\":\"日语\",\"v\":\"日语\"},{\"n\":\"其它\",\"v\":\"其它\"}]},{\"key\":5,\"name\":\"字母\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"A\",\"v\":\"A\"},{\"n\":\"B\",\"v\":\"B\"},{\"n\":\"C\",\"v\":\"C\"},{\"n\":\"D\",\"v\":\"D\"},{\"n\":\"E\",\"v\":\"E\"},{\"n\":\"F\",\"v\":\"F\"},{\"n\":\"G\",\"v\":\"G\"},{\"n\":\"H\",\"v\":\"H\"},{\"n\":\"I\",\"v\":\"I\"},{\"n\":\"J\",\"v\":\"J\"},{\"n\":\"K\",\"v\":\"K\"},{\"n\":\"L\",\"v\":\"L\"},{\"n\":\"M\",\"v\":\"M\"},{\"n\":\"N\",\"v\":\"N\"},{\"n\":\"O\",\"v\":\"O\"},{\"n\":\"P\",\"v\":\"P\"},{\"n\":\"Q\",\"v\":\"Q\"},{\"n\":\"R\",\"v\":\"R\"},{\"n\":\"S\",\"v\":\"S\"},{\"n\":\"T\",\"v\":\"T\"},{\"n\":\"U\",\"v\":\"U\"},{\"n\":\"V\",\"v\":\"V\"},{\"n\":\"W\",\"v\":\"W\"},{\"n\":\"X\",\"v\":\"X\"},{\"n\":\"Y\",\"v\":\"Y\"},{\"n\":\"Z\",\"v\":\"Z\"},{\"n\":\"0-9\",\"v\":\"0-9\"}]},{\"key\":2,\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"time\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"1\":[{\"key\":0,\"name\":\"分类\",\"value\":[{\"n\":\"全部\",\"v\":\"1\"},{\"n\":\"动作片\",\"v\":\"6\"},{\"n\":\"喜剧片\",\"v\":\"7\"},{\"n\":\"爱情片\",\"v\":\"8\"},{\"n\":\"科幻片\",\"v\":\"9\"},{\"n\":\"恐怖片\",\"v\":\"10\"},{\"n\":\"剧情片\",\"v\":\"11\"},{\"n\":\"战争片\",\"v\":\"12\"},{\"n\":\"犯罪片\",\"v\":\"23\"},{\"n\":\"奇幻片\",\"v\":\"24\"},{\"n\":\"悬疑片\",\"v\":\"25\"},{\"n\":\"记录片\",\"v\":\"27\"}]},{\"key\":1,\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"中国大陆\",\"v\":\"中国大陆\"},{\"n\":\"中国香港\",\"v\":\"中国香港\"},{\"n\":\"中国台湾\",\"v\":\"中国台湾\"},{\"n\":\"美国\",\"v\":\"美国\"},{\"n\":\"法国\",\"v\":\"法国\"},{\"n\":\"英国\",\"v\":\"英国\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"韩国\",\"v\":\"韩国\"},{\"n\":\"德国\",\"v\":\"德国\"},{\"n\":\"泰国\",\"v\":\"泰国\"},{\"n\":\"印度\",\"v\":\"印度\"},{\"n\":\"意大利\",\"v\":\"意大利\"},{\"n\":\"西班牙\",\"v\":\"西班牙\"},{\"n\":\"加拿大\",\"v\":\"加拿大\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":11,\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"}]},{\"key\":4,\"name\":\"语言\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"国语\",\"v\":\"国语\"},{\"n\":\"英语\",\"v\":\"英语\"},{\"n\":\"粤语\",\"v\":\"粤语\"},{\"n\":\"闽南语\",\"v\":\"闽南语\"},{\"n\":\"韩语\",\"v\":\"韩语\"},{\"n\":\"日语\",\"v\":\"日语\"},{\"n\":\"法语\",\"v\":\"法语\"},{\"n\":\"德语\",\"v\":\"德语\"},{\"n\":\"其它\",\"v\":\"其它\"}]},{\"key\":5,\"name\":\"字母\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"A\",\"v\":\"A\"},{\"n\":\"B\",\"v\":\"B\"},{\"n\":\"C\",\"v\":\"C\"},{\"n\":\"D\",\"v\":\"D\"},{\"n\":\"E\",\"v\":\"E\"},{\"n\":\"F\",\"v\":\"F\"},{\"n\":\"G\",\"v\":\"G\"},{\"n\":\"H\",\"v\":\"H\"},{\"n\":\"I\",\"v\":\"I\"},{\"n\":\"J\",\"v\":\"J\"},{\"n\":\"K\",\"v\":\"K\"},{\"n\":\"L\",\"v\":\"L\"},{\"n\":\"M\",\"v\":\"M\"},{\"n\":\"N\",\"v\":\"N\"},{\"n\":\"O\",\"v\":\"O\"},{\"n\":\"P\",\"v\":\"P\"},{\"n\":\"Q\",\"v\":\"Q\"},{\"n\":\"R\",\"v\":\"R\"},{\"n\":\"S\",\"v\":\"S\"},{\"n\":\"T\",\"v\":\"T\"},{\"n\":\"U\",\"v\":\"U\"},{\"n\":\"V\",\"v\":\"V\"},{\"n\":\"W\",\"v\":\"W\"},{\"n\":\"X\",\"v\":\"X\"},{\"n\":\"Y\",\"v\":\"Y\"},{\"n\":\"Z\",\"v\":\"Z\"},{\"n\":\"0-9\",\"v\":\"0-9\"}]},{\"key\":2,\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"time\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"4\":[{\"key\":0,\"name\":\"分类\",\"value\":[{\"n\":\"全部\",\"v\":\"4\"},{\"n\":\"动画电影\",\"v\":\"41\"}]},{\"key\":3,\"name\":\"剧情\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"情感\",\"v\":\"情感\"},{\"n\":\"科幻\",\"v\":\"科幻\"},{\"n\":\"热血\",\"v\":\"热血\"},{\"n\":\"推理\",\"v\":\"推理\"},{\"n\":\"搞笑\",\"v\":\"搞笑\"},{\"n\":\"冒险\",\"v\":\"冒险\"},{\"n\":\"萝莉\",\"v\":\"萝莉\"},{\"n\":\"校园\",\"v\":\"校园\"},{\"n\":\"动作\",\"v\":\"动作\"},{\"n\":\"机战\",\"v\":\"机战\"},{\"n\":\"运动\",\"v\":\"运动\"},{\"n\":\"战争\",\"v\":\"战争\"},{\"n\":\"少年\",\"v\":\"少年\"},{\"n\":\"少女\",\"v\":\"少女\"},{\"n\":\"社会\",\"v\":\"社会\"},{\"n\":\"原创\",\"v\":\"原创\"},{\"n\":\"亲子\",\"v\":\"亲子\"},{\"n\":\"益智\",\"v\":\"益智\"},{\"n\":\"励志\",\"v\":\"励志\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":1,\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"大陆\",\"v\":\"大陆\"},{\"n\":\"韩国\",\"v\":\"韩国\"},{\"n\":\"中国香港\",\"v\":\"中国香港\"},{\"n\":\"中国台湾\",\"v\":\"中国台湾\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"美国\",\"v\":\"美国\"},{\"n\":\"泰国\",\"v\":\"泰国\"},{\"n\":\"英国\",\"v\":\"英国\"},{\"n\":\"新加坡\",\"v\":\"新加坡\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":11,\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"}]},{\"key\":4,\"name\":\"语言\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"国语\",\"v\":\"国语\"},{\"n\":\"英语\",\"v\":\"英语\"},{\"n\":\"粤语\",\"v\":\"粤语\"},{\"n\":\"闽南语\",\"v\":\"闽南语\"},{\"n\":\"韩语\",\"v\":\"韩语\"},{\"n\":\"日语\",\"v\":\"日语\"},{\"n\":\"其它\",\"v\":\"其它\"}]},{\"key\":5,\"name\":\"字母\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"A\",\"v\":\"A\"},{\"n\":\"B\",\"v\":\"B\"},{\"n\":\"C\",\"v\":\"C\"},{\"n\":\"D\",\"v\":\"D\"},{\"n\":\"E\",\"v\":\"E\"},{\"n\":\"F\",\"v\":\"F\"},{\"n\":\"G\",\"v\":\"G\"},{\"n\":\"H\",\"v\":\"H\"},{\"n\":\"I\",\"v\":\"I\"},{\"n\":\"J\",\"v\":\"J\"},{\"n\":\"K\",\"v\":\"K\"},{\"n\":\"L\",\"v\":\"L\"},{\"n\":\"M\",\"v\":\"M\"},{\"n\":\"N\",\"v\":\"N\"},{\"n\":\"O\",\"v\":\"O\"},{\"n\":\"P\",\"v\":\"P\"},{\"n\":\"Q\",\"v\":\"Q\"},{\"n\":\"R\",\"v\":\"R\"},{\"n\":\"S\",\"v\":\"S\"},{\"n\":\"T\",\"v\":\"T\"},{\"n\":\"U\",\"v\":\"U\"},{\"n\":\"V\",\"v\":\"V\"},{\"n\":\"W\",\"v\":\"W\"},{\"n\":\"X\",\"v\":\"X\"},{\"n\":\"Y\",\"v\":\"Y\"},{\"n\":\"Z\",\"v\":\"Z\"},{\"n\":\"0-9\",\"v\":\"0-9\"}]},{\"key\":2,\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"time\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"3\":[{\"key\":1,\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"中国大陆\",\"v\":\"中国大陆\"},{\"n\":\"韩国\",\"v\":\"韩国\"}]},{\"key\":11,\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"},{\"n\":\"2009\",\"v\":\"2009\"},{\"n\":\"2008\",\"v\":\"2008\"},{\"n\":\"2007\",\"v\":\"2007\"},{\"n\":\"2006\",\"v\":\"2006\"},{\"n\":\"2005\",\"v\":\"2005\"},{\"n\":\"2004\",\"v\":\"2004\"}]},{\"key\":4,\"name\":\"语言\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"国语\",\"v\":\"国语\"},{\"n\":\"英语\",\"v\":\"英语\"},{\"n\":\"粤语\",\"v\":\"粤语\"},{\"n\":\"闽南语\",\"v\":\"闽南语\"},{\"n\":\"韩语\",\"v\":\"韩语\"},{\"n\":\"日语\",\"v\":\"日语\"},{\"n\":\"其它\",\"v\":\"其它\"}]},{\"key\":5,\"name\":\"字母\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"A\",\"v\":\"A\"},{\"n\":\"B\",\"v\":\"B\"},{\"n\":\"C\",\"v\":\"C\"},{\"n\":\"D\",\"v\":\"D\"},{\"n\":\"E\",\"v\":\"E\"},{\"n\":\"F\",\"v\":\"F\"},{\"n\":\"G\",\"v\":\"G\"},{\"n\":\"H\",\"v\":\"H\"},{\"n\":\"I\",\"v\":\"I\"},{\"n\":\"J\",\"v\":\"J\"},{\"n\":\"K\",\"v\":\"K\"},{\"n\":\"L\",\"v\":\"L\"},{\"n\":\"M\",\"v\":\"M\"},{\"n\":\"N\",\"v\":\"N\"},{\"n\":\"O\",\"v\":\"O\"},{\"n\":\"P\",\"v\":\"P\"},{\"n\":\"Q\",\"v\":\"Q\"},{\"n\":\"R\",\"v\":\"R\"},{\"n\":\"S\",\"v\":\"S\"},{\"n\":\"T\",\"v\":\"T\"},{\"n\":\"U\",\"v\":\"U\"},{\"n\":\"V\",\"v\":\"V\"},{\"n\":\"W\",\"v\":\"W\"},{\"n\":\"X\",\"v\":\"X\"},{\"n\":\"Y\",\"v\":\"Y\"},{\"n\":\"Z\",\"v\":\"Z\"},{\"n\":\"0-9\",\"v\":\"0-9\"}]},{\"key\":2,\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"time\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}]}");
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- }
-
- /**
- * 爬虫headers
- *
- * @param url
- * @return
- */
- protected HashMap getHeaders(String url) {
- HashMap headers = new HashMap<>();
- headers.put("method", "GET");
- headers.put("Host", siteHost);
- headers.put("Upgrade-Insecure-Requests", "1");
- headers.put("DNT", "1");
- headers.put("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36");
- headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
- headers.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
- return headers;
- }
-
- /**
- * 获取分类数据 + 首页最近更新视频列表数据
- *
- * @param filter 是否开启筛选 关联的是 软件设置中 首页数据源里的筛选开关
- * @return
- */
- @Override
- public String homeContent(boolean filter) {
- try {
- Document doc = Jsoup.parse(OkHttpUtil.string(siteUrl, getHeaders(siteUrl)));
- // 分类节点
- Elements elements = doc.select("ul.myui-header__menu>li.hidden-sm a");
- JSONArray classes = new JSONArray();
- for (Element ele : elements) {
- String name = ele.text();
- boolean show = name.equals("抖音电影") ||
- name.equals("电视剧") ||
- name.equals("电影") ||
- name.equals("动漫") ||
- name.equals("综艺");
- if (show) {
- Matcher mather = regexCategory.matcher(ele.attr("href"));
- if (!mather.find())
- continue;
- // 把分类的id和名称取出来加到列表里
- String id = mather.group(1).trim();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("type_id", id);
- jsonObject.put("type_name", name);
- classes.put(jsonObject);
- }
- }
- JSONObject result = new JSONObject();
- if (filter) {
- result.put("filters", filterConfig);
- }
- result.put("class", classes);
- try {
- // 取首页推荐视频列表
- Element homeList = doc.select("ul.myui-vodlist").get(0);
- Elements list = homeList.select("div.myui-vodlist__box>a");
- JSONArray videos = new JSONArray();
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.attr("title");
- String cover = vod.attr("data-original");
- String remark = vod.selectFirst("span.pic-tag>span").text();
- Matcher matcher = regexVid.matcher(vod.attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- result.put("list", videos);
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 获取分类信息数据
- *
- * @param tid 分类id
- * @param pg 页数
- * @param filter 同homeContent方法中的filter
- * @param extend 筛选参数{k:v, k1:v1}
- * @return
- */
- @Override
- public String categoryContent(String tid, String pg, boolean filter, HashMap extend) {
- try {
- String[] urlParams = new String[]{"", "", "", "", "", "", "", "", "", "", "", ""};
- urlParams[0] = tid;
- urlParams[8] = pg;
- if (extend != null && extend.size() > 0) {
- for (Iterator it = extend.keySet().iterator(); it.hasNext(); ) {
- String key = it.next();
- String value = extend.get(key);
- urlParams[Integer.parseInt(key)] = URLEncoder.encode(value);
- }
- }
- // 获取分类数据的url
- String url = siteUrl + "/vodshow/" + TextUtils.join("-", urlParams) + ".html";
- String html = OkHttpUtil.string(url, getHeaders(url));
- Document doc = Jsoup.parse(html);
- JSONObject result = new JSONObject();
- int pageCount = 0;
- int page = -1;
-
- // 取页码相关信息
- Elements pageInfo = doc.select("ul.myui-page>li");
- if (pageInfo.size() == 0) {
- page = Integer.parseInt(pg);
- pageCount = page;
- } else {
- for (int i = 0; i < pageInfo.size(); i++) {
- Element li = pageInfo.get(i);
- Element a = li.selectFirst("a");
- if (a == null)
- continue;
- String name = a.text();
- if (page == -1 && a.hasClass("btn-warm")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- page = Integer.parseInt(matcher.group(1).split("-")[8]);
- } else {
- page = 0;
- }
- }
- if (name.equals("尾页")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- pageCount = Integer.parseInt(matcher.group(1).split("-")[8]);
- } else {
- pageCount = 0;
- }
- break;
- }
- }
- }
-
- JSONArray videos = new JSONArray();
- if (!html.contains("没有找到您想要的结果哦")) {
- // 取当前分类页的视频列表
- Elements list = doc.select("ul.myui-vodlist>li>div>a");
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.attr("title");
- String cover = vod.attr("data-original");
- String remark = vod.selectFirst("span.pic-tag>span").text();
- Matcher matcher = regexVid.matcher(vod.attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- }
- result.put("page", page);
- result.put("pagecount", pageCount);
- result.put("limit", 48);
- result.put("total", pageCount <= 1 ? videos.length() : pageCount * 48);
-
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 视频详情信息
- *
- * @param ids 视频id
- * @return
- */
- @Override
- public String detailContent(List ids) {
- try {
- // 视频详情url
- String url = siteUrl + "/voddetail/" + ids.get(0) + ".html";
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- JSONObject result = new JSONObject();
- JSONObject vodList = new JSONObject();
-
- // 取基本数据
- Elements sourcediv = doc.select("div.myui-panel-box>div");
- String cover = sourcediv.get(1).select("div.myui-content__thumb>a>img").attr("data-original");
- String title = sourcediv.get(1).select("div.myui-content__thumb>a").attr("title");
- String category = "", area = "", year = "", remark = "", director = "", actor = "", desc = "";
- Elements data = doc.select("p.data");
- category = data.get(0).select("a").get(0).text();
- area = data.get(0).select("a").get(1).text();
- year = data.get(0).select("a").get(2).text();
- remark = data.get(1).select("span").get(1).text();
- List actors = new ArrayList<>();
- Elements aa = data.get(2).select("a");
- for (int j = 0; j < aa.size(); j++) {
- actors.add(aa.get(j).text());
- }
- actor = TextUtils.join(",", actors);
- List directors = new ArrayList<>();
- Elements bb = data.get(3).select("a");
- for (int j = 0; j < bb.size(); j++) {
- directors.add(bb.get(j).text());
- }
- director = TextUtils.join(",", directors);
- desc = doc.selectFirst("div.col-pd>span.data>p").text().trim();
-
- vodList.put("vod_id", ids.get(0));
- vodList.put("vod_name", title);
- vodList.put("vod_pic", cover);
- vodList.put("type_name", category);
- vodList.put("vod_year", year);
- vodList.put("vod_area", area);
- vodList.put("vod_remarks", remark);
- vodList.put("vod_actor", actor);
- vodList.put("vod_director", director);
- vodList.put("vod_content", desc);
-
- Map vod_play = new TreeMap<>(new Comparator() {
- @Override
- public int compare(String o1, String o2) {
- try {
- int sort1 = playerConfig.getJSONObject(o1).getInt("or");
- int sort2 = playerConfig.getJSONObject(o2).getInt("or");
-
- if (sort1 == sort2) {
- return 1;
- }
- return sort1 - sort2 > 0 ? 1 : -1;
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- return 1;
- }
- });
-
- // 取播放列表数据
- Elements sources = doc.select("div.myui-panel__head>ul").get(0).select("li");
- Elements sourceList = doc.select("div.tab-content>div.tab-pane");
-
- for (int i = 0; i < sources.size(); i++) {
- Element source = sources.get(i);
- String sourceName = source.text();
- boolean found = false;
- for (Iterator it = playerConfig.keys(); it.hasNext(); ) {
- String flag = it.next();
- if (playerConfig.getJSONObject(flag).getString("sh").equals(sourceName)) {
- sourceName = flag;
- found = true;
- break;
- }
- }
- if (!found)
- continue;
- String playList = "";
- Elements playListA = sourceList.get(i).select("ul>li>a");
- List vodItems = new ArrayList<>();
-
- for (int j = 0; j < playListA.size(); j++) {
- Element vod = playListA.get(j);
- Matcher matcher = regexPlay.matcher(vod.attr("href"));
- if (!matcher.find())
- continue;
- String playURL = matcher.group(1) + "-" + matcher.group(2) + "-" + matcher.group(3);
- vodItems.add(vod.text() + "$" + playURL);
- }
- if (vodItems.size() > 0)
- playList = TextUtils.join("#", vodItems);
-
- if (playList.length() == 0)
- continue;
-
- vod_play.put(sourceName, playList);
- }
-
- if (vod_play.size() > 0) {
- String vod_play_from = TextUtils.join("$$$", vod_play.keySet());
- String vod_play_url = TextUtils.join("$$$", vod_play.values());
- vodList.put("vod_play_from", vod_play_from);
- vodList.put("vod_play_url", vod_play_url);
- }
- JSONArray list = new JSONArray();
- list.put(vodList);
- result.put("list", list);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 获取视频播放信息
- *
- * @param flag 播放源
- * @param id 视频id
- * @param vipFlags 所有可能需要vip解析的源
- * @return
- */
- @Override
- public String playerContent(String flag, String id, List vipFlags) {
- try {
- //定义播放用的headers
- JSONObject headers = new JSONObject();
- //headers.put("Host", " cokemv.co");
- headers.put("origin", " https://cokemv.me");
- headers.put("User-Agent", " Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36");
- headers.put("Accept", " */*");
- headers.put("Accept-Language", " zh-CN,zh;q=0.9,en-US;q=0.3,en;q=0.7");
- headers.put("Accept-Encoding", " gzip, deflate");
-
-
- // 播放页 url
- String url = siteUrl + "/vodplay/" + id + ".html";
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- Elements allScript = doc.select("script");
- JSONObject result = new JSONObject();
- for (int i = 0; i < allScript.size(); i++) {
- String scContent = allScript.get(i).html().trim();
- if (scContent.startsWith("var player_")) { // 取直链
- int start = scContent.indexOf('{');
- int end = scContent.lastIndexOf('}') + 1;
- String json = scContent.substring(start, end);
- JSONObject player = new JSONObject(json);
- if (playerConfig.has(player.getString("from"))) {
- JSONObject pCfg = playerConfig.getJSONObject(player.getString("from"));
- String videoUrl = player.getString("url");
- String playUrl = pCfg.getString("pu");
- result.put("parse", pCfg.getInt("sn"));
- result.put("playUrl", playUrl);
- result.put("url", videoUrl);
- result.put("header", headers.toString());
- }
- break;
- }
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 搜索
- * 搜索有验证码,暂时不会处理
- *
- * @param key
- * @param quick 是否播放页的快捷搜索
- * @return
- */
-// @Override
-// public String searchContent(String key, boolean quick) {
-// try {
-// if (quick)
-// return "";
-// String url = siteUrl + "/vodsearch/-------------.html?wd=" + URLEncoder.encode(key) + "&submit=";
-// Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
-// JSONObject result = new JSONObject();
-//
-// JSONArray videos = new JSONArray();
-// Elements list = doc.selectFirst("ul.myui-vodlist__media").select("li>a");
-// for (int i = 0; i < list.size(); i++) {
-// Element vod = list.get(i);
-// String title = vod.attr("title");
-// String cover = vod.attr("data-original");
-// String remark = vod.selectFirst("span.pic-tag").text();
-// Matcher matcher = regexVid.matcher(vod.attr("href"));
-// if (!matcher.find())
-// continue;
-// String id = matcher.group(1);
-// JSONObject v = new JSONObject();
-// v.put("vod_id", id);
-// v.put("vod_name", title);
-// v.put("vod_pic", cover);
-// v.put("vod_remarks", remark);
-// videos.put(v);
-// }
-//
-// result.put("list", videos);
-// return result.toString();
-// } catch (Exception e) {
-// SpiderDebug.log(e);
-// }
-// return "";
-// }
-//}
- @Override
- public String searchContent(String key, boolean quick) {
- try {
- if (quick)
- return "";
- long currentTime = System.currentTimeMillis();
- String url = siteUrl + "/index.php/ajax/suggest?mid=1&wd=" + URLEncoder.encode(key) + "&limit=10×tamp=" + currentTime;
- JSONObject searchResult = new JSONObject(OkHttpUtil.string(url, getHeaders(url)));
- JSONObject result = new JSONObject();
- JSONArray videos = new JSONArray();
- if (searchResult.getInt("total") > 0) {
- JSONArray lists = new JSONArray(searchResult.getString("list"));
- for (int i = 0; i < lists.length(); i++) {
- JSONObject vod = lists.getJSONObject(i);
- String id = vod.getString("id");
- String title = vod.getString("name");
- String cover = vod.getString("pic");
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", "");
- videos.put(v);
- }
- }
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-}
diff --git a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Enlienli.java b/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Enlienli.java
deleted file mode 100644
index a273cd4..0000000
--- a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Enlienli.java
+++ /dev/null
@@ -1,252 +0,0 @@
-package com.github.catvod.spider;
-
-import android.content.Context;
-
-import com.github.catvod.crawler.Spider;
-import com.github.catvod.crawler.SpiderDebug;
-import com.github.catvod.utils.okhttp.OkHttpUtil;
-
-import org.json.JSONArray;
-import org.json.JSONObject;
-
-import java.net.URLEncoder;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Set;
-
-/**
- * 嗯哩嗯哩
- *
- * Author: 群友 不负此生
- */
-public class Enlienli extends Spider {
-
- private String siteUrl = "https://api.app.kongbuya.com";
-
- @Override
- public void init(Context context) {
- super.init(context);
- }
-
- private HashMap getHeaders(String url) {
- HashMap headers = new HashMap<>();
- headers.put("Connection", "Keep-Alive");
- headers.put("User-Agent", "okhttp/4.0.1");
- return headers;
- }
-
- @Override
- public String homeContent(boolean filter) {
- try {
- JSONArray jsonArray = new JSONArray(OkHttpUtil.string(siteUrl + "/api.php/provide/home_nav?", getHeaders(siteUrl)));
- JSONArray classes = new JSONArray();
- JSONObject filterConfig = new JSONObject();
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject jObj = jsonArray.getJSONObject(i);
- String typeName = jObj.getString("name");
- String typeId = jObj.getString("id");
- if (typeName.equals("推荐")) {
- continue;
- }
- JSONObject newCls = new JSONObject();
- newCls.put("type_id", typeId);
- newCls.put("type_name", typeName);
- classes.put(newCls);
- try {
- JSONArray typeExtend = jObj.getJSONArray("msg");
- JSONArray extendsAll = new JSONArray();
- for (int j = 0; j < typeExtend.length(); j++) {
- JSONObject typeExtendObj = typeExtend.getJSONObject(j);
- String typeExtendKey = typeExtendObj.getString("name");
- JSONArray newTypeExtendKeys = typeExtendObj.getJSONArray("data");
- if (newTypeExtendKeys.length() <= 1)
- continue;
- String typeExtendName = newTypeExtendKeys.getString(0);
- JSONObject newTypeExtend = new JSONObject();
- newTypeExtend.put("key", typeExtendKey);
- newTypeExtend.put("name", typeExtendName);
- JSONArray newTypeExtendKV = new JSONArray();
- {
- JSONObject kvAll = new JSONObject();
- kvAll.put("n", "全部");
- kvAll.put("v", "");
- newTypeExtendKV.put(kvAll);
- }
- for (int k = 1; k < newTypeExtendKeys.length(); k++) {
- JSONObject kv = new JSONObject();
- kv.put("n", newTypeExtendKeys.getString(k));
- kv.put("v", newTypeExtendKeys.getString(k));
- newTypeExtendKV.put(kv);
- }
- newTypeExtend.put("value", newTypeExtendKV);
- extendsAll.put(newTypeExtend);
- }
- filterConfig.put(typeId, extendsAll);
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
-
- }
- JSONObject result = new JSONObject();
- result.put("class", classes);
- if (filter) {
- result.put("filters", filterConfig);
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- @Override
- public String homeVideoContent() {
- try {
- String url = siteUrl + "/api.php/provide/home_data?page=1&id=0";
- JSONObject jsonObject = new JSONObject(OkHttpUtil.string(url, getHeaders(url)));
- JSONArray jsonArray = new JSONArray();
- if (jsonObject.has("tv")) {
- JSONArray data = jsonObject.getJSONObject("tv").getJSONArray("data");
- for (int i = 0; i < data.length(); i++) {
- jsonArray.put(data.getJSONObject(i));
- }
- }
-
- if (jsonObject.has("video")) {
- JSONArray vs = jsonObject.getJSONArray("video");
- for (int i = 0; i < vs.length(); i++) {
- JSONArray data = vs.getJSONObject(i).getJSONArray("data");
- for (int j = 0; j < data.length(); j++) {
- jsonArray.put(data.getJSONObject(j));
- }
- }
- }
-
- JSONArray videos = new JSONArray();
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject vObj = jsonArray.getJSONObject(i);
- JSONObject v = new JSONObject();
- v.put("vod_id", vObj.getString("id"));
- v.put("vod_name", vObj.getString("name"));
- v.put("vod_pic", vObj.getString("img"));
- v.put("vod_remarks", vObj.getString("qingxidu"));
- videos.put(v);
- }
- JSONObject result = new JSONObject();
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- @Override
- public String categoryContent(String tid, String pg, boolean filter, HashMap extend) {
- try {
- String url = siteUrl + "/api.php/provide/vod_list?page=" + pg + "&id=" + tid;
- Set keys = extend.keySet();
- for (String key : keys) {
- url += "&" + key + "=" + URLEncoder.encode(extend.get(key));
- }
- JSONArray jsonArray = new JSONArray(OkHttpUtil.string(url, getHeaders(url)));
- JSONArray videos = new JSONArray();
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject vObj = jsonArray.getJSONObject(i);
- JSONObject v = new JSONObject();
- v.put("vod_id", vObj.getString("id"));
- v.put("vod_name", vObj.getString("name"));
- v.put("vod_pic", vObj.getString("img"));
- v.put("vod_remarks", vObj.getString("qingxidu"));
- videos.put(v);
- }
- JSONObject result = new JSONObject();
- int limit = 20;
- int page = Integer.parseInt(pg);
- int total = Integer.MAX_VALUE;
- int pageCount = videos.length() < 20 ? page : page + 1;
- result.put("page", page);
- result.put("pagecount", pageCount);
- result.put("limit", limit);
- result.put("total", total);
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- @Override
- public String detailContent(List ids) {
- try {
- String url = siteUrl + "/api.php/provide/vod_detail?token=&id=" + ids.get(0) + "&ac=vod_detail";
- JSONObject jsonObject = new JSONObject(OkHttpUtil.string(url, getHeaders(url)));
- JSONObject vodList = new JSONObject();
- vodList.put("vod_id", ids.get(0));
- vodList.put("vod_name", jsonObject.getString("name"));
- vodList.put("vod_pic", jsonObject.getString("img"));
- vodList.put("type_name", jsonObject.getString("type"));
- vodList.put("vod_year", "");
- vodList.put("vod_area", "");
- vodList.put("vod_remarks", jsonObject.getString("remarks"));
- vodList.put("vod_actor", jsonObject.getString("actor"));
- vodList.put("vod_director", jsonObject.getString("director"));
- vodList.put("vod_content", jsonObject.getString("info"));
-
- vodList.put("vod_play_from", jsonObject.getString("playcode"));
- vodList.put("vod_play_url", jsonObject.getString("playlist"));
-
- JSONObject result = new JSONObject();
- JSONArray list = new JSONArray();
- list.put(vodList);
- result.put("list", list);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
-
- @Override
- public String playerContent(String flag, String id, List vipFlags) {
- try {
- JSONObject result = new JSONObject();
- result.put("parse", 0);
- result.put("playUrl", "");
- result.put("url", id);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- @Override
- public String searchContent(String key, boolean quick) {
- if (quick)
- return "";
- try {
- String url = siteUrl + "/api.php/provide/search_result?video_name=" + URLEncoder.encode(key);
- JSONObject jsonObject = new JSONObject(OkHttpUtil.string(url, getHeaders(url)));
- JSONArray jsonArray = jsonObject.getJSONObject("result").getJSONArray("search_result");
- JSONArray videos = new JSONArray();
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject vObj = jsonArray.getJSONObject(i);
- JSONObject v = new JSONObject();
- v.put("vod_id", vObj.getString("id"));
- v.put("vod_name", vObj.getString("video_name"));
- v.put("vod_pic", vObj.getString("img"));
- //v.put("vod_remarks", vObj.getString(""));
- videos.put(v);
- }
- JSONObject result = new JSONObject();
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-}
diff --git a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Imaple.java b/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Imaple.java
deleted file mode 100644
index 7779054..0000000
--- a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Imaple.java
+++ /dev/null
@@ -1,465 +0,0 @@
-package com.github.catvod.spider;
-
-import android.content.Context;
-import android.text.TextUtils;
-
-import com.github.catvod.crawler.Spider;
-import com.github.catvod.crawler.SpiderDebug;
-import com.github.catvod.utils.okhttp.OkHttpUtil;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
-
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Demo for self study
- *
- * Source from Author: CatVod
- */
-
-public class Imaple extends Spider {
-
- private static final String siteUrl = "https://imaple.co/";
- private static final String siteHost = "imaple.co";
-
- protected JSONObject playerConfig;
- protected JSONObject filterConfig;
-
- protected Pattern regexCategory = Pattern.compile("/type/(\\S+).html");
- protected Pattern regexVid = Pattern.compile("/vod/(\\d+).html");
- protected Pattern regexPlay = Pattern.compile("/play/(\\d+)-(\\d+)-(\\d+).html");
- protected Pattern regexPage = Pattern.compile("\\S+/page/(\\d+)\\S+");
-
- @Override
- public void init(Context context) {
- super.init(context);
- try {
- playerConfig = new JSONObject("{\"kbm3u8\":{\"sh\":\"秒播雲\",\"sn\":0,\"pu\":\"\",\"or\":999},\"bjm3u8\":{\"sh\":\"八戒雲\",\"sn\":0,\"pu\":\"\",\"or\":999},\"605m3u8\":{\"sh\":\"光速雲\",\"sn\":0,\"pu\":\"\",\"or\":999},\"mlm3u8\":{\"sh\":\"藍光線一\",\"sn\":0,\"pu\":\"\",\"or\":999},\"alizy\":{\"sh\":\"藍光線三\",\"sn\":1,\"pu\":\"https://player.imaple.tv/player/?url=\",\"or\":999},\"dplayer\":{\"sh\":\"動漫專線\",\"sn\":1,\"pu\":\"https://player.imaple.tv/player/?url=\",\"or\":999},\"qdyun\":{\"sh\":\"驱动云\",\"sn\":0,\"pu\":\"\",\"or\":999},\"wjm3u8\":{\"sh\":\"理想雲\",\"sn\":0,\"pu\":\"\",\"or\":999},\"fanqie\":{\"sh\":\"番茄资源\",\"sn\":1,\"pu\":\"https://player.imaple.tv/player/?url=\",\"or\":999},\"youku\":{\"sh\":\"奇藝雲\",\"sn\":1,\"pu\":\"https://player.imaple.tv/player/?url=\",\"or\":999},\"qq\":{\"sh\":\"騰訊雲\",\"sn\":1,\"pu\":\"https://player.imaple.tv/player/?url=\",\"or\":999},\"mgtv\":{\"sh\":\"芒果雲\",\"sn\":1,\"pu\":\"https://player.imaple.tv/player/?url=\",\"or\":999},\"sohu\":{\"sh\":\"搜狐雲\",\"sn\":1,\"pu\":\"https://player.imaple.tv/player/?url=\",\"or\":999},\"88zym3u8\":{\"sh\":\"優雅雲\",\"sn\":1,\"pu\":\"https://player.imaple.tv/player/?url=\",\"or\":999},\"bilibili\":{\"sh\":\"嗶哩雲\",\"sn\":1,\"pu\":\"https://player.imaple.tv/player/?url=\",\"or\":999},\"dbm3u8\":{\"sh\":\"急速雲\",\"sn\":0,\"pu\":\"\",\"or\":999},\"tkm3u8\":{\"sh\":\"天空雲\",\"sn\":0,\"pu\":\"\",\"or\":999}}");
- filterConfig = new JSONObject("{\"1\":[{\"key\":\"tid\",\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"動作片\",\"v\":\"6\"},{\"n\":\"喜劇片\",\"v\":\"7\"},{\"n\":\"愛情片\",\"v\":\"8\"},{\"n\":\"科幻片\",\"v\":\"9\"},{\"n\":\"恐怖片\",\"v\":\"10\"},{\"n\":\"劇情片\",\"v\":\"11\"},{\"n\":\"戰爭片\",\"v\":\"12\"},{\"n\":\"紀錄片\",\"v\":\"20\"}]},{\"key\":\"area\",\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"大陸\",\"v\":\"大陸\"},{\"n\":\"香港\",\"v\":\"香港\"},{\"n\":\"台灣\",\"v\":\"台灣\"},{\"n\":\"美國\",\"v\":\"美國\"},{\"n\":\"法國\",\"v\":\"法國\"},{\"n\":\"英國\",\"v\":\"英國\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"韓國\",\"v\":\"韓國\"},{\"n\":\"德國\",\"v\":\"德國\"},{\"n\":\"泰國\",\"v\":\"泰國\"},{\"n\":\"印度\",\"v\":\"印度\"},{\"n\":\"意大利\",\"v\":\"意大利\"},{\"n\":\"西班牙\",\"v\":\"西班牙\"},{\"n\":\"加拿大\",\"v\":\"加拿大\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":\"year\",\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"}]},{\"key\":\"by\",\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"2\":[{\"key\":\"tid\",\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"大陸劇\",\"v\":\"13\"},{\"n\":\"港劇\",\"v\":\"14\"},{\"n\":\"台劇\",\"v\":\"15\"},{\"n\":\"日劇\",\"v\":\"16\"},{\"n\":\"韓劇\",\"v\":\"23\"},{\"n\":\"美劇\",\"v\":\"24\"},{\"n\":\"海外劇\",\"v\":\"25\"}]},{\"key\":\"year\",\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"},{\"n\":\"2009\",\"v\":\"2009\"},{\"n\":\"2008\",\"v\":\"2008\"},{\"n\":\"2007\",\"v\":\"2007\"},{\"n\":\"2006\",\"v\":\"2006\"},{\"n\":\"2005\",\"v\":\"2005\"},{\"n\":\"2004\",\"v\":\"2004\"}]},{\"key\":\"by\",\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"3\":[{\"key\":\"tid\",\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"港台綜藝\",\"v\":\"29\"},{\"n\":\"日韓綜藝\",\"v\":\"30\"},{\"n\":\"大陸綜藝\",\"v\":\"31\"},{\"n\":\"歐美綜藝\",\"v\":\"32\"}]},{\"key\":\"year\",\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"},{\"n\":\"2009\",\"v\":\"2009\"},{\"n\":\"2008\",\"v\":\"2008\"},{\"n\":\"2007\",\"v\":\"2007\"},{\"n\":\"2006\",\"v\":\"2006\"},{\"n\":\"2005\",\"v\":\"2005\"},{\"n\":\"2004\",\"v\":\"2004\"}]},{\"key\":\"by\",\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"4\":[{\"key\":\"tid\",\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"港台動漫\",\"v\":\"33\"},{\"n\":\"日韓動漫\",\"v\":\"34\"},{\"n\":\"大陸動漫\",\"v\":\"35\"},{\"n\":\"歐美動漫\",\"v\":\"36\"},{\"n\":\"海外動漫\",\"v\":\"37\"}]},{\"key\":\"year\",\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"},{\"n\":\"2009\",\"v\":\"2009\"},{\"n\":\"2008\",\"v\":\"2008\"},{\"n\":\"2007\",\"v\":\"2007\"},{\"n\":\"2006\",\"v\":\"2006\"},{\"n\":\"2005\",\"v\":\"2005\"},{\"n\":\"2004\",\"v\":\"2004\"}]},{\"key\":\"by\",\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}]}");
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- }
-
- /**
- * 爬虫headers
- *
- * @param url
- * @return
- */
- protected HashMap getHeaders(String url) {
- HashMap headers = new HashMap<>();
- headers.put("method", "GET");
- headers.put("Host", siteHost);
- headers.put("Upgrade-Insecure-Requests", "1");
- headers.put("DNT", "1");
- headers.put("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36");
- headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
- headers.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
- return headers;
- }
-
- /**
- * 获取分类数据 + 首页最近更新视频列表数据
- *
- * @param filter 是否开启筛选 关联的是 软件设置中 首页数据源里的筛选开关
- * @return
- */
- @Override
- public String homeContent(boolean filter) {
- try {
- String url = siteUrl + '/';
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- Elements elements = doc.select("ul.myui-header__menu>li>a");
- JSONArray classes = new JSONArray();
- ArrayList allClass = new ArrayList<>();
- for (Element ele : elements) {
- String name = ele.text();
- boolean show = !filter || (name.equals("電影") || name.equals("電視劇") || name.equals("綜藝") || name.equals("動漫"));
- if (allClass.contains(name))
- show = false;
- if (show) {
- allClass.add(name);
- Matcher mather = regexCategory.matcher(ele.attr("href"));
- if (!mather.find())
- continue;
- // 把分类的id和名称取出来加到列表里
- String id = mather.group(1).trim();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("type_id", id);
- jsonObject.put("type_name", name);
- classes.put(jsonObject);
- }
- }
- JSONObject result = new JSONObject();
- if (filter) {
- result.put("filters", filterConfig);
- }
- result.put("class", classes);
- try {
- // 取首页推荐视频列表
- Elements list = doc.select("li.col-lg-6 >div.myui-vodlist__box");
- JSONArray videos = new JSONArray();
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.selectFirst(".title").text();
- String cover = vod.selectFirst(".myui-vodlist__thumb").attr("data-original");
- String remark = vod.selectFirst("span.pic-text").text();
-
- Matcher matcher = regexVid.matcher(vod.selectFirst(".myui-vodlist__thumb").attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- result.put("list", videos);
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
-
- /**
- * 获取分类信息数据
- *
- * @param tid 分类id
- * @param pg 页数
- * @param filter 同homeContent方法中的filter
- * @param extend 筛选参数{k:v, k1:v1}
- * @return
- */
- @Override
- public String categoryContent(String tid, String pg, boolean filter, HashMap extend) {
- try {
- String url = siteUrl + "/show/";
- if (extend != null && extend.size() > 0 && extend.containsKey("tid") && extend.get("tid").length() > 0) {
- url += extend.get("tid");
- } else {
- url += tid;
- }
- if (extend != null && extend.size() > 0) {
- for (Iterator it = extend.keySet().iterator(); it.hasNext(); ) {
- String key = it.next();
- String value = extend.get(key);
- if (value.length() > 0) {
- url += "/" + key + "/" + URLEncoder.encode(value);
- }
- }
- }
- url += "/page/" + pg + ".html";
- String html = OkHttpUtil.string(url, getHeaders(url));
- Document doc = Jsoup.parse(html);
- JSONObject result = new JSONObject();
- int pageCount = 0;
- int page = -1;
-
- // 取页码相关信息
- Elements pageInfo = doc.select(".myui-page li a");
- if (pageInfo.size() == 0) {
- page = Integer.parseInt(pg);
- pageCount = page;
- } else {
- for (int i = 0; i < pageInfo.size(); i++) {
- Element a = pageInfo.get(i);
- String name = a.text();
- if (page == -1 && a.hasClass("btn-warm")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- page = Integer.parseInt(matcher.group(1).trim());
- } else {
- page = 0;
- }
- }
- if (name.equals("尾頁")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- pageCount = Integer.parseInt(matcher.group(1).trim());
- } else {
- pageCount = 0;
- }
- break;
- }
- }
- }
-
- JSONArray videos = new JSONArray();
- if (!html.contains("没有找到您想要的结果哦")) {
- // 取当前分类页的视频列表
- Elements list = doc.select("li.col-lg-6 >div.myui-vodlist__box");
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.selectFirst(".title").text();
- String cover = vod.selectFirst(".myui-vodlist__thumb").attr("data-original");
- String remark = vod.selectFirst("span.pic-text").text();
-
- Matcher matcher = regexVid.matcher(vod.selectFirst(".myui-vodlist__thumb").attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- }
- result.put("page", page);
- result.put("pagecount", pageCount);
- result.put("limit", 48);
- result.put("total", pageCount <= 1 ? videos.length() : pageCount * 48);
-
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 视频详情信息
- *
- * @param ids 视频id
- * @return
- */
- @Override
- public String detailContent(List ids) {
- try {
- // 视频详情url
- String url = siteUrl + "/vod/" + ids.get(0) + ".html";
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- JSONObject result = new JSONObject();
- JSONObject vodList = new JSONObject();
-
- // 取基本数据
- String vid = doc.selectFirst("span.mac_hits").attr("data-id");
-
- String cover = doc.selectFirst("a.myui-vodlist__thumb img").attr("data-original");
- String title = doc.selectFirst("div.myui-content__detail h1.title").text();
- String desc = Jsoup.parse(doc.selectFirst("meta[name=description]").attr("content")).text();
- String category = "", area = "", year = "", remark = "", director = "", actor = "";
- Elements span_text_muted = doc.select("div.myui-content__detail span.text-muted");
- for (int i = 0; i < span_text_muted.size(); i++) {
- Element text = span_text_muted.get(i);
- String info = text.text();
- if (info.equals("分類:")) {
- category = text.nextElementSibling().text();
- } else if (info.equals("年份:")) {
- year = text.nextElementSibling().text();
- } else if (info.equals("地區:")) {
- area = text.nextElementSibling().text();
- } else if (info.equals("更新:")) {
- remark = text.nextElementSibling().text();
- } else if (info.equals("導演:")) {
- List directors = new ArrayList<>();
- Elements aa = text.parent().select("a");
- for (int j = 0; j < aa.size(); j++) {
- directors.add(aa.get(j).text());
- }
- director = TextUtils.join(",", directors);
- } else if (info.equals("主演:")) {
- List actors = new ArrayList<>();
- Elements aa = text.parent().select("a");
- for (int j = 0; j < aa.size(); j++) {
- actors.add(aa.get(j).text());
- }
- actor = TextUtils.join(",", actors);
- }
- }
-
- vodList.put("vod_id", vid);
- vodList.put("vod_name", title);
- vodList.put("vod_pic", cover);
- vodList.put("type_name", category);
- vodList.put("vod_year", year);
- vodList.put("vod_area", area);
- vodList.put("vod_remarks", remark);
- vodList.put("vod_actor", actor);
- vodList.put("vod_director", director);
- vodList.put("vod_content", desc);
-
- Map vod_play = new TreeMap<>(new Comparator() {
- @Override
- public int compare(String o1, String o2) {
- try {
- int sort1 = playerConfig.getJSONObject(o1).getInt("or");
- int sort2 = playerConfig.getJSONObject(o2).getInt("or");
-
- if (sort1 == sort2) {
- return 1;
- }
- return sort1 - sort2 > 0 ? 1 : -1;
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- return 1;
- }
- });
-
- // 取播放列表数据
- Elements sources = doc.select("div.myui-panel__head>ul").get(0).select("li");
- Elements sourceList = doc.select("div.tab-content>div.tab-pane");
-
- for (int i = 0; i < sources.size(); i++) {
- Element source = sources.get(i);
- String sourceName = source.text();
- boolean found = false;
- for (Iterator it = playerConfig.keys(); it.hasNext(); ) {
- String flag = it.next();
- if (playerConfig.getJSONObject(flag).getString("sh").equals(sourceName)) {
- sourceName = flag;
- found = true;
- break;
- }
- }
- if (!found)
- continue;
- String playList = "";
- Elements playListA = sourceList.get(i).select("ul>li>a");
- List vodItems = new ArrayList<>();
-
- for (int j = 0; j < playListA.size(); j++) {
- Element vod = playListA.get(j);
- Matcher matcher = regexPlay.matcher(vod.attr("href"));
- if (!matcher.find())
- continue;
- String playURL = matcher.group(1) + "-" + matcher.group(2) + "-" + matcher.group(3);
- vodItems.add(vod.text() + "$" + playURL);
- }
- if (vodItems.size() > 0)
- playList = TextUtils.join("#", vodItems);
-
- if (playList.length() == 0)
- continue;
-
- vod_play.put(sourceName, playList);
- }
-
- if (vod_play.size() > 0) {
- String vod_play_from = TextUtils.join("$$$", vod_play.keySet());
- String vod_play_url = TextUtils.join("$$$", vod_play.values());
- vodList.put("vod_play_from", vod_play_from);
- vodList.put("vod_play_url", vod_play_url);
- }
- JSONArray list = new JSONArray();
- list.put(vodList);
- result.put("list", list);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 获取视频播放信息
- *
- * @param flag 播放源
- * @param id 视频id
- * @param vipFlags 所有可能需要vip解析的源
- * @return
- */
- @Override
- public String playerContent(String flag, String id, List vipFlags) {
- try {
- //定义播放用的headers
- JSONObject headers = new JSONObject();
- //headers.put("Host", " cokemv.co");
- headers.put("origin", " https://imaple.co");
- headers.put("User-Agent", " Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36");
- headers.put("Accept", " */*");
- headers.put("Accept-Language", " zh-CN,zh;q=0.9,en-US;q=0.3,en;q=0.7");
- headers.put("Accept-Encoding", " gzip, deflate");
-
-
- // 播放页 url
- String url = siteUrl + "/play/" + id + ".html";
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- Elements allScript = doc.select("script");
- JSONObject result = new JSONObject();
- for (int i = 0; i < allScript.size(); i++) {
- String scContent = allScript.get(i).html().trim();
- if (scContent.startsWith("var player_")) { // 取直链
- int start = scContent.indexOf('{');
- int end = scContent.lastIndexOf('}') + 1;
- String json = scContent.substring(start, end);
- JSONObject player = new JSONObject(json);
- if (playerConfig.has(player.getString("from"))) {
- JSONObject pCfg = playerConfig.getJSONObject(player.getString("from"));
- String videoUrl = player.getString("url");
- String playUrl = pCfg.getString("pu");
- result.put("parse", pCfg.getInt("sn"));
- result.put("playUrl", playUrl);
- result.put("url", videoUrl);
- result.put("header", headers.toString());
- }
- break;
- }
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
-
- @Override
- public String searchContent(String key, boolean quick) {
- try {
- if (quick)
- return "";
- long currentTime = System.currentTimeMillis();
- String url = siteUrl + "/index.php/ajax/suggest?mid=1&wd=" + URLEncoder.encode(key) + "&limit=10×tamp=" + currentTime;
- JSONObject searchResult = new JSONObject(OkHttpUtil.string(url, getHeaders(url)));
- JSONObject result = new JSONObject();
- JSONArray videos = new JSONArray();
- if (searchResult.getInt("total") > 0) {
- JSONArray lists = new JSONArray(searchResult.getString("list"));
- for (int i = 0; i < lists.length(); i++) {
- JSONObject vod = lists.getJSONObject(i);
- String id = vod.getString("id");
- String title = vod.getString("name");
- String cover = vod.getString("pic");
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", "");
- videos.put(v);
- }
- }
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-}
diff --git a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Init.java b/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Init.java
deleted file mode 100644
index 2061c7b..0000000
--- a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Init.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.github.catvod.spider;
-
-import android.content.Context;
-
-import com.github.catvod.crawler.SpiderDebug;
-
-public class Init {
- public static void init(Context context) {
- SpiderDebug.log("自定义爬虫代码加载成功!");
- }
-}
diff --git a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Juhi.java b/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Juhi.java
deleted file mode 100644
index 8d33a94..0000000
--- a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Juhi.java
+++ /dev/null
@@ -1,472 +0,0 @@
-package com.github.catvod.spider;
-
-import android.content.Context;
-import android.text.TextUtils;
-
-import com.github.catvod.crawler.Spider;
-import com.github.catvod.crawler.SpiderDebug;
-import com.github.catvod.utils.Misc;
-import com.github.catvod.utils.okhttp.OkHttpUtil;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
-
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class Juhi extends Spider {
-
- private static final String siteUrl = "https://www.juhi.cc/";
- private static final String siteHost = "juhi.cc";
-
- protected JSONObject playerConfig;
- protected JSONObject filterConfig;
-
- protected Pattern regexCategory = Pattern.compile("/vodtype/(\\d+)/");
- protected Pattern regexVid = Pattern.compile("/voddetail/(\\d+)/");
- protected Pattern regexPlay = Pattern.compile("/vodplay/(\\d+)-(\\d+)-(\\d+)/");
- protected Pattern regexPage = Pattern.compile("/vodshow/(\\S+)/");
-
- @Override
- public void init(Context context) {
- super.init(context);
- try {
- playerConfig = new JSONObject("{\"tkm3u8\":{\"sh\":\"✦剧嗨专线\",\"pu\":\"https://jx.huishij.com/yun/?url=\",\"sn\":1,\"or\":999},\"if101\":{\"sh\":\"✦蓝光超清\",\"pu\":\"\",\"sn\":0,\"or\":999},\"dbm3u8\":{\"sh\":\"北美高清①\",\"pu\":\"\",\"sn\":0,\"or\":999},\"dbyun\":{\"sh\":\"北美高清②\",\"pu\":\"\",\"sn\":0,\"or\":999},\"wjm3u8\":{\"sh\":\"北美高清③\",\"pu\":\"\",\"sn\":0,\"or\":999},\"kbm3u8\":{\"sh\":\"全球线路①\",\"pu\":\"\",\"sn\":0,\"or\":999},\"hnyun\":{\"sh\":\"全球线路②\",\"pu\":\"\",\"sn\":0,\"or\":999},\"hnm3u8\":{\"sh\":\"全球线路③\",\"pu\":\"\",\"sn\":0,\"or\":999},\"kbzy\":{\"sh\":\"全球线路④\",\"pu\":\"\",\"sn\":0,\"or\":999},\"fanqie\":{\"sh\":\"全球线路⑤\",\"pu\":\"\",\"sn\":0,\"or\":999},\"kuaiyun\":{\"sh\":\"快速线路\",\"pu\":\"https://qimihe.com/?url=\",\"sn\":1,\"or\":999},\"leyum3u8\":{\"sh\":\"午夜专线1\",\"pu\":\"\",\"sn\":0,\"or\":999},\"lym3u8\":{\"sh\":\"午夜专线2\",\"pu\":\"\",\"sn\":0,\"or\":999},\"dplayer\":{\"sh\":\"DPlayer-H5播放器\",\"pu\":\"\",\"sn\":0,\"or\":999},\"videojs\":{\"sh\":\"videojs-H5播放器\",\"pu\":\"\",\"sn\":0,\"or\":999},\"iva\":{\"sh\":\"iva-H5播放器\",\"pu\":\"\",\"sn\":0,\"or\":999},\"iframe\":{\"sh\":\"iframe外链数据\",\"pu\":\"\",\"sn\":0,\"or\":999},\"link\":{\"sh\":\"外链数据\",\"pu\":\"\",\"sn\":0,\"or\":999},\"swf\":{\"sh\":\"Flash文件\",\"pu\":\"\",\"sn\":0,\"or\":999},\"flv\":{\"sh\":\"Flv文件\",\"pu\":\"\",\"sn\":0,\"or\":999},\"bjyun\":{\"sh\":\"bjyun\",\"pu\":\"\",\"sn\":0,\"or\":999},\"bjm3u8\":{\"sh\":\"bjm3u8\",\"pu\":\"\",\"sn\":0,\"or\":999},\"wasu\":{\"sh\":\"华数直连\",\"pu\":\"\",\"sn\":0,\"or\":999},\"funshion\":{\"sh\":\"风行直连\",\"pu\":\"\",\"sn\":0,\"or\":999},\"pptv\":{\"sh\":\"PPTV直连\",\"pu\":\"https://jx.m3u8.tv/jiexi/?url=\",\"sn\":1,\"or\":999},\"letv\":{\"sh\":\"乐视直连\",\"pu\":\"https://jx.m3u8.tv/jiexi/?url=\",\"sn\":1,\"or\":999},\"mgtv\":{\"sh\":\"芒果直连\",\"pu\":\"https://jx.m3u8.tv/jiexi/?url=\",\"sn\":1,\"or\":999},\"youku\":{\"sh\":\"优酷直连\",\"pu\":\"https://jx.m3u8.tv/jiexi/?url=\",\"sn\":1,\"or\":999},\"qiyi\":{\"sh\":\"爱奇艺直连\",\"pu\":\"https://jx.m3u8.tv/jiexi/?url=\",\"sn\":1,\"or\":999},\"qq\":{\"sh\":\"腾讯直连\",\"pu\":\"https://jx.m3u8.tv/jiexi/?url=\",\"sn\":1,\"or\":999},\"m1905\":{\"sh\":\"M1905直连\",\"pu\":\"https://jx.m3u8.tv/jiexi/?url=\",\"sn\":1,\"or\":999},\"sohu\":{\"sh\":\"搜狐直连\",\"pu\":\"https://jx.m3u8.tv/jiexi/?url=\",\"sn\":1,\"or\":999}}");
- filterConfig = new JSONObject("{\"20\":[{\"key\":\"0\",\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"20\"},{\"n\":\"动作片\",\"v\":\"24\"},{\"n\":\"喜剧片\",\"v\":\"25\"},{\"n\":\"愛情片\",\"v\":\"26\"},{\"n\":\"科幻片\",\"v\":\"27\"},{\"n\":\"恐怖片\",\"v\":\"28\"},{\"n\":\"劇情片\",\"v\":\"11\"},{\"n\":\"戰爭片\",\"v\":\"30\"},{\"n\":\"动画电影\",\"v\":\"33\"}]},{\"key\":1,\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"大陆\",\"v\":\"大陆\"},{\"n\":\"香港\",\"v\":\"香港\"},{\"n\":\"台湾\",\"v\":\"台湾\"},{\"n\":\"美国\",\"v\":\"美国\"},{\"n\":\"法国\",\"v\":\"法国\"},{\"n\":\"英国\",\"v\":\"英国\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"韩国\",\"v\":\"韩国\"},{\"n\":\"德国\",\"v\":\"德国\"},{\"n\":\"泰国\",\"v\":\"泰国\"},{\"n\":\"印度\",\"v\":\"印度\"},{\"n\":\"意大利\",\"v\":\"意大利\"},{\"n\":\"西班牙\",\"v\":\"西班牙\"},{\"n\":\"加拿大\",\"v\":\"加拿大\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":11,\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"}]},{\"key\":2,\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"time\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"21\":[{\"key\":\"tid\",\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"国产剧\",\"v\":\"34\"},{\"n\":\"港剧\",\"v\":\"35\"},{\"n\":\"韩剧\",\"v\":\"37\"},{\"n\":\"欧美剧\",\"v\":\"36\"},{\"n\":\"日本剧\",\"v\":\"38\"},{\"n\":\"台湾剧\",\"v\":\"39\"},{\"n\":\"海外剧\",\"v\":\"40\"}]},{\"key\":11,\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"},{\"n\":\"2009\",\"v\":\"2009\"},{\"n\":\"2008\",\"v\":\"2008\"},{\"n\":\"2007\",\"v\":\"2007\"},{\"n\":\"2006\",\"v\":\"2006\"},{\"n\":\"2005\",\"v\":\"2005\"},{\"n\":\"2004\",\"v\":\"2004\"}]},{\"key\":2,\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"time\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"22\":[{\"key\":0,\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"22\"},{\"n\":\"大陆综艺\",\"v\":\"41\"},{\"n\":\"港台综艺\",\"v\":\"42\"},{\"n\":\"日韩综艺\",\"v\":\"43\"},{\"n\":\"欧美综艺\",\"v\":\"44\"}]},{\"key\":11,\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"},{\"n\":\"2009\",\"v\":\"2009\"},{\"n\":\"2008\",\"v\":\"2008\"},{\"n\":\"2007\",\"v\":\"2007\"},{\"n\":\"2006\",\"v\":\"2006\"},{\"n\":\"2005\",\"v\":\"2005\"},{\"n\":\"2004\",\"v\":\"2004\"}]},{\"key\":2,\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"time\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"23\":[{\"key\":0,\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"23\"},{\"n\":\"国产动漫\",\"v\":\"45\"},{\"n\":\"日本动漫\",\"v\":\"46\"},{\"n\":\"欧美动漫\",\"v\":\"47\"}]},{\"key\":11,\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"},{\"n\":\"2009\",\"v\":\"2009\"},{\"n\":\"2008\",\"v\":\"2008\"},{\"n\":\"2007\",\"v\":\"2007\"},{\"n\":\"2006\",\"v\":\"2006\"},{\"n\":\"2005\",\"v\":\"2005\"},{\"n\":\"2004\",\"v\":\"2004\"}]},{\"key\":2,\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"time\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}]}");
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- }
-
- /**
- * 爬虫headers
- *
- * @param url
- * @return
- */
- protected HashMap getHeaders(String url) {
- HashMap headers = new HashMap<>();
- headers.put("method", "GET");
- headers.put("Host", siteHost);
- headers.put("Upgrade-Insecure-Requests", "1");
- headers.put("DNT", "1");
- headers.put("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36");
- headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
- headers.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
- return headers;
- }
-
- /**
- * 获取分类数据 + 首页最近更新视频列表数据
- *
- * @param filter 是否开启筛选 关联的是 软件设置中 首页数据源里的筛选开关
- * @return
- */
- @Override
- public String homeContent(boolean filter) {
- try {
- Document doc = Jsoup.parse(OkHttpUtil.string(siteUrl, getHeaders(siteUrl)));
- // 分类节点
- Elements elements = doc.select("ul.nav-menu > li > a");
- JSONArray classes = new JSONArray();
- for (Element ele : elements) {
- //分类名
- String name = ele.text();
- boolean show = name.equals("电影") ||
- name.equals("电视剧") ||
- name.equals("综艺") ||
- name.equals("动漫");
- if (show) {
- Matcher mather = regexCategory.matcher(ele.attr("href"));
- if (!mather.find())
- continue;
- // 把分类的id和名称取出来加到列表里
- String id = mather.group(1).trim();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("type_id", id);
- jsonObject.put("type_name", name);
- classes.put(jsonObject);
- }
- }
- JSONObject result = new JSONObject();
- if (filter) {
- result.put("filters", filterConfig);
- }
- result.put("class", classes);
- try {
- // 取首页推荐视频列表
- Element homeList = doc.select("ul.myui-vodlist").get(0);
- Elements list = homeList.select("li > div > a");
- JSONArray videos = new JSONArray();
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.attr("title");
- String cover = vod.attr("data-original");
- String remark = vod.selectFirst("span.pic-text").text();
- Matcher matcher = regexVid.matcher(vod.attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- result.put("list", videos);
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 获取分类信息数据
- *
- * @param tid 分类id
- * @param pg 页数
- * @param filter 同homeContent方法中的filter
- * @param extend 筛选参数{k:v, k1:v1}
- * @return
- */
- @Override
- public String categoryContent(String tid, String pg, boolean filter, HashMap extend) {
- try {
- String[] urlParams = new String[]{"", "", "", "", "", "", "", "", "", "", "", ""};
- urlParams[0] = tid;
- urlParams[8] = pg;
- if (extend != null && extend.size() > 0) {
- for (Iterator it = extend.keySet().iterator(); it.hasNext(); ) {
- String key = it.next();
- String value = extend.get(key);
- urlParams[Integer.parseInt(key)] = URLEncoder.encode(value);
- }
- }
- // 获取分类数据的url
- String url = siteUrl + "/vodshow/" + TextUtils.join("-", urlParams) + "/";
- String html = OkHttpUtil.string(url, getHeaders(url));
- Document doc = Jsoup.parse(html);
- JSONObject result = new JSONObject();
- int pageCount = 0;
- int page = -1;
-
-
- // 取页码相关信息
- Elements pageInfo = doc.select("ul.myui-page>li");
- if (pageInfo.size() == 0) {
- page = Integer.parseInt(pg);
- pageCount = page;
- } else {
- for (int i = 0; i < pageInfo.size(); i++) {
- Element li = pageInfo.get(i);
- Element a = li.selectFirst("a");
- if (a == null)
- continue;
- String name = a.text();
- if (page == -1 && a.hasClass("btn-warm")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- page = Integer.parseInt(matcher.group(1).split("-")[8]);
- } else {
- page = 0;
- }
- }
- if (name.equals("尾页")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- pageCount = Integer.parseInt(matcher.group(1).split("-")[8]);
- } else {
- pageCount = 0;
- }
- break;
- }
- }
- }
-
- JSONArray videos = new JSONArray();
- if (!html.contains("没有找到您想要的结果哦")) {
- // 取当前分类页的视频列表
- Elements list = doc.select("ul.myui-vodlist > li > div > a");
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.attr("title");
- String cover = vod.attr("data-original");
- String remark = vod.selectFirst("span.pic-text").text();
- Matcher matcher = regexVid.matcher(vod.attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- }
- result.put("page", page);
- result.put("pagecount", pageCount);
- result.put("limit", 48);
- result.put("total", pageCount <= 1 ? videos.length() : pageCount * 48);
-
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 视频详情信息
- *
- * @param ids 视频id
- * @return
- */
- @Override
- public String detailContent(List ids) {
- try {
- // 视频详情url
- String url = siteUrl + "/voddetail/" + ids.get(0) + "/";
- //System.out.println(url);
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- JSONObject result = new JSONObject();
- JSONObject vodList = new JSONObject();
-
- // 取基本数据
- String cover = doc.selectFirst("div.myui-content__thumb > a > img").attr("src");
- String title = doc.selectFirst("div.myui-content__thumb > a").attr("title");
- String desc = Jsoup.parse(doc.selectFirst("meta[name=description]").attr("content")).text();
- String category = "", area = "", year = "", remark = "", director = "", actor = "";
- Elements span_text_muted = doc.select("div.myui-content__detail span.text-muted");
- for (int i = 0; i < span_text_muted.size(); i++) {
- Element text = span_text_muted.get(i);
- String info = text.text();
- if (info.equals("分类:")) {
- category = text.nextElementSibling().text();
- } else if (info.equals("年份:")) {
- year = text.nextElementSibling().text();
- } else if (info.equals("地区:")) {
- area = text.nextElementSibling().text();
- } else if (info.equals("更新:")) {
- remark = text.nextElementSibling().text();
- } else if (info.equals("导演:")) {
- List directors = new ArrayList<>();
- Elements aa = text.parent().select("a");
- for (int j = 0; j < aa.size(); j++) {
- directors.add(aa.get(j).text());
- }
- director = TextUtils.join(",", directors);
- } else if (info.equals("主演:")) {
- List actors = new ArrayList<>();
- Elements aa = text.parent().select("a");
- for (int j = 0; j < aa.size(); j++) {
- actors.add(aa.get(j).text());
- }
- actor = TextUtils.join(",", actors);
- }
- }
-
- vodList.put("vod_id", ids.get(0));
- vodList.put("vod_name", title);
- vodList.put("vod_pic", cover);
- vodList.put("type_name", category);
- vodList.put("vod_year", year);
- vodList.put("vod_area", area);
- vodList.put("vod_remarks", remark);
- vodList.put("vod_actor", actor);
- vodList.put("vod_director", director);
- vodList.put("vod_content", desc);
- //System.out.println(vodList.toString());
- Map vod_play = new TreeMap<>(new Comparator() {
- @Override
- public int compare(String o1, String o2) {
- try {
- int sort1 = playerConfig.getJSONObject(o1).getInt("or");
- int sort2 = playerConfig.getJSONObject(o2).getInt("or");
-
- if (sort1 == sort2) {
- return 1;
- }
- return sort1 - sort2 > 0 ? 1 : -1;
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- return 1;
- }
- });
-
- // 取播放列表数据
- Elements sources = doc.select("ul.nav-btn > li > a");
- //System.out.println(sources.size());
- Elements sourceList = doc.select("div.tab-content > div");
- //System.out.println(sourceList.size());
- for (int i = 0; i < sources.size(); i++) {
- Element source = sources.get(i);
- //System.out.println(sources.text().split(":")[0].split("』")[1]);
- String sourceName = source.text();
- boolean found = false;
- for (Iterator it = playerConfig.keys(); it.hasNext(); ) {
- String flag = it.next();
- if (playerConfig.getJSONObject(flag).getString("sh").equals(sourceName)) {
- sourceName = flag;
- found = true;
- break;
- }
- }
- if (!found)
- continue;
- String playList = "";
- Elements playListA = sourceList.get(i).select("ul > li > a");
- //System.out.println(playListA.size());
- List vodItems = new ArrayList<>();
-
- for (int j = 0; j < playListA.size(); j++) {
- Element vod = playListA.get(j);
- Matcher matcher = regexPlay.matcher(vod.attr("href"));
- if (!matcher.find())
- continue;
- String playURL = matcher.group(1) + "-" + matcher.group(2) + "-" + matcher.group(3);
- vodItems.add(vod.text() + "$" + playURL);
- }
- if (vodItems.size() > 0)
- playList = TextUtils.join("#", vodItems);
-
- if (playList.length() == 0)
- continue;
-
- vod_play.put(sourceName, playList);
- }
-
- if (vod_play.size() > 0) {
- String vod_play_from = TextUtils.join("$$$", vod_play.keySet());
- String vod_play_url = TextUtils.join("$$$", vod_play.values());
- vodList.put("vod_play_from", vod_play_from);
- vodList.put("vod_play_url", vod_play_url);
- }
- JSONArray list = new JSONArray();
- list.put(vodList);
- result.put("list", list);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
-
- /**
- * 获取视频播放信息
- *
- * @param flag 播放源
- * @param id 视频id
- * @param vipFlags 所有可能需要vip解析的源
- * @return
- */
- @Override
- public String playerContent(String flag, String id, List vipFlags) {
- try {
- //定义播放用的headers
- JSONObject headers = new JSONObject();
- //headers.put("Host", " cokemv.co");
- //headers.put("origin", " https://juhi.cc");
- //headers.put("User-Agent", " Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36");
- //headers.put("Accept", " */*");
- //headers.put("Accept-Language", " zh-CN,zh;q=0.9,en-US;q=0.3,en;q=0.7");
- //headers.put("Accept-Encoding", " gzip, deflate, br");
-
-
- // 播放页 url
- String url = siteUrl + "/vodplay/" + id + "/";
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- Elements allScript = doc.select("script");
- JSONObject result = new JSONObject();
- for (int i = 0; i < allScript.size(); i++) {
- String scContent = allScript.get(i).html().trim();
- if (scContent.startsWith("var player_")) { // 取直链
- int start = scContent.indexOf('{');
- int end = scContent.lastIndexOf('}') + 1;
- String json = scContent.substring(start, end);
- JSONObject player = new JSONObject(json);
- if (playerConfig.has(player.getString("from"))) {
- JSONObject pCfg = playerConfig.getJSONObject(player.getString("from"));
- String videoUrl = player.getString("url");
- String playUrl = pCfg.getString("pu");
- if (Misc.isVip(videoUrl)) { // 使用jx:1
- try {
- result.put("parse", 1);
- result.put("jx", "1");
- result.put("url", videoUrl);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- }
- result.put("parse", pCfg.getInt("sn"));
- result.put("playUrl", playUrl);
- result.put("url", videoUrl);
- result.put("header", headers.toString());
- }
- break;
- }
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
-
- @Override
- public String searchContent(String key, boolean quick) {
- try {
- if (quick)
- return "";
- long currentTime = System.currentTimeMillis();
- String url = siteUrl + "/index.php/ajax/suggest?mid=1&wd=" + URLEncoder.encode(key) + "&limit=10×tamp=" + currentTime;
- //Document doc = Jsoup.parse(srr.content);
- JSONObject searchResult = new JSONObject(OkHttpUtil.string(url, getHeaders(url)));
- JSONObject result = new JSONObject();
- JSONArray videos = new JSONArray();
- if (searchResult.getInt("total") > 0) {
- JSONArray lists = new JSONArray(searchResult.getString("list"));
- for (int i = 0; i < lists.length(); i++) {
- JSONObject vod = lists.getJSONObject(i);
- String id = vod.getString("id");
- String title = vod.getString("name");
- String cover = vod.getString("pic");
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", "");
- videos.put(v);
- }
- }
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-}
diff --git a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Jumi.java b/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Jumi.java
deleted file mode 100644
index 1f3b010..0000000
--- a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Jumi.java
+++ /dev/null
@@ -1,466 +0,0 @@
-package com.github.catvod.spider;
-
-import android.content.Context;
-import android.text.TextUtils;
-
-import com.github.catvod.crawler.Spider;
-import com.github.catvod.crawler.SpiderDebug;
-import com.github.catvod.utils.okhttp.OkHttpUtil;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
-
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Demo for self study
- *
- * Source from Author: CatVod
- */
-
-public class Jumi extends Spider {
-
- private static final String siteUrl = "https://jumi.tv/";
- private static final String siteHost = "jumi.tv";
-
- protected JSONObject playerConfig;
- protected JSONObject filterConfig;
-
- protected Pattern regexCategory = Pattern.compile("/type/(\\S+).html");
- protected Pattern regexVid = Pattern.compile("/vod/(\\d+).html");
- protected Pattern regexPlay = Pattern.compile("/play/(\\d+)-(\\d+)-(\\d+).html");
- protected Pattern regexPage = Pattern.compile("\\S+/page/(\\d+)\\S+");
-
- @Override
- public void init(Context context) {
- super.init(context);
- try {
- playerConfig = new JSONObject("{\"mlm3u8\":{\"sh\":\"極速①線\",\"sn\":1,\"pu\":\"https://jx.parwix.com:4433/aliplayer/?url=\",\"or\":999},\"alizy\":{\"sh\":\"極速③線\",\"sn\":1,\"pu\":\"https://jx.parwix.com:4433/aliplayer/?url=\",\"or\":999},\"weiyun\":{\"sh\":\"1080P\",\"sn\":1,\"pu\":\"https://jx.parwix.com:4433/aliplayer/?url=\",\"or\":999},\"dbm3u8\":{\"sh\":\"急速雲\",\"sn\":1,\"pu\":\"https://jx.parwix.com:4433/aliplayer/?url=\",\"or\":999},\"tkm3u8\":{\"sh\":\"天空雲\",\"sn\":1,\"pu\":\"https://jx.parwix.com:4433/aliplayer/?url=\",\"or\":999},\"wjm3u8\":{\"sh\":\"無盡雲\",\"sn\":1,\"pu\":\"https://jx.parwix.com:4433/aliplayer/?url=\",\"or\":999},\"605m3u8\":{\"sh\":\"光速雲\",\"sn\":1,\"pu\":\"https://jx.parwix.com:4433/aliplayer/?url=\",\"or\":999},\"kbm3u8\":{\"sh\":\"秒播雲\",\"sn\":1,\"pu\":\"https://jx.parwix.com:4433/aliplayer/?url=\",\"or\":999},\"bjm3u8\":{\"sh\":\"八戒雲\",\"sn\":1,\"pu\":\"https://jx.parwix.com:4433/aliplayer/?url=\",\"or\":999},\"hnm3u8\":{\"sh\":\"紅牛雲\",\"sn\":1,\"pu\":\"https://jx.parwix.com:4433/aliplayer/?url=\",\"or\":999},\"bdxm3u8\":{\"sh\":\"北鬥雲\",\"sn\":1,\"pu\":\"https://jx.parwix.com:4433/aliplayer/?url=\",\"or\":999},\"youku\":{\"sh\":\"優酷雲\",\"sn\":1,\"pu\":\"https://www.mgtv.com.jumi.tv/player/?url=\",\"or\":999},\"mgtv\":{\"sh\":\"芒果雲\",\"sn\":1,\"pu\":\"https://www.mgtv.com.jumi.tv/player/?url=\",\"or\":999},\"88zym3u8\":{\"sh\":\"88雲\",\"sn\":1,\"pu\":\"https://jx.parwix.com:4433/aliplayer/?url=\",\"or\":999},\"qiyi\":{\"sh\":\"奇藝雲\",\"sn\":1,\"pu\":\"https://www.mgtv.com.jumi.tv/player/?url=\",\"or\":999},\"dplayer\":{\"sh\":\"動漫專線\",\"sn\":1,\"pu\":\"https://jx.parwix.com:4433/aliplayer/?url=\",\"or\":999},\"qq\":{\"sh\":\"騰訊雲\",\"sn\":1,\"pu\":\"https://www.mgtv.com.jumi.tv/player/?url=\",\"or\":999},\"bilibili\":{\"sh\":\"嗶哩雲\",\"sn\":1,\"pu\":\"https://www.mgtv.com.jumi.tv/player/?url=\",\"or\":999},\"sohu\":{\"sh\":\"搜狐雲\",\"sn\":1,\"pu\":\"https://www.mgtv.com.jumi.tv/player/?url=\",\"or\":999}}");
- filterConfig = new JSONObject("{\"1\":[{\"key\":\"tid\",\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"動作片\",\"v\":\"6\"},{\"n\":\"喜劇片\",\"v\":\"7\"},{\"n\":\"愛情片\",\"v\":\"8\"},{\"n\":\"科幻片\",\"v\":\"9\"},{\"n\":\"恐怖片\",\"v\":\"10\"},{\"n\":\"劇情片\",\"v\":\"11\"},{\"n\":\"戰爭片\",\"v\":\"12\"},{\"n\":\"紀錄片\",\"v\":\"20\"}]},{\"key\":\"class\",\"name\":\"剧情\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"驚悚\",\"v\":\"驚悚\"},{\"n\":\"懸疑\",\"v\":\"懸疑\"},{\"n\":\"魔幻\",\"v\":\"魔幻\"},{\"n\":\"罪案\",\"v\":\"罪案\"},{\"n\":\"災難\",\"v\":\"災難\"},{\"n\":\"動畫\",\"v\":\"動畫\"},{\"n\":\"古裝\",\"v\":\"古裝\"},{\"n\":\"青春\",\"v\":\"青春\"},{\"n\":\"歌舞\",\"v\":\"歌舞\"},{\"n\":\"文藝\",\"v\":\"文藝\"},{\"n\":\"生活\",\"v\":\"生活\"},{\"n\":\"歷史\",\"v\":\"歷史\"},{\"n\":\"勵志\",\"v\":\"勵志\"},{\"n\":\"搞笑\",\"v\":\"搞笑\"},{\"n\":\"愛情\",\"v\":\"愛情\"},{\"n\":\"喜劇\",\"v\":\"喜劇\"},{\"n\":\"恐怖\",\"v\":\"恐怖\"},{\"n\":\"動作\",\"v\":\"動作\"},{\"n\":\"科幻\",\"v\":\"科幻\"},{\"n\":\"劇情\",\"v\":\"劇情\"},{\"n\":\"戰爭\",\"v\":\"戰爭\"},{\"n\":\"犯罪\",\"v\":\"犯罪\"},{\"n\":\"奇幻\",\"v\":\"奇幻\"},{\"n\":\"武俠\",\"v\":\"武俠\"},{\"n\":\"冒險\",\"v\":\"冒險\"},{\"n\":\"經典\",\"v\":\"經典\"},{\"n\":\"兒童\",\"v\":\"兒童\"}]},{\"key\":\"area\",\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"大陸\",\"v\":\"大陸\"},{\"n\":\"香港\",\"v\":\"香港\"},{\"n\":\"台灣\",\"v\":\"台灣\"},{\"n\":\"美國\",\"v\":\"美國\"},{\"n\":\"法國\",\"v\":\"法國\"},{\"n\":\"英國\",\"v\":\"英國\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"韓國\",\"v\":\"韓國\"},{\"n\":\"德國\",\"v\":\"德國\"},{\"n\":\"泰國\",\"v\":\"泰國\"},{\"n\":\"印度\",\"v\":\"印度\"},{\"n\":\"意大利\",\"v\":\"意大利\"},{\"n\":\"西班牙\",\"v\":\"西班牙\"},{\"n\":\"加拿大\",\"v\":\"加拿大\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":\"year\",\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"}]},{\"key\":\"by\",\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"2\":[{\"key\":\"tid\",\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"陸劇\",\"v\":\"13\"},{\"n\":\"港劇\",\"v\":\"14\"},{\"n\":\"台劇\",\"v\":\"22\"},{\"n\":\"日劇\",\"v\":\"15\"},{\"n\":\"韓劇\",\"v\":\"23\"},{\"n\":\"美劇\",\"v\":\"16\"},{\"n\":\"海外劇\",\"v\":\"24\"}]},{\"key\":\"class\",\"name\":\"剧情\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"言情\",\"v\":\"言情\"},{\"n\":\"都市\",\"v\":\"都市\"},{\"n\":\"家庭\",\"v\":\"家庭\"},{\"n\":\"生活\",\"v\":\"生活\"},{\"n\":\"偶像\",\"v\":\"偶像\"},{\"n\":\"喜劇\",\"v\":\"喜劇\"},{\"n\":\"歷史\",\"v\":\"歷史\"},{\"n\":\"古裝\",\"v\":\"古裝\"},{\"n\":\"武俠\",\"v\":\"武俠\"},{\"n\":\"刑偵\",\"v\":\"刑偵\"},{\"n\":\"戰爭\",\"v\":\"戰爭\"},{\"n\":\"神話\",\"v\":\"神話\"},{\"n\":\"軍旅\",\"v\":\"軍旅\"},{\"n\":\"諜戰\",\"v\":\"諜戰\"},{\"n\":\"商戰\",\"v\":\"商戰\"},{\"n\":\"校園\",\"v\":\"校園\"},{\"n\":\"穿越\",\"v\":\"穿越\"},{\"n\":\"懸疑\",\"v\":\"懸疑\"},{\"n\":\"犯罪\",\"v\":\"犯罪\"},{\"n\":\"科幻\",\"v\":\"科幻\"},{\"n\":\"愛情\",\"v\":\"愛情\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":\"area\",\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"大陸\",\"v\":\"大陸\"},{\"n\":\"香港\",\"v\":\"香港\"},{\"n\":\"台灣\",\"v\":\"台灣\"},{\"n\":\"美國\",\"v\":\"美國\"},{\"n\":\"法國\",\"v\":\"法國\"},{\"n\":\"英國\",\"v\":\"英國\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"韓國\",\"v\":\"韓國\"},{\"n\":\"德國\",\"v\":\"德國\"},{\"n\":\"泰國\",\"v\":\"泰國\"},{\"n\":\"印度\",\"v\":\"印度\"},{\"n\":\"意大利\",\"v\":\"意大利\"},{\"n\":\"西班牙\",\"v\":\"西班牙\"},{\"n\":\"加拿大\",\"v\":\"加拿大\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":\"year\",\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"},{\"n\":\"2009\",\"v\":\"2009\"},{\"n\":\"2008\",\"v\":\"2008\"},{\"n\":\"2007\",\"v\":\"2007\"},{\"n\":\"2006\",\"v\":\"2006\"},{\"n\":\"2005\",\"v\":\"2005\"},{\"n\":\"2004\",\"v\":\"2004\"}]},{\"key\":\"by\",\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"3\":[{\"key\":\"class\",\"name\":\"剧情\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"选秀\",\"v\":\"选秀\"},{\"n\":\"情感\",\"v\":\"情感\"},{\"n\":\"访谈\",\"v\":\"访谈\"},{\"n\":\"播报\",\"v\":\"播报\"},{\"n\":\"旅游\",\"v\":\"旅游\"},{\"n\":\"音乐\",\"v\":\"音乐\"},{\"n\":\"美食\",\"v\":\"美食\"},{\"n\":\"纪实\",\"v\":\"纪实\"},{\"n\":\"曲艺\",\"v\":\"曲艺\"},{\"n\":\"生活\",\"v\":\"生活\"},{\"n\":\"游戏互动\",\"v\":\"游戏互动\"},{\"n\":\"财经\",\"v\":\"财经\"},{\"n\":\"求职\",\"v\":\"求职\"}]},{\"key\":\"area\",\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"中国大陆\",\"v\":\"中国大陆\"},{\"n\":\"大陆\",\"v\":\"大陆\"},{\"n\":\"港台\",\"v\":\"港台\"},{\"n\":\"日韩\",\"v\":\"日韩\"},{\"n\":\"欧美\",\"v\":\"欧美\"}]},{\"key\":\"year\",\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"},{\"n\":\"2009\",\"v\":\"2009\"},{\"n\":\"2008\",\"v\":\"2008\"},{\"n\":\"2007\",\"v\":\"2007\"},{\"n\":\"2006\",\"v\":\"2006\"},{\"n\":\"2005\",\"v\":\"2005\"},{\"n\":\"2004\",\"v\":\"2004\"}]},{\"key\":\"by\",\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"4\":[{\"key\":\"class\",\"name\":\"剧情\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"情感\",\"v\":\"情感\"},{\"n\":\"科幻\",\"v\":\"科幻\"},{\"n\":\"热血\",\"v\":\"热血\"},{\"n\":\"推理\",\"v\":\"推理\"},{\"n\":\"搞笑\",\"v\":\"搞笑\"},{\"n\":\"冒险\",\"v\":\"冒险\"},{\"n\":\"萝莉\",\"v\":\"萝莉\"},{\"n\":\"校园\",\"v\":\"校园\"},{\"n\":\"动作\",\"v\":\"动作\"},{\"n\":\"机战\",\"v\":\"机战\"},{\"n\":\"运动\",\"v\":\"运动\"},{\"n\":\"战争\",\"v\":\"战争\"},{\"n\":\"少年\",\"v\":\"少年\"},{\"n\":\"少女\",\"v\":\"少女\"},{\"n\":\"社会\",\"v\":\"社会\"},{\"n\":\"原创\",\"v\":\"原创\"},{\"n\":\"亲子\",\"v\":\"亲子\"},{\"n\":\"益智\",\"v\":\"益智\"},{\"n\":\"励志\",\"v\":\"励志\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":\"area\",\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"国产\",\"v\":\"国产\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"欧美\",\"v\":\"欧美\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":\"year\",\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"},{\"n\":\"2009\",\"v\":\"2009\"},{\"n\":\"2008\",\"v\":\"2008\"},{\"n\":\"2007\",\"v\":\"2007\"},{\"n\":\"2006\",\"v\":\"2006\"},{\"n\":\"2005\",\"v\":\"2005\"},{\"n\":\"2004\",\"v\":\"2004\"}]},{\"key\":\"by\",\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}]}");
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- }
-
- /**
- * 爬虫headers
- *
- * @param url
- * @return
- */
- protected HashMap getHeaders(String url) {
- HashMap headers = new HashMap<>();
- headers.put("method", "GET");
- headers.put("Host", siteHost);
- headers.put("Upgrade-Insecure-Requests", "1");
- headers.put("DNT", "1");
- headers.put("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36");
- headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
- headers.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
- return headers;
- }
-
- /**
- * 获取分类数据 + 首页最近更新视频列表数据
- *
- * @param filter 是否开启筛选 关联的是 软件设置中 首页数据源里的筛选开关
- * @return
- */
- @Override
- public String homeContent(boolean filter) {
- try {
- String url = siteUrl + '/';
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- Elements elements = doc.select("ul.nav-menu>li>a");
- JSONArray classes = new JSONArray();
- ArrayList allClass = new ArrayList<>();
- for (Element ele : elements) {
- String name = ele.text();
- boolean show = !filter || (name.equals("電影") || name.equals("劇集") || name.equals("綜藝") || name.equals("動漫"));
- if (allClass.contains(name))
- show = false;
- if (show) {
- allClass.add(name);
- Matcher mather = regexCategory.matcher(ele.attr("href"));
- if (!mather.find())
- continue;
- // 把分类的id和名称取出来加到列表里
- String id = mather.group(1).trim();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("type_id", id);
- jsonObject.put("type_name", name);
- classes.put(jsonObject);
- }
- }
- JSONObject result = new JSONObject();
- if (filter) {
- result.put("filters", filterConfig);
- }
- result.put("class", classes);
- try {
- // 取首页推荐视频列表
- Elements list = doc.select("div.col-lg-wide-75 > ul.myui-vodlist li div.myui-vodlist__box");
- JSONArray videos = new JSONArray();
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.selectFirst(".title").text();
- String cover = vod.selectFirst(".myui-vodlist__thumb").attr("data-original");
- String remark = vod.selectFirst("span.pic-text").text();
-
- Matcher matcher = regexVid.matcher(vod.selectFirst(".myui-vodlist__thumb").attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- result.put("list", videos);
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
-
- /**
- * 获取分类信息数据
- *
- * @param tid 分类id
- * @param pg 页数
- * @param filter 同homeContent方法中的filter
- * @param extend 筛选参数{k:v, k1:v1}
- * @return
- */
- @Override
- public String categoryContent(String tid, String pg, boolean filter, HashMap extend) {
- try {
- String url = siteUrl + "/show/";
- if (extend != null && extend.size() > 0 && extend.containsKey("tid") && extend.get("tid").length() > 0) {
- url += extend.get("tid");
- } else {
- url += tid;
- }
- if (extend != null && extend.size() > 0) {
- for (Iterator it = extend.keySet().iterator(); it.hasNext(); ) {
- String key = it.next();
- String value = extend.get(key);
- if (value.length() > 0) {
- url += "/" + key + "/" + URLEncoder.encode(value);
- }
- }
- }
- url += "/page/" + pg + ".html";
- String html = OkHttpUtil.string(url, getHeaders(url));
- Document doc = Jsoup.parse(html);
- JSONObject result = new JSONObject();
- int pageCount = 0;
- int page = -1;
-
- // 取页码相关信息
- Elements pageInfo = doc.select(".myui-page li a");
- if (pageInfo.size() == 0) {
- page = Integer.parseInt(pg);
- pageCount = page;
- } else {
- for (int i = 0; i < pageInfo.size(); i++) {
- Element a = pageInfo.get(i);
- String name = a.text();
- if (page == -1 && a.hasClass("btn-warm")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- page = Integer.parseInt(matcher.group(1).trim());
- } else {
- page = 0;
- }
- }
- if (name.equals("尾页")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- pageCount = Integer.parseInt(matcher.group(1).trim());
- } else {
- pageCount = 0;
- }
- break;
- }
- }
- }
-
- JSONArray videos = new JSONArray();
- if (!html.contains("没有找到您想要的结果哦")) {
- // 取当前分类页的视频列表
- Elements list = doc.select("ul.myui-vodlist li div.myui-vodlist__box");
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.selectFirst(".title").text();
- String cover = vod.selectFirst(".myui-vodlist__thumb").attr("data-original");
- String remark = vod.selectFirst("span.pic-text").text();
-
- Matcher matcher = regexVid.matcher(vod.selectFirst(".myui-vodlist__thumb").attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- }
- result.put("page", page);
- result.put("pagecount", pageCount);
- result.put("limit", 48);
- result.put("total", pageCount <= 1 ? videos.length() : pageCount * 48);
-
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 视频详情信息
- *
- * @param ids 视频id
- * @return
- */
- @Override
- public String detailContent(List ids) {
- try {
- // 视频详情url
- String url = siteUrl + "/vod/" + ids.get(0) + ".html";
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- JSONObject result = new JSONObject();
- JSONObject vodList = new JSONObject();
-
- // 取基本数据
- String vid = doc.selectFirst("span.mac_hits").attr("data-id");
-
- String cover = doc.selectFirst("a.myui-vodlist__thumb img").attr("data-original");
- String title = doc.selectFirst("div.myui-content__detail h1.title").text();
- String desc = Jsoup.parse(doc.selectFirst("meta[name=description]").attr("content")).text();
- String category = "", area = "", year = "", remark = "", director = "", actor = "";
- Elements span_text_muted = doc.select("div.myui-content__detail span.text-muted");
- for (int i = 0; i < span_text_muted.size(); i++) {
- Element text = span_text_muted.get(i);
- String info = text.text();
- if (info.equals("分类:")) {
- category = text.nextElementSibling().text();
- } else if (info.equals("年份:")) {
- year = text.nextElementSibling().text();
- } else if (info.equals("地区:")) {
- area = text.nextElementSibling().text();
- } else if (info.equals("更新:")) {
- remark = text.nextElementSibling().text();
- } else if (info.equals("导演:")) {
- List directors = new ArrayList<>();
- Elements aa = text.parent().select("a");
- for (int j = 0; j < aa.size(); j++) {
- directors.add(aa.get(j).text());
- }
- director = TextUtils.join(",", directors);
- } else if (info.equals("主演:")) {
- List actors = new ArrayList<>();
- Elements aa = text.parent().select("a");
- for (int j = 0; j < aa.size(); j++) {
- actors.add(aa.get(j).text());
- }
- actor = TextUtils.join(",", actors);
- }
- }
-
- vodList.put("vod_id", vid);
- vodList.put("vod_name", title);
- vodList.put("vod_pic", cover);
- vodList.put("type_name", category);
- vodList.put("vod_year", year);
- vodList.put("vod_area", area);
- vodList.put("vod_remarks", remark);
- vodList.put("vod_actor", actor);
- vodList.put("vod_director", director);
- vodList.put("vod_content", desc);
-
- Map vod_play = new TreeMap<>(new Comparator() {
- @Override
- public int compare(String o1, String o2) {
- try {
- int sort1 = playerConfig.getJSONObject(o1).getInt("or");
- int sort2 = playerConfig.getJSONObject(o2).getInt("or");
-
- if (sort1 == sort2) {
- return 1;
- }
- return sort1 - sort2 > 0 ? 1 : -1;
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- return 1;
- }
- });
-
- // 取播放列表数据
- Elements sources = doc.select("div.myui-panel__head>ul").get(0).select("li");
- Elements sourceList = doc.select("div.tab-content>div.tab-pane");
-
- for (int i = 0; i < sources.size(); i++) {
- Element source = sources.get(i);
- String sourceName = source.text();
- boolean found = false;
- for (Iterator it = playerConfig.keys(); it.hasNext(); ) {
- String flag = it.next();
- if (playerConfig.getJSONObject(flag).getString("sh").equals(sourceName)) {
- sourceName = flag;
- found = true;
- break;
- }
- }
- if (!found)
- continue;
- String playList = "";
- Elements playListA = sourceList.get(i).select("ul>li>a");
- List vodItems = new ArrayList<>();
-
- for (int j = 0; j < playListA.size(); j++) {
- Element vod = playListA.get(j);
- Matcher matcher = regexPlay.matcher(vod.attr("href"));
- if (!matcher.find())
- continue;
- String playURL = matcher.group(1) + "-" + matcher.group(2) + "-" + matcher.group(3);
- vodItems.add(vod.text() + "$" + playURL);
- }
- if (vodItems.size() > 0)
- playList = TextUtils.join("#", vodItems);
-
- if (playList.length() == 0)
- continue;
-
- vod_play.put(sourceName, playList);
- }
-
- if (vod_play.size() > 0) {
- String vod_play_from = TextUtils.join("$$$", vod_play.keySet());
- String vod_play_url = TextUtils.join("$$$", vod_play.values());
- vodList.put("vod_play_from", vod_play_from);
- vodList.put("vod_play_url", vod_play_url);
- }
- JSONArray list = new JSONArray();
- list.put(vodList);
- result.put("list", list);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 获取视频播放信息
- *
- * @param flag 播放源
- * @param id 视频id
- * @param vipFlags 所有可能需要vip解析的源
- * @return
- */
- @Override
- public String playerContent(String flag, String id, List vipFlags) {
- try {
- //定义播放用的headers
- JSONObject headers = new JSONObject();
- //headers.put("Host", " cokemv.co");
- headers.put("origin", " https://jumi.tv");
- headers.put("User-Agent", " Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36");
- headers.put("Accept", " */*");
- headers.put("Accept-Language", " zh-CN,zh;q=0.9,en-US;q=0.3,en;q=0.7");
- headers.put("Accept-Encoding", " gzip, deflate");
- headers.put("referer", " https://jumi.tv/");
-
-
- // 播放页 url
- String url = siteUrl + "/play/" + id + ".html";
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- Elements allScript = doc.select("script");
- JSONObject result = new JSONObject();
- for (int i = 0; i < allScript.size(); i++) {
- String scContent = allScript.get(i).html().trim();
- if (scContent.startsWith("var player_")) { // 取直链
- int start = scContent.indexOf('{');
- int end = scContent.lastIndexOf('}') + 1;
- String json = scContent.substring(start, end);
- JSONObject player = new JSONObject(json);
- if (playerConfig.has(player.getString("from"))) {
- JSONObject pCfg = playerConfig.getJSONObject(player.getString("from"));
- String videoUrl = player.getString("url");
- String playUrl = pCfg.getString("pu");
- result.put("parse", pCfg.getInt("sn"));
- result.put("playUrl", playUrl);
- result.put("url", videoUrl);
- result.put("header", headers.toString());
- }
- break;
- }
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
-
- @Override
- public String searchContent(String key, boolean quick) {
- try {
- if (quick)
- return "";
- long currentTime = System.currentTimeMillis();
- String url = siteUrl + "/index.php/ajax/suggest?mid=1&wd=" + URLEncoder.encode(key) + "&limit=10×tamp=" + currentTime;
- JSONObject searchResult = new JSONObject(OkHttpUtil.string(url, getHeaders(url)));
- JSONObject result = new JSONObject();
- JSONArray videos = new JSONArray();
- if (searchResult.getInt("total") > 0) {
- JSONArray lists = new JSONArray(searchResult.getString("list"));
- for (int i = 0; i < lists.length(); i++) {
- JSONObject vod = lists.getJSONObject(i);
- String id = vod.getString("id");
- String title = vod.getString("name");
- String cover = vod.getString("pic");
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", "");
- videos.put(v);
- }
- }
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-}
diff --git a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/N0ys.java b/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/N0ys.java
deleted file mode 100644
index 4e63721..0000000
--- a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/N0ys.java
+++ /dev/null
@@ -1,471 +0,0 @@
-package com.github.catvod.spider;
-
-import android.content.Context;
-import android.net.Uri;
-import android.text.TextUtils;
-
-import com.github.catvod.crawler.Spider;
-import com.github.catvod.crawler.SpiderDebug;
-import com.github.catvod.utils.okhttp.OkHttpUtil;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
-
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * 90影视
- *
- * Author: 小黄瓜
- */
-public class N0ys extends Spider {
- private static final String siteUrl = "http://1090ys8.com";
- private static final String siteHost = "1090ys8.com";
- private static final String ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36";
-
- /**
- * 播放源配置
- */
- private JSONObject playerConfig;
-
- private Pattern regexCategory = Pattern.compile("/whole/(\\w+).html");
- private Pattern regexVid = Pattern.compile("/show/(\\w+).html");
- private Pattern regexPlay = Pattern.compile("/play/(\\w+)-(\\d+)-(\\d+).html");
- private Pattern regexPage = Pattern.compile("/whole/\\d+/page/(\\d+).html");
-
- @Override
- public void init(Context context) {
- super.init(context);
- try {
- playerConfig = new JSONObject("{\"youbo\":{\"sh\":\"高速1\",\"sn\":\"0\",\"pu\":\"http://jx1090ys5.hongfanedu.top/x2.php?id=\",\"or\":999},\"wanpan\":{\"sh\":\"高速备用\",\"sn\":\"0\",\"pu\":\"\",\"or\":999},\"niuxyun\":{\"sh\":\"高速2\",\"sn\":\"1\",\"pu\":\"http://1090ys2.com/nxjx/jx.php?id=\",\"or\":999},\"bjm3u8\":{\"sh\":\"备用2\",\"sn\":\"0\",\"pu\":\"\",\"or\":999},\"dbm3u8\":{\"sh\":\"备用3\",\"sn\":\"0\",\"pu\":\"\",\"or\":999},\"nfmp4\":{\"sh\":\"高速3\",\"sn\":\"0\",\"pu\":\"\",\"or\":999},\"tkm3u8\":{\"sh\":\"备用1\",\"sn\":\"0\",\"pu\":\"\",\"or\":999},\"wjm3u8\":{\"sh\":\"备用4\",\"sn\":\"0\",\"pu\":\"\",\"or\":999}}");
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- }
-
- /**
- * 爬虫headers
- *
- * @param url
- * @return
- */
- protected HashMap getHeaders(String url) {
- HashMap headers = new HashMap<>();
- headers.put("method", "GET");
- headers.put("Host", siteHost);
- headers.put("Upgrade-Insecure-Requests", "1");
- headers.put("DNT", "1");
- headers.put("User-Agent", ua);
- headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
- headers.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
- return headers;
- }
-
- /**
- * 获取分类数据 + 首页最近更新视频列表数据
- *
- * @param filter 是否开启筛选 关联的是 软件设置中 首页数据源里的筛选开关
- * @return
- */
- @Override
- public String homeContent(boolean filter) {
- try {
- Document doc = Jsoup.parse(OkHttpUtil.string(siteUrl, getHeaders(siteUrl)));
- // 分类节点
- Elements elements = doc.select("ul.type-slide > li a");
- JSONArray classes = new JSONArray();
- for (Element ele : elements) {
- String name = ele.text();
- Matcher mather = regexCategory.matcher(ele.attr("href"));
- if (!mather.find())
- continue;
- String id = mather.group(1).trim();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("type_id", id);
- jsonObject.put("type_name", name);
- classes.put(jsonObject);
- }
- JSONObject result = new JSONObject();
- result.put("class", classes);
- try {
- Elements list = doc.select("div.stui-pannel_bd ul.stui-vodlist li div.stui-vodlist__box");
- JSONArray videos = new JSONArray();
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- Matcher matcher = regexVid.matcher(vod.selectFirst(".stui-vodlist__thumb").attr("href"));
- if (!matcher.find())
- continue;
- String title = vod.selectFirst(".title").text();
- String cover = vod.selectFirst(".stui-vodlist__thumb").attr("data-original");
- String remark = vod.selectFirst("span.pic-text").text();
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- result.put("list", videos);
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 获取分类信息数据
- *
- * @param tid 分类id
- * @param pg 页数
- * @param filter 同homeContent方法中的filter
- * @param extend 筛选参数{k:v, k1:v1}
- * @return
- */
- @Override
- public String categoryContent(String tid, String pg, boolean filter, HashMap extend) {
- try {
- // 获取分类数据的url
- String url = siteUrl + "/whole/" + tid + "/page/" + pg + ".html";
- String html = OkHttpUtil.string(url, getHeaders(url));
- Document doc = Jsoup.parse(html);
- JSONObject result = new JSONObject();
- int pageCount = 0;
- int page = -1;
-
- Elements pageInfo = doc.select(".stui-page li");
- if (pageInfo.size() == 0) {
- page = Integer.parseInt(pg);
- pageCount = page;
- } else {
- for (int i = 0; i < pageInfo.size(); i++) {
- Element li = pageInfo.get(i);
- Element a = li.selectFirst("a");
- if (a == null)
- continue;
- String name = a.text();
- if (page == -1 && li.hasClass("active")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- page = Integer.parseInt(matcher.group(1));
- } else {
- page = 0;
- }
- }
- if (name.equals("尾页")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- pageCount = Integer.parseInt(matcher.group(1));
- } else {
- pageCount = 0;
- }
- break;
- }
- }
- }
-
- JSONArray videos = new JSONArray();
- if (!html.contains("没有找到您想要的结果哦")) {
- Elements list = doc.select("ul.stui-vodlist li div.stui-vodlist__box");
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.selectFirst(".title").text();
- String cover = vod.selectFirst(".stui-vodlist__thumb").attr("data-original");
- String remark = vod.selectFirst("span.pic-text").text();
- Matcher matcher = regexVid.matcher(vod.selectFirst(".stui-vodlist__thumb").attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- }
- result.put("page", page);
- result.put("pagecount", pageCount);
- result.put("limit", 30);
- result.put("total", pageCount <= 1 ? videos.length() : pageCount * 30);
-
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 视频详情信息
- *
- * @param ids 视频id
- * @return
- */
- @Override
- public String detailContent(List ids) {
- try {
- // 视频详情url
- String url = siteUrl + "/show/" + ids.get(0) + ".html";
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- JSONObject result = new JSONObject();
- JSONObject vodList = new JSONObject();
-
- // 取基本数据
- String cover = doc.selectFirst("a.stui-vodlist__thumb img").attr("data-original");
- String title = doc.selectFirst("a.stui-vodlist__thumb").attr("title");
- String desc = Jsoup.parse(doc.selectFirst("meta[name=description]").attr("content")).text();
- String category = "", area = "", year = "", remark = "", director = "", actor = "";
- Elements span_text_muted = doc.select("div.stui-content__detail span.text-muted");
- for (int i = 0; i < span_text_muted.size(); i++) {
- Element text = span_text_muted.get(i);
- String info = text.text();
- if (info.equals("类型:")) {
- category = text.nextSibling().outerHtml().trim();
- } else if (info.equals("年份:")) {
- year = text.nextSibling().outerHtml().trim();
- } else if (info.equals("地区:")) {
- area = text.nextSibling().outerHtml().trim();
- } else if (info.equals("更新:")) {
- remark = text.nextSibling().outerHtml().trim();
- } else if (info.equals("导演:")) {
- director = text.nextSibling().outerHtml().trim();
- } else if (info.equals("主演:")) {
- actor = text.nextSibling().outerHtml().trim();
- }
- }
-
- vodList.put("vod_id", ids.get(0));
- vodList.put("vod_name", title);
- vodList.put("vod_pic", cover);
- vodList.put("type_name", category);
- vodList.put("vod_year", year);
- vodList.put("vod_area", area);
- vodList.put("vod_remarks", remark);
- vodList.put("vod_actor", actor);
- vodList.put("vod_director", director);
- vodList.put("vod_content", desc);
-
- Map vod_play = new TreeMap<>(new Comparator() {
- @Override
- public int compare(String o1, String o2) {
- try {
- int sort1 = playerConfig.getJSONObject(o1).getInt("or");
- int sort2 = playerConfig.getJSONObject(o2).getInt("or");
-
- if (sort1 == sort2) {
- return 1;
- }
- return sort1 - sort2 > 0 ? 1 : -1;
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- return 1;
- }
- });
-
- Elements sources = doc.select("div.playlist");
-
- for (int i = 0; i < sources.size(); i++) {
- Element source = sources.get(i);
- String sourceName = source.selectFirst("h3.title").text().trim();
- String tabHref = source.attr("href");
- boolean found = false;
- for (Iterator it = playerConfig.keys(); it.hasNext(); ) {
- String flag = it.next();
- if (playerConfig.getJSONObject(flag).getString("sh").equals(sourceName)) {
- sourceName = flag;
- found = true;
- break;
- }
- }
- if (!found)
- continue;
- String playList = "";
- Elements playListA = source.select("ul.stui-content__playlist > li > a");
- List vodItems = new ArrayList<>();
-
- for (int j = 0; j < playListA.size(); j++) {
- Element vod = playListA.get(j);
- Matcher matcher = regexPlay.matcher(vod.attr("href"));
- if (!matcher.find())
- continue;
- String playURL = matcher.group(1) + "-" + matcher.group(2) + "-" + matcher.group(3);
- vodItems.add(vod.text() + "$" + playURL);
- }
- if (vodItems.size() > 0)
- playList = TextUtils.join("#", vodItems);
-
- if (playList.length() == 0)
- continue;
-
- vod_play.put(sourceName, playList);
- }
-
- if (vod_play.size() > 0) {
- String vod_play_from = TextUtils.join("$$$", vod_play.keySet());
- String vod_play_url = TextUtils.join("$$$", vod_play.values());
- vodList.put("vod_play_from", vod_play_from);
- vodList.put("vod_play_url", vod_play_url);
- }
- JSONArray list = new JSONArray();
- list.put(vodList);
- result.put("list", list);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 获取视频播放信息
- *
- * @param flag 播放源
- * @param id 视频id
- * @param vipFlags 所有可能需要vip解析的源
- * @return
- */
- @Override
- public String playerContent(String flag, String id, List vipFlags) {
- try {
- // 播放页 url
- String url = "http://1090ys8.com/play/" + id + ".html";
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- Elements allScript = doc.select("script");
- JSONObject result = new JSONObject();
- for (int i = 0; i < allScript.size(); i++) {
- String scContent = allScript.get(i).html().trim();
- if (scContent.startsWith("var player_")) {
- int start = scContent.indexOf('{');
- int end = scContent.lastIndexOf('}') + 1;
- String json = scContent.substring(start, end);
- JSONObject player = new JSONObject(json);
- if (playerConfig.has(player.getString("from"))) {
- JSONObject pCfg = playerConfig.getJSONObject(player.getString("from"));
- String videoUrl = player.getString("url");
- String playUrl = pCfg.getString("pu");
- String from = player.getString("from");
- if (from.equals("youbo")) {
- // 感谢猫大神的直连解密代码
- HashMap hds = getHeaders(url);
- hds.put("Host", "jx1090ys5.hongfanedu.top");
- hds.put("Referer", url);
- String content1 = OkHttpUtil.string(playUrl + videoUrl, hds);
- Document doc1 = Jsoup.parse(content1);
- String url2 = doc1.selectFirst("iframe#WANG").attr("src");
- String url2host = Uri.parse(url2).getHost();
- hds.put("Host", url2host);
- hds.put("Referer", "http://jx1090ys5.hongfanedu.top/");
- String content2 = OkHttpUtil.string(url2, hds);
- String finder = "var id=\"";
- start = content2.indexOf(finder) + finder.length();
- end = content2.indexOf('\"', start);
- String vvid = content2.substring(start, end);
- finder = "var sk=\"";
- start = content2.indexOf(finder) + finder.length();
- end = content2.indexOf('\"', start);
- String skey = content2.substring(start, end);
- finder = "var pt=\"";
- start = content2.indexOf(finder) + finder.length();
- end = content2.indexOf('\"', start);
- String pt = content2.substring(start, end);
- finder = "var ti=\"";
- start = content2.indexOf(finder) + finder.length();
- end = content2.indexOf('\"', start);
- String time = content2.substring(start, end);
- int bkn = 0x195c;
- for (int j = 0x0, all = skey.length(); all > j; ++j) {
- bkn += ((bkn << 5) + (byte) skey.charAt(j));
- }
- bkn = 0x7fffffff & bkn;
- int gtk1 = 0x0;
- for (int j = 0x0; j < pt.length(); j += 0x4) {
- gtk1 += Integer.parseInt(String.format("%c%c%c%c", pt.charAt(j), pt.charAt(j + 0x1), pt.charAt(j + 0x2), pt.charAt(j + 0x3)), 0x10);
- gtk1 %= 0x400a;
- }
- int offset = gtk1 % 10;
- int gtk = 0x0;
- for (int j = 0x0; j < pt.length(); j++) {
- gtk += ((byte) pt.charAt(j)) * (j + offset);
- gtk %= gtk1;
- }
- String finalVideoUrl = "http://" + url2host + "/hls/play/" + vvid + "%7C" + time + "%7C" + skey + "%7C" + pt + "%7C" + bkn + "%7C" + gtk + ".m3u8";
- result.put("parse", pCfg.getInt("sn"));
- result.put("playUrl", "");
- result.put("url", finalVideoUrl);
- result.put("header", "{\"Referer\":\" " + url2 + "\"}");
- } else {
- result.put("parse", pCfg.getInt("sn"));
- result.put("playUrl", playUrl);
- result.put("url", videoUrl);
- result.put("header", "");
- }
- }
- break;
- }
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 搜索
- *
- * @param key
- * @param quick 是否播放页的快捷搜索
- * @return
- */
- @Override
- public String searchContent(String key, boolean quick) {
- try {
- long currentTime = System.currentTimeMillis();
- String url = siteUrl + "/index.php/ajax/suggest?mid=1&wd=" + URLEncoder.encode(key) + "&limit=10×tamp=" + currentTime;
- JSONObject searchResult = new JSONObject(OkHttpUtil.string(url, getHeaders(url)));
- JSONObject result = new JSONObject();
- JSONArray videos = new JSONArray();
- if (searchResult.getInt("total") > 0) {
- JSONArray lists = new JSONArray(searchResult.getString("list"));
- for (int i = 0; i < lists.length(); i++) {
- JSONObject vod = lists.getJSONObject(i);
- String id = vod.getString("id");
- String title = vod.getString("name");
- String cover = vod.getString("pic");
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", "");
- videos.put(v);
- }
- }
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-}
diff --git a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Nekk.java b/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Nekk.java
deleted file mode 100644
index 1c21002..0000000
--- a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Nekk.java
+++ /dev/null
@@ -1,489 +0,0 @@
-package com.github.catvod.spider;
-
-import android.content.Context;
-import android.text.TextUtils;
-import android.util.Base64;
-
-import com.github.catvod.crawler.Spider;
-import com.github.catvod.crawler.SpiderDebug;
-import com.github.catvod.utils.okhttp.OKCallBack;
-import com.github.catvod.utils.okhttp.OkHttpUtil;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import okhttp3.Call;
-import okhttp3.Headers;
-import okhttp3.Response;
-
-
-public class Nekk extends Spider {
-
- private static final String siteUrl = "https://www.9ela.com";
- private static final String siteHost = "www.9ela.com";
-
- protected JSONObject playerConfig;
- protected JSONObject filterConfig;
-
- protected Pattern regexCategory = Pattern.compile("/vodshow/(\\S+).html");
- protected Pattern regexVid = Pattern.compile("/voddetail/(\\d+).html");
- protected Pattern regexPlay = Pattern.compile("/vodplay/(\\d+)-(\\d+)-(\\d+).html");
- protected Pattern regexPage = Pattern.compile("\\S+/page/(\\d+)\\S+");
-
- @Override
- public void init(Context context) {
- super.init(context);
- try {
- playerConfig = new JSONObject("{\"9ekk\":{\"sh\":\"手机线路\",\"sn\":0,\"pu\":\"\",\"or\":999},\"ttee\":{\"sh\":\"9亿超清\",\"sn\":0,\"pu\":\"\",\"or\":999},\"9999ku\":{\"sh\":\"手机线路2\",\"sn\":0,\"pu\":\"\",\"or\":999},\"gsyun\":{\"sh\":\"九亿超清\",\"sn\":0,\"pu\":\"\",\"or\":999},\"kkyun\":{\"sh\":\"HD超清线路\",\"sn\":0,\"pu\":\"\",\"or\":999},\"ty01\":{\"sh\":\"超清线路\",\"sn\":0,\"pu\":\"\",\"or\":999},\"ppayun\":{\"sh\":\"九亿线路\",\"sn\":0,\"pu\":\"https://wy.mlkioiy.cn/api/GetDownUrlWy/d91ea50eb7eb4932b92aa8bb3c61560d/\",\"or\":999},\"8kdm\":{\"sh\":\"九亿动漫\",\"sn\":0,\"pu\":\"\",\"or\":999},\"jsyun\":{\"sh\":\"九亿备用\",\"sn\":0,\"pu\":\"\",\"or\":999},\"9evip\":{\"sh\":\"九亿解析-弃用\",\"sn\":0,\"pu\":\"\",\"or\":999},\"189pan\":{\"sh\":\"九亿超清11\",\"sn\":0,\"pu\":\"http://1987s.com/api/dp.php?url=\",\"or\":999},\"VIP\":{\"sh\":\"VIP线路\",\"sn\":0,\"pu\":\"\",\"or\":999},\"qq\":{\"sh\":\"九亿解析\",\"sn\":1,\"pu\":\"\",\"or\":999},\"mgtv\":{\"sh\":\"九亿解析\",\"sn\":1,\"pu\":\"\",\"or\":999},\"bjm3u8\":{\"sh\":\"线路三\",\"sn\":0,\"pu\":\"\",\"or\":999},\"dbm3u8\":{\"sh\":\"线路四\",\"sn\":0,\"pu\":\"\",\"or\":999},\"ckm3u8\":{\"sh\":\"线路二\",\"sn\":0,\"pu\":\"\",\"or\":999},\"mahua\":{\"sh\":\"线路四\",\"sn\":0,\"pu\":\"\",\"or\":999},\"123kum3u8\":{\"sh\":\"123kum3u8\",\"sn\":1,\"pu\":\"https://jx.123ku.com/123kudpbfq/?url=\",\"or\":999},\"pqc\":{\"sh\":\"测试\",\"sn\":1,\"pu\":\"https://jx.qiuzeqi.top/jx1/dp/index.php?url=\",\"or\":999},\"test\":{\"sh\":\"test\",\"sn\":1,\"pu\":\"https//1987s.com/api/dp.php?url=\",\"or\":999}}");
- filterConfig = new JSONObject("{\"dianying\":[{\"key\":\"tid\",\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"国语配音电影\",\"v\":\"gypy\"},{\"n\":\"最近热播电影\",\"v\":\"zuijinrebodianying\"},{\"n\":\"动作片\",\"v\":\"dongzuopian\"},{\"n\":\"喜剧片\",\"v\":\"xijupian\"},{\"n\":\"爱情片\",\"v\":\"aiqingpian\"},{\"n\":\"科幻片\",\"v\":\"kehuanpian\"},{\"n\":\"恐怖片\",\"v\":\"kongbupian\"},{\"n\":\"剧情片\",\"v\":\"juqingpian\"},{\"n\":\"战争片\",\"v\":\"zhanzhengpian\"}]},{\"key\":\"class\",\"name\":\"剧情\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"喜剧\",\"v\":\"喜剧\"},{\"n\":\"爱情\",\"v\":\"爱情\"},{\"n\":\"恐怖\",\"v\":\"恐怖\"},{\"n\":\"动作\",\"v\":\"动作\"},{\"n\":\"科幻\",\"v\":\"科幻\"},{\"n\":\"剧情\",\"v\":\"剧情\"},{\"n\":\"战争\",\"v\":\"战争\"},{\"n\":\"警匪\",\"v\":\"警匪\"},{\"n\":\"犯罪\",\"v\":\"犯罪\"},{\"n\":\"动画\",\"v\":\"动画\"},{\"n\":\"奇幻\",\"v\":\"奇幻\"},{\"n\":\"武侠\",\"v\":\"武侠\"},{\"n\":\"冒险\",\"v\":\"冒险\"},{\"n\":\"枪战\",\"v\":\"枪战\"},{\"n\":\"恐怖\",\"v\":\"恐怖\"},{\"n\":\"悬疑\",\"v\":\"悬疑\"},{\"n\":\"惊悚\",\"v\":\"惊悚\"},{\"n\":\"经典\",\"v\":\"经典\"},{\"n\":\"青春\",\"v\":\"青春\"},{\"n\":\"文艺\",\"v\":\"文艺\"},{\"n\":\"微电影\",\"v\":\"微电影\"},{\"n\":\"古装\",\"v\":\"古装\"},{\"n\":\"历史\",\"v\":\"历史\"},{\"n\":\"运动\",\"v\":\"运动\"},{\"n\":\"农村\",\"v\":\"农村\"},{\"n\":\"儿童\",\"v\":\"儿童\"},{\"n\":\"网络电影\",\"v\":\"网络电影\"}]},{\"key\":\"area\",\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"中国大陆\",\"v\":\"中国大陆\"},{\"n\":\"中国香港\",\"v\":\"中国香港\"},{\"n\":\"中国台湾\",\"v\":\"中国台湾\"},{\"n\":\"美国\",\"v\":\"美国\"},{\"n\":\"法国\",\"v\":\"法国\"},{\"n\":\"英国\",\"v\":\"英国\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"韩国\",\"v\":\"韩国\"},{\"n\":\"德国\",\"v\":\"德国\"},{\"n\":\"泰国\",\"v\":\"泰国\"},{\"n\":\"印度\",\"v\":\"印度\"},{\"n\":\"意大利\",\"v\":\"意大利\"},{\"n\":\"西班牙\",\"v\":\"西班牙\"},{\"n\":\"加拿大\",\"v\":\"加拿大\"},{\"n\":\"其他\",\"v\":\"其他\"},{\"n\":\"热门\",\"v\":\"热门\"}]},{\"key\":\"year\",\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"}]},{\"key\":\"by\",\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"lianxuju\":[{\"key\":\"tid\",\"name\":\"类型\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"最近热播电视剧\",\"v\":\"zuijinrebodianshiju\"},{\"n\":\"国语配音剧集\",\"v\":\"guoyupeiyinhanju\"},{\"n\":\"热播美剧\",\"v\":\"rebomeiju\"},{\"n\":\"电视剧\",\"v\":\"guochanju\"},{\"n\":\"港台剧\",\"v\":\"gangtaiju\"},{\"n\":\"日韩剧\",\"v\":\"rihanju\"},{\"n\":\"欧美剧\",\"v\":\"oumeiju\"}]},{\"key\":\"class\",\"name\":\"剧情\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"古装\",\"v\":\"古装\"},{\"n\":\"战争\",\"v\":\"战争\"},{\"n\":\"青春偶像\",\"v\":\"青春偶像\"},{\"n\":\"喜剧\",\"v\":\"喜剧\"},{\"n\":\"家庭\",\"v\":\"家庭\"},{\"n\":\"犯罪\",\"v\":\"犯罪\"},{\"n\":\"动作\",\"v\":\"动作\"},{\"n\":\"奇幻\",\"v\":\"奇幻\"},{\"n\":\"剧情\",\"v\":\"剧情\"},{\"n\":\"历史\",\"v\":\"历史\"},{\"n\":\"经典\",\"v\":\"经典\"},{\"n\":\"乡村\",\"v\":\"乡村\"},{\"n\":\"情景\",\"v\":\"情景\"},{\"n\":\"商战\",\"v\":\"商战\"},{\"n\":\"网剧\",\"v\":\"网剧\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":\"area\",\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"中国大陆\",\"v\":\"中国大陆\"},{\"n\":\"韩国\",\"v\":\"韩国\"},{\"n\":\"香港\",\"v\":\"香港\"},{\"n\":\"台湾\",\"v\":\"台湾\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"美国\",\"v\":\"美国\"},{\"n\":\"泰国\",\"v\":\"泰国\"},{\"n\":\"英国\",\"v\":\"英国\"},{\"n\":\"新加坡\",\"v\":\"新加坡\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":\"year\",\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"},{\"n\":\"2009\",\"v\":\"2009\"},{\"n\":\"2008\",\"v\":\"2008\"},{\"n\":\"2007\",\"v\":\"2007\"},{\"n\":\"2006\",\"v\":\"2006\"},{\"n\":\"2005\",\"v\":\"2005\"},{\"n\":\"2004\",\"v\":\"2004\"}]},{\"key\":\"by\",\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"zongyi\":[{\"key\":\"class\",\"name\":\"剧情\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"选秀\",\"v\":\"选秀\"},{\"n\":\"情感\",\"v\":\"情感\"},{\"n\":\"访谈\",\"v\":\"访谈\"},{\"n\":\"播报\",\"v\":\"播报\"},{\"n\":\"旅游\",\"v\":\"旅游\"},{\"n\":\"音乐\",\"v\":\"音乐\"},{\"n\":\"美食\",\"v\":\"美食\"},{\"n\":\"纪实\",\"v\":\"纪实\"},{\"n\":\"曲艺\",\"v\":\"曲艺\"},{\"n\":\"生活\",\"v\":\"生活\"},{\"n\":\"游戏互动\",\"v\":\"游戏互动\"},{\"n\":\"财经\",\"v\":\"财经\"},{\"n\":\"求职\",\"v\":\"求职\"}]},{\"key\":\"area\",\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"中国大陆\",\"v\":\"中国大陆\"},{\"n\":\"大陆\",\"v\":\"大陆\"},{\"n\":\"港台\",\"v\":\"港台\"},{\"n\":\"日韩\",\"v\":\"日韩\"},{\"n\":\"欧美\",\"v\":\"欧美\"}]},{\"key\":\"year\",\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"},{\"n\":\"2009\",\"v\":\"2009\"},{\"n\":\"2008\",\"v\":\"2008\"},{\"n\":\"2007\",\"v\":\"2007\"},{\"n\":\"2006\",\"v\":\"2006\"},{\"n\":\"2005\",\"v\":\"2005\"},{\"n\":\"2004\",\"v\":\"2004\"}]},{\"key\":\"by\",\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}],\"dongman\":[{\"key\":\"class\",\"name\":\"剧情\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"情感\",\"v\":\"情感\"},{\"n\":\"科幻\",\"v\":\"科幻\"},{\"n\":\"热血\",\"v\":\"热血\"},{\"n\":\"推理\",\"v\":\"推理\"},{\"n\":\"搞笑\",\"v\":\"搞笑\"},{\"n\":\"冒险\",\"v\":\"冒险\"},{\"n\":\"萝莉\",\"v\":\"萝莉\"},{\"n\":\"校园\",\"v\":\"校园\"},{\"n\":\"动作\",\"v\":\"动作\"},{\"n\":\"机战\",\"v\":\"机战\"},{\"n\":\"运动\",\"v\":\"运动\"},{\"n\":\"战争\",\"v\":\"战争\"},{\"n\":\"少年\",\"v\":\"少年\"},{\"n\":\"少女\",\"v\":\"少女\"},{\"n\":\"社会\",\"v\":\"社会\"},{\"n\":\"原创\",\"v\":\"原创\"},{\"n\":\"亲子\",\"v\":\"亲子\"},{\"n\":\"益智\",\"v\":\"益智\"},{\"n\":\"励志\",\"v\":\"励志\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":\"area\",\"name\":\"地区\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"国产\",\"v\":\"国产\"},{\"n\":\"日本\",\"v\":\"日本\"},{\"n\":\"欧美\",\"v\":\"欧美\"},{\"n\":\"其他\",\"v\":\"其他\"}]},{\"key\":\"year\",\"name\":\"年份\",\"value\":[{\"n\":\"全部\",\"v\":\"\"},{\"n\":\"2021\",\"v\":\"2021\"},{\"n\":\"2020\",\"v\":\"2020\"},{\"n\":\"2019\",\"v\":\"2019\"},{\"n\":\"2018\",\"v\":\"2018\"},{\"n\":\"2017\",\"v\":\"2017\"},{\"n\":\"2016\",\"v\":\"2016\"},{\"n\":\"2015\",\"v\":\"2015\"},{\"n\":\"2014\",\"v\":\"2014\"},{\"n\":\"2013\",\"v\":\"2013\"},{\"n\":\"2012\",\"v\":\"2012\"},{\"n\":\"2011\",\"v\":\"2011\"},{\"n\":\"2010\",\"v\":\"2010\"},{\"n\":\"2009\",\"v\":\"2009\"},{\"n\":\"2008\",\"v\":\"2008\"},{\"n\":\"2007\",\"v\":\"2007\"},{\"n\":\"2006\",\"v\":\"2006\"},{\"n\":\"2005\",\"v\":\"2005\"},{\"n\":\"2004\",\"v\":\"2004\"}]},{\"key\":\"by\",\"name\":\"排序\",\"value\":[{\"n\":\"时间\",\"v\":\"\"},{\"n\":\"人气\",\"v\":\"hits\"},{\"n\":\"评分\",\"v\":\"score\"}]}]}");
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- }
-
- /**
- * 爬虫headers
- *
- * @param url
- * @return
- */
- protected HashMap getHeaders(String url) {
- HashMap headers = new HashMap<>();
- headers.put("method", "GET");
- headers.put("Host", siteHost);
- headers.put("Upgrade-Insecure-Requests", "1");
- headers.put("DNT", "1");
- headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36");
- headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
- headers.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
- return headers;
- }
-
-
- @Override
- public String homeContent(boolean filter) {
- try {
- String url = siteUrl + '/';
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- Elements elements = doc.select("ul.nav-list > li a");
- JSONArray classes = new JSONArray();
- ArrayList allClass = new ArrayList<>();
- for (Element ele : elements) {
- String name = ele.text();
- boolean show = !filter || (name.equals("电影") || name.equals("连续剧") || name.equals("综艺") || name.equals("动漫"));
- if (allClass.contains(name))
- show = false;
- if (show) {
- allClass.add(name);
- Matcher mather = regexCategory.matcher(ele.attr("href"));
- if (!mather.find())
- continue;
- String id = mather.group(1).trim();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("type_id", id);
- jsonObject.put("type_name", name);
- classes.put(jsonObject);
- }
- }
- JSONObject result = new JSONObject();
- if (filter) {
- result.put("filters", filterConfig);
- }
- result.put("class", classes);
- try {
- Elements list = doc.select("div.col-lg-wide-75 > ul.myui-vodlist li div.myui-vodlist__box");
- JSONArray videos = new JSONArray();
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.selectFirst(".title").text();
- String cover = fixCover(vod.selectFirst(".myui-vodlist__thumb").attr("data-original"));
- String remark = vod.selectFirst("span.pic-text").text();
-
- Matcher matcher = regexVid.matcher(vod.selectFirst(".myui-vodlist__thumb").attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- result.put("list", videos);
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- @Override
- public String categoryContent(String tid, String pg, boolean filter, HashMap extend) {
- try {
- String url = siteUrl + "/vodshow/";
- if (extend != null && extend.size() > 0 && extend.containsKey("tid") && extend.get("tid").length() > 0) {
- url += extend.get("tid");
- } else {
- url += tid;
- }
- if (extend != null && extend.size() > 0) {
- for (Iterator it = extend.keySet().iterator(); it.hasNext(); ) {
- String key = it.next();
- String value = extend.get(key);
- if (value.length() > 0) {
- url += "/" + key + "/" + URLEncoder.encode(value);
- }
- }
- }
- url += "/page/" + pg + ".html";
- String html = OkHttpUtil.string(url, getHeaders(url));
- Document doc = Jsoup.parse(html);
- JSONObject result = new JSONObject();
- int pageCount = 0;
- int page = -1;
-
- Elements pageInfo = doc.select(".myui-page li a");
- if (pageInfo.size() == 0) {
- page = Integer.parseInt(pg);
- pageCount = page;
- } else {
- for (int i = 0; i < pageInfo.size(); i++) {
- Element a = pageInfo.get(i);
- String name = a.text();
- if (page == -1 && a.hasClass("btn-warm")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- page = Integer.parseInt(matcher.group(1).trim());
- } else {
- page = 0;
- }
- }
- if (name.equals("尾页")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- pageCount = Integer.parseInt(matcher.group(1).trim());
- } else {
- pageCount = 0;
- }
- break;
- }
- }
- }
-
- JSONArray videos = new JSONArray();
- if (!html.contains("没有找到您想要的结果哦")) {
- Elements list = doc.select("ul.myui-vodlist li div.myui-vodlist__box");
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.selectFirst(".title").text();
- String cover = fixCover(vod.selectFirst(".myui-vodlist__thumb").attr("data-original"));
- String remark = vod.selectFirst("span.pic-text").text();
-
- Matcher matcher = regexVid.matcher(vod.selectFirst(".myui-vodlist__thumb").attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- }
- result.put("page", page);
- result.put("pagecount", pageCount);
- result.put("limit", 48);
- result.put("total", pageCount <= 1 ? videos.length() : pageCount * 48);
-
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- @Override
- public String detailContent(List ids) {
- try {
- String url = siteUrl + "/voddetail/" + ids.get(0) + ".html";
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- JSONObject result = new JSONObject();
- JSONObject vodList = new JSONObject();
-
- String vid = doc.selectFirst("span.mac_hits").attr("data-id");
-
- String cover = fixCover(doc.selectFirst("a.myui-vodlist__thumb img").attr("data-original"));
- String title = doc.selectFirst("div.myui-content__detail h1.title").text();
- String desc = Jsoup.parse(doc.selectFirst("meta[name=description]").attr("content")).text();
- String category = "", area = "", year = "", remark = "", director = "", actor = "";
- Elements span_text_muted = doc.select("div.myui-content__detail span.text-muted");
- for (int i = 0; i < span_text_muted.size(); i++) {
- Element text = span_text_muted.get(i);
- String info = text.text();
- if (info.equals("分类:")) {
- category = text.nextElementSibling().text();
- } else if (info.equals("年份:")) {
- year = text.nextElementSibling().text();
- } else if (info.equals("地区:")) {
- area = text.nextElementSibling().text();
- } else if (info.equals("更新:")) {
- remark = text.nextElementSibling().text();
- } else if (info.equals("导演:")) {
- List directors = new ArrayList<>();
- Elements aa = text.parent().select("a");
- for (int j = 0; j < aa.size(); j++) {
- directors.add(aa.get(j).text());
- }
- director = TextUtils.join(",", directors);
- } else if (info.equals("主演:")) {
- List actors = new ArrayList<>();
- Elements aa = text.parent().select("a");
- for (int j = 0; j < aa.size(); j++) {
- actors.add(aa.get(j).text());
- }
- actor = TextUtils.join(",", actors);
- }
- }
-
- vodList.put("vod_id", vid);
- vodList.put("vod_name", title);
- vodList.put("vod_pic", cover);
- vodList.put("type_name", category);
- vodList.put("vod_year", year);
- vodList.put("vod_area", area);
- vodList.put("vod_remarks", remark);
- vodList.put("vod_actor", actor);
- vodList.put("vod_director", director);
- vodList.put("vod_content", desc);
-
- Map vod_play = new TreeMap<>(new Comparator() {
- @Override
- public int compare(String o1, String o2) {
- try {
- int sort1 = playerConfig.getJSONObject(o1).getInt("or");
- int sort2 = playerConfig.getJSONObject(o2).getInt("or");
-
- if (sort1 == sort2) {
- return 1;
- }
- return sort1 - sort2 > 0 ? 1 : -1;
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- return 1;
- }
- });
-
- Elements sources = doc.select("a[data-toggle=tab]");
-
- for (int i = 0; i < sources.size(); i++) {
- Element source = sources.get(i);
- String sourceName = source.text();
- String tabHref = source.attr("href");
- boolean found = false;
- for (Iterator it = playerConfig.keys(); it.hasNext(); ) {
- String flag = it.next();
- if (playerConfig.getJSONObject(flag).getString("sh").equals(sourceName)) {
- sourceName = flag;
- found = true;
- break;
- }
- }
- if (!found)
- continue;
- String playList = "";
- Elements playListA = doc.select("div" + tabHref + " ul > li a");
- List vodItems = new ArrayList<>();
-
- for (int j = 0; j < playListA.size(); j++) {
- Element vod = playListA.get(j);
- Matcher matcher = regexPlay.matcher(vod.attr("href"));
- if (!matcher.find())
- continue;
- String playURL = matcher.group(1) + "-" + matcher.group(2) + "-" + matcher.group(3);
- vodItems.add(vod.text() + "$" + playURL);
- }
- if (vodItems.size() > 0)
- playList = TextUtils.join("#", vodItems);
-
- if (playList.length() == 0)
- continue;
-
- vod_play.put(sourceName, playList);
- }
-
- if (vod_play.size() > 0) {
- String vod_play_from = TextUtils.join("$$$", vod_play.keySet());
- String vod_play_url = TextUtils.join("$$$", vod_play.values());
- vodList.put("vod_play_from", vod_play_from);
- vodList.put("vod_play_url", vod_play_url);
- }
- JSONArray list = new JSONArray();
- list.put(vodList);
- result.put("list", list);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- @Override
- public String playerContent(String flag, String id, List vipFlags) {
- try {
- String url = siteUrl + "/vodplay/" + id + ".html";
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- Elements allScript = doc.select("script");
- JSONObject result = new JSONObject();
- for (int i = 0; i < allScript.size(); i++) {
- String scContent = allScript.get(i).html().trim();
- if (scContent.startsWith("var player_")) {
- int start = scContent.indexOf('{');
- int end = scContent.lastIndexOf('}') + 1;
- String json = scContent.substring(start, end);
- JSONObject player = new JSONObject(json);
- if (playerConfig.has(player.getString("from"))) {
- JSONObject pCfg = playerConfig.getJSONObject(player.getString("from"));
- String videoUrl = player.getString("url");
- if (player.has("encrypt")) {
- int encrypt = player.getInt("encrypt");
- if (encrypt == 1) {
- videoUrl = URLDecoder.decode(videoUrl);
- } else if (encrypt == 2) {
- videoUrl = new String(Base64.decode(videoUrl, Base64.DEFAULT));
- videoUrl = URLDecoder.decode(videoUrl);
- }
- }
- String playUrl = pCfg.getString("pu");
- result.put("parse", pCfg.getInt("sn"));
- result.put("playUrl", playUrl);
- result.put("url", videoUrl);
- if (flag.equals("9ekk")) {
- JSONObject headers = new JSONObject();
- headers.put("User-Agent", " Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36");
- headers.put("Accept", " */*");
- headers.put("Connection", " keep-alive");
- result.put("header", headers.toString());
- } else {
- result.put("header", "");
- }
- }
- break;
- }
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- @Override
- public String searchContent(String key, boolean quick) {
- try {
- if (quick)
- return "";
- long currentTime = System.currentTimeMillis();
- String url = siteUrl + "/index.php/ajax/suggest?mid=1&wd=" + URLEncoder.encode(key) + "&limit=10×tamp=" + currentTime;
- JSONObject searchResult = new JSONObject(OkHttpUtil.string(url, getHeaders(url)));
- JSONObject result = new JSONObject();
- JSONArray videos = new JSONArray();
- if (searchResult.getInt("total") > 0) {
- JSONArray lists = new JSONArray(searchResult.getString("list"));
- for (int i = 0; i < lists.length(); i++) {
- JSONObject vod = lists.getJSONObject(i);
- String id = vod.getString("id");
- String title = vod.getString("name");
- String cover = fixCover(vod.getString("pic"));
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", "");
- videos.put(v);
- }
- }
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- protected String fixCover(String cover) {
- try {
- return "proxy://do=nekk&pic=" + Base64.encodeToString(cover.getBytes("UTF-8"), Base64.DEFAULT | Base64.URL_SAFE | Base64.NO_WRAP);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- return cover;
- }
-
- private static HashMap nekkPicHeader = null;
-
- public static Object[] loadPic(String pic) {
- try {
- pic = new String(Base64.decode(pic, Base64.DEFAULT | Base64.URL_SAFE | Base64.NO_WRAP), "UTF-8");
-
- if (nekkPicHeader == null) {
- nekkPicHeader = new HashMap<>();
- nekkPicHeader.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36");
- nekkPicHeader.put("referer", siteUrl + "/");
- }
- OKCallBack.OKCallBackDefault callBack = new OKCallBack.OKCallBackDefault() {
- @Override
- protected void onFailure(Call call, Exception e) {
-
- }
-
- @Override
- protected void onResponse(Response response) {
-
- }
- };
- OkHttpUtil.get(OkHttpUtil.defaultClient(), pic, null, nekkPicHeader, callBack);
- if (callBack.getResult().code() == 200) {
- Headers headers = callBack.getResult().headers();
- String type = headers.get("Content-Type");
- if (type == null) {
- type = "application/octet-stream";
- }
- Object[] result = new Object[3];
- result[0] = 200;
- result[1] = type;
- System.out.println(pic);
- System.out.println(type);
- result[2] = callBack.getResult().body().byteStream();
- return result;
- }
- } catch (Throwable th) {
- th.printStackTrace();
- }
- return null;
- }
-}
diff --git a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Nfx.java b/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Nfx.java
deleted file mode 100644
index ed70d51..0000000
--- a/CatVodTVSpider/app/src/main/java/com/github/catvod/spider/Nfx.java
+++ /dev/null
@@ -1,449 +0,0 @@
-package com.github.catvod.spider;
-
-import android.content.Context;
-import android.text.TextUtils;
-
-import com.github.catvod.crawler.Spider;
-import com.github.catvod.crawler.SpiderDebug;
-import com.github.catvod.utils.okhttp.OkHttpUtil;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
-
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Demo for self study
- *
- * Source from Author: CatVod
- */
-
-public class Nfx extends Spider {
-
- private static final String siteUrl = "https://nfxhd.com/";
- private static final String siteHost = "nfxhd.com";
-
- protected JSONObject playerConfig;
-
- protected Pattern regexCategory = Pattern.compile("/vodtype/(\\w+)/");
- protected Pattern regexVid = Pattern.compile("/voddetail/(\\w+)/");
- protected Pattern regexPlay = Pattern.compile("/vodplay/(\\w+)-(\\d+)-(\\d+)/");
- protected Pattern regexPage = Pattern.compile("/vodshow/(\\S+)/");
-
- @Override
- public void init(Context context) {
- super.init(context);
- try {
- playerConfig = new JSONObject("{\"adaplay\":{\"sh\":\"菜逼播放器\",\"sn\":\"1\",\"pu\":\"https://nfxhd.com/dp.php/?url=\",\"or\":999},\"xigua\":{\"sh\":\"手动点播放才能播放的播放器\",\"sn\":\"1\",\"pu\":\"https://nfxhd.com/dp.php/?url=\",\"or\":999},\"danmuku\":{\"sh\":\"海王播放器\",\"sn\":\"1\",\"pu\":\"\",\"or\":999},\"dplayer\":{\"sh\":\"冥王星播放器\",\"sn\":\"0\",\"pu\":\"\",\"or\":999},\"bdxm3u8\":{\"sh\":\"北斗星m3u8\",\"sn\":\"1\",\"pu\":\"https://player.bdxzym3u8.com/dplayer/?url=\",\"or\":999},\"bdxyun\":{\"sh\":\"北斗星云播放\",\"sn\":\"1\",\"pu\":\"\",\"or\":999},\"gangtiexia\":{\"sh\":\"土星播放器\",\"sn\":\"1\",\"pu\":\"https://wy.bigmao.top/api/ShowVideoWy/3bb24322f78b47dfb8723c13d46d45ee/\",\"or\":999},\"tt10\":{\"sh\":\"木星播放器\",\"sn\":\"1\",\"pu\":\"https://wy.bigmao.top/api/ShowVideoMu/3bb24322f78b47dfb8723c13d46d45ee/\",\"or\":999},\"docker\":{\"sh\":\"彗星播放器\",\"sn\":\"1\",\"pu\":\"https://wy.bigmao.top/api/ShowVideoDoc/3bb24322f78b47dfb8723c13d46d45ee/\",\"or\":999},\"qq\":{\"sh\":\"腾讯视频\",\"sn\":\"1\",\"pu\":\"\",\"or\":999},\"youku\":{\"sh\":\"优酷\",\"sn\":\"1\",\"pu\":\"\",\"or\":999},\"qiyi\":{\"sh\":\"爱奇艺\",\"sn\":\"1\",\"pu\":\"\",\"or\":999},\"mgtv\":{\"sh\":\"仅限APP播放\",\"sn\":\"1\",\"pu\":\"\",\"or\":999},\"m3u8\":{\"sh\":\"m3u8\",\"sn\":\"1\",\"pu\":\"\",\"or\":999},\"mx771\":{\"sh\":\"站长采集的播放器\",\"sn\":\"0\",\"pu\":\"\",\"or\":999},\"ppayun2\":{\"sh\":\"白鸟座播放器\",\"sn\":\"1\",\"pu\":\"https://wy.bigmao.top/api/ShowVideoMu/3bb24322f78b47dfb8723c13d46d45ee/\",\"or\":999},\"sohu\":{\"sh\":\"搜狐\",\"sn\":\"1\",\"pu\":\"\",\"or\":999},\"iframe\":{\"sh\":\"iframe外链数据\",\"sn\":\"0\",\"pu\":\"\",\"or\":999}}");
- } catch (JSONException e) {
- SpiderDebug.log(e);
- }
- }
-
- /**
- * 爬虫headers
- *
- * @param url
- * @return
- */
- protected HashMap getHeaders(String url) {
- HashMap headers = new HashMap<>();
- headers.put("method", "GET");
- headers.put("Host", siteHost);
- headers.put("Upgrade-Insecure-Requests", "1");
- headers.put("DNT", "1");
- headers.put("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36");
- headers.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
- headers.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
- return headers;
- }
-
- /**
- * 获取分类数据 + 首页最近更新视频列表数据
- *
- * @param filter 是否开启筛选 关联的是 软件设置中 首页数据源里的筛选开关
- * @return
- */
- @Override
- public String homeContent(boolean filter) {
- try {
- String url = siteUrl;
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- Elements elements = doc.select("ul.nav-menu>li>a");
- JSONArray classes = new JSONArray();
- ArrayList allClass = new ArrayList<>();
- for (Element ele : elements) {
- String name = ele.text();
- boolean show = !filter || (name.equals("电影") || name.equals("美剧") || name.equals("日韩") || name.equals("动漫"));
- if (allClass.contains(name))
- show = false;
- if (show) {
- allClass.add(name);
- Matcher mather = regexCategory.matcher(ele.attr("href"));
- if (!mather.find())
- continue;
- // 把分类的id和名称取出来加到列表里
- String id = mather.group(1).trim();
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("type_id", id);
- jsonObject.put("type_name", name);
- classes.put(jsonObject);
- }
- }
- JSONObject result = new JSONObject();
- result.put("class", classes);
- try {
- // 取首页推荐视频列表
- Elements list = doc.select("ul.myui-vodlist>li>div");
- JSONArray videos = new JSONArray();
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.selectFirst(".title").text();
- String cover = vod.selectFirst(".myui-vodlist__thumb").attr("data-original");
- String remark = vod.selectFirst("span.pic-text").text();
-
- Matcher matcher = regexVid.matcher(vod.selectFirst(".myui-vodlist__thumb").attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- result.put("list", videos);
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
-
- /**
- * 获取分类信息数据
- *
- * @param tid 分类id
- * @param pg 页数
- * @param filter 同homeContent方法中的filter
- * @param extend 筛选参数{k:v, k1:v1}
- * @return
- */
- @Override
- public String categoryContent(String tid, String pg, boolean filter, HashMap extend) {
- try {
- // 获取分类数据的url
- String url = siteUrl + "/vodtype/" + tid + "-" + pg + "/";
- String html = OkHttpUtil.string(url, getHeaders(url));
- Document doc = Jsoup.parse(html);
- JSONObject result = new JSONObject();
- int pageCount = 0;
- int page = -1;
-
- // 取页码相关信息
- Elements pageInfo = doc.select("ul.myui-page>li");
- if (pageInfo.size() == 0) {
- page = Integer.parseInt(pg);
- pageCount = page;
- } else {
- for (int i = 0; i < pageInfo.size(); i++) {
- Element li = pageInfo.get(i);
- Element a = li.selectFirst("a");
- if (a == null)
- continue;
- String name = a.text();
- if (page == -1 && a.hasClass("btn-warm")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- page = Integer.parseInt(matcher.group(1).split("-")[8]);
- } else {
- page = 0;
- }
- }
- if (name.equals("尾页")) {
- Matcher matcher = regexPage.matcher(a.attr("href"));
- if (matcher.find()) {
- pageCount = Integer.parseInt(matcher.group(1).split("-")[8]);
- } else {
- pageCount = 0;
- }
- break;
- }
- }
- }
-
-
- JSONArray videos = new JSONArray();
- if (!html.contains("没有找到您想要的结果哦")) {
- // 取当前分类页的视频列表
- Elements list = doc.select("div.myui-panel_bd>ul>li>div");
- for (int i = 0; i < list.size(); i++) {
- Element vod = list.get(i);
- String title = vod.selectFirst(".title").text();
- String cover = vod.selectFirst(".myui-vodlist__thumb").attr("data-original");
- String remark = vod.selectFirst("span.pic-text").text();
-
- Matcher matcher = regexVid.matcher(vod.selectFirst(".myui-vodlist__thumb").attr("href"));
- if (!matcher.find())
- continue;
- String id = matcher.group(1);
- JSONObject v = new JSONObject();
- v.put("vod_id", id);
- v.put("vod_name", title);
- v.put("vod_pic", cover);
- v.put("vod_remarks", remark);
- videos.put(v);
- }
- }
- result.put("page", page);
- result.put("pagecount", pageCount);
- result.put("limit", 48);
- result.put("total", pageCount <= 1 ? videos.length() : pageCount * 48);
-
- result.put("list", videos);
- return result.toString();
- } catch (Exception e) {
- SpiderDebug.log(e);
- }
- return "";
- }
-
- /**
- * 视频详情信息
- *
- * @param ids 视频id
- * @return
- */
- @Override
- public String detailContent(List ids) {
- try {
- // 视频详情url
- String url = siteUrl + "/voddetail/" + ids.get(0) + "/";
- Document doc = Jsoup.parse(OkHttpUtil.string(url, getHeaders(url)));
- JSONObject result = new JSONObject();
- JSONObject vodList = new JSONObject();
-
- // 取基本数据
- String vid = doc.selectFirst("span.mac_hits").attr("data-id");
-
- String cover = doc.selectFirst("a.myui-vodlist__thumb img").attr("data-original");
- String title = doc.selectFirst("div.myui-content__detail h1.title").text();
- String desc = doc.selectFirst("div.col-pd>span.sketch").text();
- String category = "", area = "", year = "", remark = "", director = "", actor = "";
- Elements span_text_muted = doc.select("div.myui-content__detail span.text-muted");
- for (int i = 0; i < span_text_muted.size(); i++) {
- Element text = span_text_muted.get(i);
- String info = text.text();
- if (info.equals("分类:")) {
- category = text.nextElementSibling().text();
- } else if (info.equals("年份:")) {
- year = text.nextElementSibling().text();
- } else if (info.equals("地区:")) {
- area = text.nextElementSibling().text();
- } else if (info.equals("更新:")) {
- remark = text.nextElementSibling().text();
- } else if (info.equals("导演:")) {
- List directors = new ArrayList<>();
- Elements aa = text.parent().select("a");
- for (int j = 0; j < aa.size(); j++) {
- directors.add(aa.get(j).text());
- }
- } else if (info.equals("主演:")) {
- List