Clean code
This commit is contained in:
parent
f303cae0a2
commit
22205be06a
|
|
@ -2,7 +2,7 @@ package com.github.catvod.bean.ali;
|
|||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ public class Item {
|
|||
}
|
||||
|
||||
public String getSize() {
|
||||
return size == 0 ? "" : "[" + Misc.getSize(size) + "]";
|
||||
return size == 0 ? "" : "[" + Utils.getSize(size) + "]";
|
||||
}
|
||||
|
||||
public String getParent() {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.github.catvod.bean.alist;
|
|||
import android.text.TextUtils;
|
||||
|
||||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
|
@ -116,7 +116,7 @@ public class Item {
|
|||
}
|
||||
|
||||
public String getRemark() {
|
||||
return Misc.getSize(getSize()) + (isFolder() ? " 文件夹" : "");
|
||||
return Utils.getSize(getSize()) + (isFolder() ? " 文件夹" : "");
|
||||
}
|
||||
|
||||
public String getVodTag() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package com.github.catvod.xpath;
|
||||
package com.github.catvod.bean.xpath;
|
||||
|
||||
import com.github.catvod.crawler.SpiderDebug;
|
||||
|
||||
|
|
@ -9,7 +9,7 @@ import java.util.LinkedHashMap;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class XPathRule {
|
||||
public class Rule {
|
||||
/**
|
||||
* user-agent
|
||||
*/
|
||||
|
|
@ -325,10 +325,10 @@ public class XPathRule {
|
|||
return src;
|
||||
}
|
||||
|
||||
public static XPathRule fromJson(String json) {
|
||||
public static Rule fromJson(String json) {
|
||||
try {
|
||||
JSONObject jsonObj = new JSONObject(json);
|
||||
XPathRule rule = new XPathRule();
|
||||
Rule rule = new Rule();
|
||||
rule.ua = jsonObj.optString("ua");
|
||||
rule.homeUrl = jsonObj.optString("homeUrl").trim();
|
||||
rule.cateNode = jsonObj.optString("cateNode").trim();
|
||||
|
|
@ -2,7 +2,7 @@ package com.github.catvod.net;
|
|||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
|
@ -68,7 +68,7 @@ class OkRequest {
|
|||
private void setParams() {
|
||||
url = url + "?";
|
||||
for (String key : params.keySet()) url = url.concat(key + "=" + params.get(key) + "&");
|
||||
url = Misc.substring(url);
|
||||
url = Utils.substring(url);
|
||||
}
|
||||
|
||||
public String execute(OkHttpClient client) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import android.util.Base64;
|
|||
|
||||
import com.github.catvod.crawler.SpiderDebug;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ public class JsonBasic {
|
|||
reqHeaders.remove("url");
|
||||
SpiderDebug.log(realUrl + url);
|
||||
String json = OkHttp.string(realUrl + url, reqHeaders);
|
||||
JSONObject taskResult = Misc.jsonParse(url, json);
|
||||
JSONObject taskResult = Utils.jsonParse(url, json);
|
||||
if (taskResult == null) continue;
|
||||
taskResult.put("jxFrom", jxName);
|
||||
SpiderDebug.log(taskResult.toString());
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.github.catvod.parser;
|
|||
|
||||
import com.github.catvod.crawler.SpiderDebug;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ public class JsonParallel {
|
|||
reqHeaders.remove("url");
|
||||
SpiderDebug.log(realUrl + url);
|
||||
String json = OkHttp.string(realUrl + url, ParseOKTag, reqHeaders);
|
||||
JSONObject taskResult = Misc.jsonParse(url, json);
|
||||
JSONObject taskResult = Utils.jsonParse(url, json);
|
||||
taskResult.put("jxFrom", jxName);
|
||||
SpiderDebug.log(taskResult.toString());
|
||||
return taskResult;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.github.catvod.parser;
|
|||
|
||||
import com.github.catvod.crawler.SpiderDebug;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ public class JsonSequence {
|
|||
reqHeaders.remove("url");
|
||||
SpiderDebug.log(realUrl + url);
|
||||
String json = OkHttp.string(realUrl + url, reqHeaders);
|
||||
JSONObject taskResult = Misc.jsonParse(url, json);
|
||||
JSONObject taskResult = Utils.jsonParse(url, json);
|
||||
if (taskResult == null) continue;
|
||||
taskResult.put("jxFrom", jxName);
|
||||
return taskResult;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import com.github.catvod.bean.alist.Item;
|
|||
import com.github.catvod.bean.alist.Sorter;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
import com.github.catvod.utils.Trans;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
|
@ -200,7 +200,7 @@ public class AList extends Spider {
|
|||
|
||||
private String findSubs(String path, List<Item> items) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Item item : items) if (Misc.isSub(item.getExt())) sb.append("~~~").append(item.getName()).append("@@@").append(item.getExt()).append("@@@").append(item.getVodId(path));
|
||||
for (Item item : items) if (Utils.isSub(item.getExt())) sb.append("~~~").append(item.getName()).append("@@@").append(item.getExt()).append("@@@").append(item.getVodId(path));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import com.github.catvod.bean.ali.Auth;
|
|||
import com.github.catvod.bean.ali.Data;
|
||||
import com.github.catvod.bean.ali.Item;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
import com.github.catvod.utils.Prefers;
|
||||
import com.github.catvod.utils.QRCode;
|
||||
import com.github.catvod.utils.Trans;
|
||||
|
|
@ -64,7 +64,7 @@ public class Ali {
|
|||
|
||||
private HashMap<String, String> getHeaders() {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", Misc.CHROME);
|
||||
headers.put("User-Agent", Utils.CHROME);
|
||||
headers.put("Referer", "https://www.aliyundrive.com/");
|
||||
return headers;
|
||||
}
|
||||
|
|
@ -159,7 +159,7 @@ public class Ali {
|
|||
folders.add(file);
|
||||
} else if (file.getCategory().equals("video") || file.getCategory().equals("audio")) {
|
||||
files.add(file.parent(parent.getName()));
|
||||
} else if (Misc.isSub(file.getExt())) {
|
||||
} else if (Utils.isSub(file.getExt())) {
|
||||
String key = file.removeExt();
|
||||
if (!subMap.containsKey(key)) subMap.put(key, new ArrayList<>());
|
||||
subMap.get(key).add(key + "@@@" + file.getExt() + "@@@" + file.getFileId());
|
||||
|
|
@ -306,12 +306,12 @@ public class Ali {
|
|||
|
||||
private void checkService() {
|
||||
if (service != null) service.shutdownNow();
|
||||
if (auth.getView() != null) Init.run(() -> Misc.removeView(auth.getView()));
|
||||
if (auth.getView() != null) Init.run(() -> Utils.removeView(auth.getView()));
|
||||
}
|
||||
|
||||
private void getQRCode() {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", Misc.CHROME);
|
||||
headers.put("User-Agent", Utils.CHROME);
|
||||
Data data = Data.objectFrom(OkHttp.string(QRCODE + "qr", headers));
|
||||
if (data != null) Init.run(() -> showCode(data));
|
||||
service = Executors.newScheduledThreadPool(1);
|
||||
|
|
@ -334,7 +334,7 @@ public class Ali {
|
|||
private void showCode(Data data) {
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.gravity = Gravity.CENTER;
|
||||
Misc.addView(create(data.getData().getCodeContent()), params);
|
||||
Utils.addView(create(data.getData().getCodeContent()), params);
|
||||
Init.show("請使用阿里雲盤 App 掃描二維碼");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import com.github.catvod.bean.Result;
|
|||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
import com.github.catvod.utils.Trans;
|
||||
|
||||
import org.json.JSONArray;
|
||||
|
|
@ -38,7 +38,7 @@ public class Bili extends Spider {
|
|||
|
||||
private void setHeader() throws Exception {
|
||||
header.put("cookie", getCookie(ext.getString("cookie")));
|
||||
header.put("User-Agent", Misc.CHROME);
|
||||
header.put("User-Agent", Utils.CHROME);
|
||||
header.put("Referer", url);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import com.github.catvod.bean.Result;
|
|||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
import com.github.catvod.utils.Trans;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
|
|
@ -32,7 +32,7 @@ public class Dm84 extends Spider {
|
|||
|
||||
private HashMap<String, String> getHeaders() {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", Misc.CHROME);
|
||||
headers.put("User-Agent", Utils.CHROME);
|
||||
return headers;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import com.github.catvod.bean.Result;
|
|||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
|
@ -75,7 +75,7 @@ public class Doll extends Spider {
|
|||
@Override
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
||||
HashMap<String, String> result = new HashMap<>();
|
||||
Misc.loadWebView(url + id, getClient(result));
|
||||
Utils.loadWebView(url + id, getClient(result));
|
||||
while (result.isEmpty()) SystemClock.sleep(10);
|
||||
return Result.get().url(result.get("url")).string();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import com.github.catvod.bean.Result;
|
|||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
|
@ -97,7 +97,7 @@ public class Eighteen extends Spider {
|
|||
@Override
|
||||
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
||||
HashMap<String, String> result = new HashMap<>();
|
||||
Misc.loadWebView(url + id, getClient(result));
|
||||
Utils.loadWebView(url + id, getClient(result));
|
||||
while (result.isEmpty()) SystemClock.sleep(10);
|
||||
return Result.get().url(result.get("url")).string();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import com.github.catvod.bean.Result;
|
|||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
|
@ -23,7 +23,7 @@ public class Hanime extends Spider {
|
|||
|
||||
private HashMap<String, String> getHeaders() {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", Misc.CHROME);
|
||||
headers.put("User-Agent", Utils.CHROME);
|
||||
return headers;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import com.github.catvod.bean.Result;
|
|||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
|
@ -26,7 +26,7 @@ public class Jable extends Spider {
|
|||
|
||||
private HashMap<String, String> getHeaders() {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", Misc.CHROME);
|
||||
headers.put("User-Agent", Utils.CHROME);
|
||||
return headers;
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ public class Jable extends Spider {
|
|||
vod.setVodYear(year.replace("上市於 ", ""));
|
||||
vod.setVodName(name);
|
||||
vod.setVodPlayFrom("Jable");
|
||||
vod.setVodPlayUrl("播放$" + Misc.getVar(doc.html(), "hlsUrl"));
|
||||
vod.setVodPlayUrl("播放$" + Utils.getVar(doc.html(), "hlsUrl"));
|
||||
return Result.string(vod);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import com.github.catvod.bean.Result;
|
|||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Element;
|
||||
|
|
@ -28,7 +28,7 @@ public class PanSou extends Spider {
|
|||
|
||||
private Map<String, String> getHeaders(String id) {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", Misc.CHROME);
|
||||
headers.put("User-Agent", Utils.CHROME);
|
||||
headers.put("Referer", siteUrl + id);
|
||||
headers.put("_bid", "6d14a5dd6c07980d9dc089a693805ad8");
|
||||
return headers;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import com.github.catvod.bean.Vod;
|
|||
import com.github.catvod.bean.paper.Data;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.jsoup.Jsoup;
|
||||
|
|
@ -35,7 +35,7 @@ public class Paper extends Spider {
|
|||
|
||||
private HashMap<String, String> getHeaders() {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", Misc.CHROME);
|
||||
headers.put("User-Agent", Utils.CHROME);
|
||||
return headers;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import android.content.Context;
|
|||
import com.github.catvod.bean.Result;
|
||||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -20,8 +20,8 @@ public class Push extends Spider {
|
|||
public String detailContent(List<String> ids) throws Exception {
|
||||
String url = ids.get(0).trim();
|
||||
if (url.contains("aliyundrive")) return Ali.get().detailContent(ids);
|
||||
if (Misc.isVip(url)) return Result.string(vod(url, "官源"));
|
||||
if (Misc.isVideoFormat(url)) return Result.string(vod(url, "直連"));
|
||||
if (Utils.isVip(url)) return Result.string(vod(url, "官源"));
|
||||
if (Utils.isVideoFormat(url)) return Result.string(vod(url, "直連"));
|
||||
return Result.string(vod(url, "網頁"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import com.github.catvod.bean.Result;
|
|||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
|
@ -33,7 +33,7 @@ public class Supjav extends Spider {
|
|||
|
||||
private HashMap<String, String> getHeaders(String referer) {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", Misc.CHROME);
|
||||
headers.put("User-Agent", Utils.CHROME);
|
||||
headers.put("Referer", referer);
|
||||
return headers;
|
||||
}
|
||||
|
|
@ -149,7 +149,7 @@ public class Supjav extends Spider {
|
|||
|
||||
private String parseTV(String redirect) {
|
||||
String data = OkHttp.string(redirect, getHeaders(playUrl));
|
||||
return Result.get().url(Misc.getVar(data, "urlPlay")).header(getHeaders(redirect)).string();
|
||||
return Result.get().url(Utils.getVar(data, "urlPlay")).header(getHeaders(redirect)).string();
|
||||
}
|
||||
|
||||
private String parseST(String redirect) {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import com.github.catvod.bean.upyun.Data;
|
|||
import com.github.catvod.bean.upyun.Item;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -25,7 +25,7 @@ public class UpYun extends Spider {
|
|||
|
||||
private Map<String, String> getHeaders() {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", Misc.CHROME);
|
||||
headers.put("User-Agent", Utils.CHROME);
|
||||
headers.put("Referer", siteUrl);
|
||||
return headers;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ import com.github.catvod.bean.Vod;
|
|||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.crawler.SpiderDebug;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
import com.github.catvod.utils.Trans;
|
||||
import com.github.catvod.xpath.XPathRule;
|
||||
import com.github.catvod.bean.xpath.Rule;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
|
@ -27,21 +27,21 @@ import java.util.Set;
|
|||
|
||||
public class XPath extends Spider {
|
||||
|
||||
protected XPathRule rule = null;
|
||||
protected Rule rule = null;
|
||||
|
||||
private HashMap<String, String> getHeaders() {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", rule.getUa().isEmpty() ? Misc.CHROME : rule.getUa());
|
||||
headers.put("User-Agent", rule.getUa().isEmpty() ? Utils.CHROME : rule.getUa());
|
||||
return headers;
|
||||
}
|
||||
|
||||
private void fetchRule(String ext) {
|
||||
if (ext.startsWith("http")) {
|
||||
String json = OkHttp.string(ext);
|
||||
rule = XPathRule.fromJson(json);
|
||||
rule = Rule.fromJson(json);
|
||||
loadRuleExt(json);
|
||||
} else {
|
||||
rule = XPathRule.fromJson(ext);
|
||||
rule = Rule.fromJson(ext);
|
||||
loadRuleExt(ext);
|
||||
}
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ public class XPath extends Spider {
|
|||
id = rule.getHomeVodIdR(id);
|
||||
String pic = vodNodes.get(i).selOne(rule.getHomeVodImg()).asString().trim();
|
||||
pic = rule.getHomeVodImgR(pic);
|
||||
pic = Misc.fixUrl(webUrl, pic);
|
||||
pic = Utils.fixUrl(webUrl, pic);
|
||||
String mark = "";
|
||||
if (!rule.getHomeVodMark().isEmpty()) {
|
||||
try {
|
||||
|
|
@ -114,7 +114,7 @@ public class XPath extends Spider {
|
|||
id = rule.getCateVodIdR(id);
|
||||
String pic = vodNodes.get(i).selOne(rule.getCateVodImg()).asString().trim();
|
||||
pic = rule.getCateVodImgR(pic);
|
||||
pic = Misc.fixUrl(webUrl, pic);
|
||||
pic = Utils.fixUrl(webUrl, pic);
|
||||
String mark = "";
|
||||
if (!rule.getCateVodMark().isEmpty()) {
|
||||
try {
|
||||
|
|
@ -142,7 +142,7 @@ public class XPath extends Spider {
|
|||
try {
|
||||
cover = vodNode.selOne(rule.getDetailImg()).asString().trim();
|
||||
cover = rule.getDetailImgR(cover);
|
||||
cover = Misc.fixUrl(webUrl, cover);
|
||||
cover = Utils.fixUrl(webUrl, cover);
|
||||
} catch (Exception e) {
|
||||
SpiderDebug.log(e);
|
||||
}
|
||||
|
|
@ -285,7 +285,7 @@ public class XPath extends Spider {
|
|||
id = rule.getSearchVodIdR(id);
|
||||
String pic = vod.optString(rule.getSearchVodImg()).trim();
|
||||
pic = rule.getSearchVodImgR(pic);
|
||||
pic = Misc.fixUrl(webUrl, pic);
|
||||
pic = Utils.fixUrl(webUrl, pic);
|
||||
String mark = vod.optString(rule.getSearchVodMark()).trim();
|
||||
mark = rule.getSearchVodMarkR(mark);
|
||||
list.add(new Vod(id, name, pic, mark));
|
||||
|
|
@ -304,7 +304,7 @@ public class XPath extends Spider {
|
|||
id = rule.getSearchVodIdR(id);
|
||||
String pic = vodNodes.get(i).selOne(rule.getSearchVodImg()).asString().trim();
|
||||
pic = rule.getSearchVodImgR(pic);
|
||||
pic = Misc.fixUrl(webUrl, pic);
|
||||
pic = Utils.fixUrl(webUrl, pic);
|
||||
String mark = "";
|
||||
if (!rule.getCateVodMark().isEmpty()) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import android.text.TextUtils;
|
|||
import android.util.Base64;
|
||||
|
||||
import com.github.catvod.crawler.SpiderDebug;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
|
@ -122,7 +122,7 @@ public class XPathMac extends XPath {
|
|||
}
|
||||
if (videoUrl != null) {
|
||||
// 適配2.0.6的調用應用內解析列表的支持, 需要配合直連分析和匹配官源解析一起使用,參考cjt影視和極品直連
|
||||
if (decodeVipFlag && Misc.isVip(videoUrl)) { // 使用jx:1
|
||||
if (decodeVipFlag && Utils.isVip(videoUrl)) { // 使用jx:1
|
||||
try {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("parse", 1);
|
||||
|
|
@ -145,7 +145,7 @@ public class XPathMac extends XPath {
|
|||
}
|
||||
}
|
||||
// 如果是視頻直連 直接返回免解
|
||||
else if (Misc.isVideoFormat(videoUrl)) {
|
||||
else if (Utils.isVideoFormat(videoUrl)) {
|
||||
try {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("parse", 0);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import android.webkit.WebViewClient;
|
|||
import com.github.catvod.bean.Result;
|
||||
import com.github.catvod.bean.yiso.Item;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
|
|
@ -40,7 +40,7 @@ public class YiSo extends Spider {
|
|||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return "";
|
||||
String url = "https://yiso.fun/api/search?name=" + URLEncoder.encode(key) + "&from=ali";
|
||||
Map<String, String> result = new HashMap<>();
|
||||
Misc.loadWebView(url, getWebViewClient(result));
|
||||
Utils.loadWebView(url, getWebViewClient(result));
|
||||
while (!result.containsKey("json")) SystemClock.sleep(50);
|
||||
String json = JsonParser.parseString(Objects.requireNonNull(result.get("json"))).getAsJsonPrimitive().getAsString();
|
||||
return Result.string(Item.objectFrom(json).getData().getList(key));
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import com.github.catvod.bean.Result;
|
|||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
import com.github.catvod.utils.Trans;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
|
|
@ -32,7 +32,7 @@ public class Ying extends Spider {
|
|||
|
||||
private HashMap<String, String> getHeaders() {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", Misc.CHROME);
|
||||
headers.put("User-Agent", Utils.CHROME);
|
||||
return headers;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import com.github.catvod.bean.Result;
|
|||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
import com.github.catvod.utils.Trans;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
|
|
@ -33,7 +33,7 @@ public class Ysj extends Spider {
|
|||
|
||||
private HashMap<String, String> getHeaders() {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", Misc.CHROME);
|
||||
headers.put("User-Agent", Utils.CHROME);
|
||||
return headers;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import com.github.catvod.bean.Result;
|
|||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Utils;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
|
@ -31,7 +31,7 @@ public class Zhaozy extends Spider {
|
|||
|
||||
private Map<String, String> getHeader() {
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", Misc.CHROME);
|
||||
headers.put("User-Agent", Utils.CHROME);
|
||||
headers.put("Referer", siteUrl);
|
||||
headers.put("Cookie", getCookie());
|
||||
return headers;
|
||||
|
|
@ -42,7 +42,7 @@ public class Zhaozy extends Spider {
|
|||
params.put("username", username);
|
||||
params.put("password", password);
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", Misc.CHROME);
|
||||
headers.put("User-Agent", Utils.CHROME);
|
||||
headers.put("Referer", siteUrl + "login.html");
|
||||
headers.put("Origin", siteUrl);
|
||||
Map<String, List<String>> resp = new HashMap<>();
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
package com.github.catvod.utils;
|
||||
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
public class Json {
|
||||
|
||||
public static String getString(String result, String column) {
|
||||
return JsonParser.parseString(result).getAsJsonObject().get(column).getAsString();
|
||||
}
|
||||
|
||||
public static int getInt(String result, String column) {
|
||||
return JsonParser.parseString(result).getAsJsonObject().get(column).getAsInt();
|
||||
}
|
||||
|
||||
public static long getLong(String result, String column) {
|
||||
return JsonParser.parseString(result).getAsJsonObject().get(column).getAsLong();
|
||||
}
|
||||
|
||||
public static boolean getBoolean(String result, String column) {
|
||||
return JsonParser.parseString(result).getAsJsonObject().get(column).getAsBoolean();
|
||||
}
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ public class QRCode {
|
|||
Map<EncodeHintType, Object> hints = new EnumMap<>(EncodeHintType.class);
|
||||
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
|
||||
hints.put(EncodeHintType.MARGIN, margin);
|
||||
return createBitmap(new MultiFormatWriter().encode(contents, BarcodeFormat.QR_CODE, Misc.dp2px(size), Misc.dp2px(size), hints));
|
||||
return createBitmap(new MultiFormatWriter().encode(contents, BarcodeFormat.QR_CODE, Utils.dp2px(size), Utils.dp2px(size), hints));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ import java.util.regex.Pattern;
|
|||
public class Sniffer {
|
||||
|
||||
public static final Pattern RULE = Pattern.compile(
|
||||
"http((?!http).){12,}?\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a)\\?.*|" +
|
||||
"http((?!http).){12,}\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a)"
|
||||
"http((?!http).){12,}?\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a|mp3)\\?.*|" +
|
||||
"http((?!http).){12,}\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a|mp3)|" +
|
||||
"http((?!http).)*?video/tos*"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class Misc {
|
||||
public class Utils {
|
||||
|
||||
public static final String CHROME = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36";
|
||||
public static final String CHROME = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36";
|
||||
|
||||
public static boolean isVip(String url) {
|
||||
List<String> hosts = Arrays.asList("iqiyi.com", "v.qq.com", "youku.com", "le.com", "tudou.com", "mgtv.com", "sohu.com", "acfun.cn", "bilibili.com", "baofeng.com", "pptv.com");
|
||||
|
|
@ -82,7 +82,7 @@ public class Misc {
|
|||
headers.put("User-Agent", "Mozilla/5.0");
|
||||
} else if (input.contains("bilibili")) {
|
||||
headers.put("Referer", "https://www.bilibili.com/");
|
||||
headers.put("User-Agent", Misc.CHROME);
|
||||
headers.put("User-Agent", CHROME);
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ public class Misc {
|
|||
if (ua.trim().length() > 0) headers.put("User-Agent", ua);
|
||||
String referer = jsonPlayData.optString("referer", "");
|
||||
if (referer.trim().length() > 0) headers.put("Referer", referer);
|
||||
headers = Misc.fixJsonVodHeader(headers, input, url);
|
||||
headers = Utils.fixJsonVodHeader(headers, input, url);
|
||||
JSONObject taskResult = new JSONObject();
|
||||
taskResult.put("header", headers);
|
||||
taskResult.put("url", url);
|
||||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
8442882c682a5045ef214f42540ab28d
|
||||
4f59dbb5aa3eebcfebd3df5d216d83a8
|
||||
|
|
|
|||
Loading…
Reference in New Issue