Merge remote-tracking branch 'origin/main'

# Conflicts:
#	app/src/main/java/com/github/catvod/utils/Utils.java
#	jar/custom_spider.jar
#	jar/custom_spider.jar.md5
This commit is contained in:
dukun 2023-02-08 13:21:01 +08:00
commit 5a3a860b17
37 changed files with 322 additions and 153 deletions

View File

@ -1,7 +1,6 @@
package com.github.catvod.bean.ali;
import android.text.TextUtils;
import android.widget.ImageView;
public class Auth {
@ -9,7 +8,6 @@ public class Auth {
private String accessToken;
private String shareToken;
private String shareId;
private ImageView view;
public String getRefreshToken() {
return TextUtils.isEmpty(refreshToken) ? "" : refreshToken;
@ -43,14 +41,6 @@ public class Auth {
this.shareId = shareId;
}
public ImageView getView() {
return view;
}
public void setView(ImageView view) {
this.view = view;
}
public boolean isEmpty() {
return getAccessToken().isEmpty();
}

View File

@ -0,0 +1,66 @@
package com.github.catvod.bean.ali;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class Biz {
@SerializedName("pds_login_result")
private Biz pdsLoginResult;
@SerializedName("role")
private String role;
@SerializedName("isFirstLogin")
private Boolean isFirstLogin;
@SerializedName("needLink")
private Boolean needLink;
@SerializedName("loginType")
private String loginType;
@SerializedName("nickName")
private String nickName;
@SerializedName("needRpVerify")
private Boolean needRpVerify;
@SerializedName("avatar")
private String avatar;
@SerializedName("accessToken")
private String accessToken;
@SerializedName("userName")
private String userName;
@SerializedName("userId")
private String userId;
@SerializedName("defaultDriveId")
private String defaultDriveId;
@SerializedName("existLink")
private List<?> existLink;
@SerializedName("expiresIn")
private Integer expiresIn;
@SerializedName("expireTime")
private String expireTime;
@SerializedName("requestId")
private String requestId;
@SerializedName("dataPinSetup")
private Boolean dataPinSetup;
@SerializedName("state")
private String state;
@SerializedName("tokenType")
private String tokenType;
@SerializedName("dataPinSaved")
private Boolean dataPinSaved;
@SerializedName("refreshToken")
private String refreshToken;
@SerializedName("status")
private String status;
public static Biz objectFrom(String str) {
return new Gson().fromJson(str, Biz.class);
}
public Biz getPdsLoginResult() {
return pdsLoginResult;
}
public String getRefreshToken() {
return refreshToken;
}
}

View File

@ -1,24 +1,34 @@
package com.github.catvod.bean.ali;
import android.util.Base64;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.util.HashMap;
import java.util.Map;
public class Data {
@SerializedName(value = "data", alternate = "pds_login_result")
@SerializedName("data")
private Data data;
@SerializedName("content")
private Data content;
@SerializedName("t")
private String t;
@SerializedName("ck")
private String ck;
@SerializedName("codeContent")
private String codeContent;
@SerializedName("refreshToken")
private String refreshToken;
@SerializedName("qrCodeStatus")
private String qrCodeStatus;
@SerializedName("bizExt")
private String bizExt;
public static Data objectFrom(String str) {
try {
return new Gson().fromJson(str, Data.class);
Data data = new Gson().fromJson(str, Data.class);
return data == null ? new Data() : data;
} catch (Exception e) {
return new Data();
}
@ -28,8 +38,8 @@ public class Data {
return data == null ? new Data() : data;
}
public boolean hasToken() {
return getData().getRefreshToken().length() > 0;
public Data getContent() {
return content == null ? new Data() : content;
}
public String getT() {
@ -44,7 +54,35 @@ public class Data {
return codeContent == null ? "" : codeContent;
}
public String getRefreshToken() {
return refreshToken == null ? "" : refreshToken;
public String getQrCodeStatus() {
return qrCodeStatus == null ? "" : qrCodeStatus;
}
public String getBizExt() {
return bizExt == null ? "" : bizExt;
}
public String getToken() {
return Biz.objectFrom(new String(Base64.decode(getBizExt(), Base64.DEFAULT))).getPdsLoginResult().getRefreshToken();
}
public boolean hasToken() {
return getQrCodeStatus().equals("CONFIRMED") && getBizExt().length() > 0;
}
public Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("t", getT());
params.put("ck", getCk());
params.put("appName", "aliyun_drive");
params.put("appEntrance", "web");
params.put("isMobile", "false");
params.put("lang", "zh_CN");
params.put("returnUrl", "");
params.put("fromSite", "52");
params.put("bizParams", "");
params.put("navlanguage", "zh-CN");
params.put("navPlatform", "MacIntel");
return params;
}
}

View File

@ -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() {

View File

@ -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() {

View File

@ -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();

View File

@ -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) {

View File

@ -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());

View File

@ -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;

View File

@ -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;

View File

@ -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();
}

View File

@ -1,5 +1,9 @@
package com.github.catvod.spider;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.SystemClock;
import android.text.TextUtils;
import android.view.Gravity;
@ -13,11 +17,10 @@ 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.Prefers;
import com.github.catvod.utils.QRCode;
import com.github.catvod.utils.Trans;
import com.google.gson.JsonObject;
import com.github.catvod.utils.Utils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -43,6 +46,7 @@ public class Ali {
public static final Pattern pattern = Pattern.compile("www.aliyundrive.com/s/([^/]+)(/folder/([^/]+))?");
private ScheduledExecutorService service;
private final Auth auth;
private AlertDialog dialog;
private static class Loader {
static volatile Ali INSTANCE = new Ali();
@ -63,7 +67,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;
}
@ -100,7 +104,8 @@ public class Ali {
if (!matcher.find()) return "";
String shareId = matcher.group(1);
String fileId = matcher.groupCount() == 3 ? matcher.group(3) : "";
auth.setShareId(shareId); refreshShareToken();
auth.setShareId(shareId);
refreshShareToken();
return Result.string(getVod(url, fileId));
}
@ -157,7 +162,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());
@ -193,7 +198,7 @@ public class Ali {
auth.setRefreshToken(object.getString("refresh_token"));
return true;
} catch (Exception e) {
checkService();
stopService();
auth.clean();
getQRCode();
return true;
@ -302,23 +307,33 @@ public class Ali {
return result;
}
private void checkService() {
if (service != null) service.shutdownNow();
if (auth.getView() != null) Init.run(() -> Misc.removeView(auth.getView()));
private void getQRCode() {
Data data = Data.objectFrom(OkHttp.string("https://passport.aliyundrive.com/newlogin/qrcode/generate.do?appName=aliyun_drive&fromSite=52&appName=aliyun_drive&appEntrance=web&isMobile=false&lang=zh_CN&returnUrl=&bizParams=&_bx-v=2.2.3")).getContent().getData();
Init.run(() -> showQRCode(data));
}
private void getQRCode() {
HashMap<String, String> headers = new HashMap<>();
headers.put("User-Agent", Misc.CHROME);
Data data = Data.objectFrom(OkHttp.string("https://token.cooluc.com/qr", headers));
if (data != null) Init.run(() -> showCode(data));
private void showQRCode(Data data) {
try {
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(Utils.dp2px(240), Utils.dp2px(240));
ImageView image = new ImageView(Init.context());
image.setScaleType(ImageView.ScaleType.CENTER_CROP);
image.setImageBitmap(QRCode.getBitmap(data.getCodeContent(), 240, 2));
FrameLayout frame = new FrameLayout(Init.context());
params.gravity = Gravity.CENTER;
frame.addView(image, params);
dialog = new AlertDialog.Builder(Init.getActivity()).setView(frame).setOnDismissListener(this::dismiss).show();
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
Init.execute(() -> startService(data.getParams()));
Init.show("請使用阿里雲盤 App 掃描二維碼");
} catch (Exception ignored) {
}
}
private void startService(Map<String, String> params) {
service = Executors.newScheduledThreadPool(1);
if (data != null) service.scheduleAtFixedRate(() -> {
JsonObject params = new JsonObject();
params.addProperty("t", data.getData().getT());
params.addProperty("ck", data.getData().getCk());
Data result = Data.objectFrom(OkHttp.postJson("https://easy-token.cooluc.com/ck", params.toString(), headers));
if (result.hasToken()) setToken(result.getData().getRefreshToken());
service.scheduleAtFixedRate(() -> {
Data result = Data.objectFrom(OkHttp.post("https://passport.aliyundrive.com/newlogin/qrcode/query.do?appName=aliyun_drive&fromSite=52&_bx-v=2.2.3", params)).getContent().getData();
if (result.hasToken()) setToken(result.getToken());
}, 1, 1, TimeUnit.SECONDS);
}
@ -326,21 +341,22 @@ public class Ali {
Prefers.put("token", value);
Init.show("請重新進入播放頁");
auth.setRefreshToken(value);
checkService();
stopService();
}
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);
Init.show("請使用阿里雲盤 App 掃描二維碼");
private void stopService() {
if (service != null) service.shutdownNow();
Init.run(this::dismiss);
}
private ImageView create(String value) {
ImageView view = new ImageView(Init.context());
view.setScaleType(ImageView.ScaleType.CENTER_CROP);
view.setImageBitmap(QRCode.getBitmap(value, 250, 2));
auth.setView(view);
return view;
private void dismiss(DialogInterface dialog) {
stopService();
}
private void dismiss() {
try {
if (dialog != null) dialog.dismiss();
} catch (Exception ignored) {
}
}
}

View File

@ -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 Bili11 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);
}

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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;
}

View File

@ -12,9 +12,12 @@ import com.github.catvod.utils.Trans;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class Init {
private final ExecutorService executor;
private final Handler handler;
private Application app;
@ -28,6 +31,7 @@ public class Init {
public Init() {
this.handler = new Handler(Looper.getMainLooper());
this.executor = Executors.newFixedThreadPool(5);
}
public static Application context() {
@ -40,6 +44,10 @@ public class Init {
Trans.init();
}
public static void execute(Runnable runnable) {
get().executor.execute(runnable);
}
public static void run(Runnable runnable) {
get().handler.post(runnable);
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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, "網頁"));
}

View File

@ -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) {

View File

@ -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;
}

View File

@ -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 {

View File

@ -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);

View File

@ -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;
@ -41,7 +41,7 @@ public class YiSo extends Spider {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return "";
String url = "https://yiso.fun/api/search?name=4k " + 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));

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<>();

View File

@ -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();
}
}

View File

@ -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;

View File

@ -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*"
);
}

View File

@ -24,7 +24,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/109.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/108.0.0.0 Safari/537.36";
public static Charset CharsetUTF8 = Charset.forName("UTF-8");
@ -85,7 +87,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;
}
@ -101,7 +103,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);

View File

@ -1,5 +1,5 @@
{
"spider": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;e5b681f675bb3bde7f94196f60235829",
"spider": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;5f350e3b859432e66db59eebc3ccce78",
"wallpaper": "https://gao.chuqiuyu.tk",
"lives": [
{
@ -611,7 +611,7 @@
"searchable": 1,
"filterable": 1,
"switchable": 0,
"ext": "http://我不是.肥猫.love:63/token.php"
"ext": "https://agit.ai/Yoursmile7/TVBox/raw/branch/master/token.txt"
}
]
}

70
json/ali.json Normal file
View File

@ -0,0 +1,70 @@
{
"sites": [
{
"key": "紙條",
"name": "紙條",
"type": 3,
"api": "csp_Paper",
"searchable": 1,
"filterable": 1,
"switchable": 0,
"ext": "https://agit.ai/Yoursmile7/TVBox/raw/branch/master/token.txt",
"jar": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;5f350e3b859432e66db59eebc3ccce78"
},
{
"key": "易搜",
"name": "易搜",
"type": 3,
"api": "csp_YiSo",
"searchable": 1,
"filterable": 0,
"switchable": 0,
"ext": "https://agit.ai/Yoursmile7/TVBox/raw/branch/master/token.txt",
"jar": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;5f350e3b859432e66db59eebc3ccce78"
},
{
"key": "盤搜",
"name": "盤搜",
"type": 3,
"api": "csp_PanSou",
"searchable": 1,
"filterable": 0,
"switchable": 0,
"ext": "https://agit.ai/Yoursmile7/TVBox/raw/branch/master/token.txt",
"jar": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;5f350e3b859432e66db59eebc3ccce78"
},
{
"key": "UP雲搜",
"name": "UP雲搜",
"type": 3,
"api": "csp_UpYun",
"searchable": 1,
"filterable": 0,
"switchable": 0,
"ext": "https://agit.ai/Yoursmile7/TVBox/raw/branch/master/token.txt",
"jar": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;5f350e3b859432e66db59eebc3ccce78"
},
{
"key": "找資源",
"name": "找資源",
"type": 3,
"api": "csp_Zhaozy",
"searchable": 1,
"filterable": 0,
"switchable": 0,
"ext": "https://agit.ai/Yoursmile7/TVBox/raw/branch/master/token.txt$$$yingshi$$$abcd1234",
"jar": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;5f350e3b859432e66db59eebc3ccce78"
},
{
"key": "push_agent",
"name": "推送",
"type": 3,
"api": "csp_Push",
"searchable": 1,
"filterable": 0,
"switchable": 0,
"ext": "https://agit.ai/Yoursmile7/TVBox/raw/branch/master/token.txt",
"jar": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;5f350e3b859432e66db59eebc3ccce78"
}
]
}

View File

@ -1,5 +1,5 @@
{
"spider": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;e5b681f675bb3bde7f94196f60235829",
"spider": "https://gh-proxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;5f350e3b859432e66db59eebc3ccce78",
"wallpaper": "http://www.kf666888.cn/api/tvbox/img",
"lives": [
{
@ -125,7 +125,7 @@
"searchable": 1,
"filterable": 1,
"switchable": 0,
"ext": "http://我不是.肥猫.love:63/token.php"
"ext": "https://agit.ai/Yoursmile7/TVBox/raw/branch/master/token.txt"
},
{
"key": "易搜",
@ -135,7 +135,7 @@
"searchable": 1,
"filterable": 0,
"switchable": 0,
"ext": "http://我不是.肥猫.love:63/token.php"
"ext": "https://agit.ai/Yoursmile7/TVBox/raw/branch/master/token.txt"
},
{
"key": "盤搜",
@ -145,7 +145,7 @@
"searchable": 1,
"filterable": 0,
"switchable": 0,
"ext": "http://我不是.肥猫.love:63/token.php"
"ext": "https://agit.ai/Yoursmile7/TVBox/raw/branch/master/token.txt"
},
{
"key": "UP雲搜",
@ -155,7 +155,7 @@
"searchable": 1,
"filterable": 0,
"switchable": 0,
"ext": "http://我不是.肥猫.love:63/token.php"
"ext": "https://agit.ai/Yoursmile7/TVBox/raw/branch/master/token.txt"
},
{
"key": "找資源",
@ -165,7 +165,7 @@
"searchable": 1,
"filterable": 0,
"switchable": 0,
"ext": "http://我不是.肥猫.love:63/token.php$$$yingshi$$$abcd1234"
"ext": "https://agit.ai/Yoursmile7/TVBox/raw/branch/master/token.txt$$$yingshi$$$abcd1234"
},
{
"key": "Live",
@ -185,7 +185,7 @@
"searchable": 1,
"filterable": 0,
"switchable": 0,
"ext": "http://我不是.肥猫.love:63/token.php"
"ext": "https://agit.ai/Yoursmile7/TVBox/raw/branch/master/token.txt"
}
]
}