Merge branch 'main' of https://github.com/FongMi/CatVodSpider
This commit is contained in:
commit
06d60b2bbf
|
|
@ -39,7 +39,6 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executors;
|
||||
|
|
@ -47,6 +46,8 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import okhttp3.Response;
|
||||
|
||||
public class API {
|
||||
|
||||
private final Map<String, String> quality;
|
||||
|
|
@ -261,12 +262,12 @@ public class API {
|
|||
String result = post("adrive/v3/share_link/get_share_by_anonymous", body);
|
||||
JSONObject object = new JSONObject(result);
|
||||
List<Item> files = new ArrayList<>();
|
||||
LinkedHashMap<String, List<String>> subMap = new LinkedHashMap<>();
|
||||
listFiles(new Item(getParentFileId(fileId, object)), files, subMap);
|
||||
List<Item> subs = new ArrayList<>();
|
||||
listFiles(new Item(getParentFileId(fileId, object)), files, subs);
|
||||
List<String> playFrom = Arrays.asList("原畫", "超清", "高清");
|
||||
List<String> episode = new ArrayList<>();
|
||||
List<String> playUrl = new ArrayList<>();
|
||||
for (Item file : files) episode.add(file.getDisplayName() + "$" + file.getFileId() + findSubs(file.getName(), subMap));
|
||||
for (Item file : files) episode.add(file.getDisplayName() + "$" + file.getFileId() + findSubs(file.getName(), subs));
|
||||
for (int i = 0; i < playFrom.size(); i++) playUrl.add(TextUtils.join("#", episode));
|
||||
Vod vod = new Vod();
|
||||
vod.setVodId(url);
|
||||
|
|
@ -279,11 +280,11 @@ public class API {
|
|||
return vod;
|
||||
}
|
||||
|
||||
private void listFiles(Item folder, List<Item> files, LinkedHashMap<String, List<String>> subMap) throws Exception {
|
||||
listFiles(folder, files, subMap, "");
|
||||
private void listFiles(Item folder, List<Item> files, List<Item> subs) throws Exception {
|
||||
listFiles(folder, files, subs, "");
|
||||
}
|
||||
|
||||
private void listFiles(Item parent, List<Item> files, LinkedHashMap<String, List<String>> subMap, String marker) throws Exception {
|
||||
private void listFiles(Item parent, List<Item> files, List<Item> subs, String marker) throws Exception {
|
||||
JSONObject body = new JSONObject();
|
||||
List<Item> folders = new ArrayList<>();
|
||||
body.put("limit", 200);
|
||||
|
|
@ -299,16 +300,14 @@ public class API {
|
|||
} else if (file.getCategory().equals("video") || file.getCategory().equals("audio")) {
|
||||
files.add(file.parent(parent.getName()));
|
||||
} else if (Utils.isSub(file.getExt())) {
|
||||
String key = Utils.removeExt(file.getName());
|
||||
if (!subMap.containsKey(key)) subMap.put(key, new ArrayList<>());
|
||||
subMap.get(key).add(key + "@@@" + file.getExt() + "@@@" + file.getFileId());
|
||||
subs.add(file);
|
||||
}
|
||||
}
|
||||
if (item.getNextMarker().length() > 0) {
|
||||
listFiles(parent, files, subMap, item.getNextMarker());
|
||||
listFiles(parent, files, subs, item.getNextMarker());
|
||||
}
|
||||
for (Item folder : folders) {
|
||||
listFiles(folder, files, subMap);
|
||||
listFiles(folder, files, subs);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -322,18 +321,19 @@ public class API {
|
|||
return "";
|
||||
}
|
||||
|
||||
private String findSubs(String name, Map<String, List<String>> subMap) {
|
||||
name = name.substring(0, name.lastIndexOf("."));
|
||||
List<String> subs = subMap.get(name);
|
||||
if (subs != null && subs.size() > 0) return combineSubs(subs);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Map.Entry<String, List<String>> entry : subMap.entrySet()) sb.append(combineSubs(entry.getValue()));
|
||||
return sb.toString();
|
||||
private void pair(String name1, List<Item> items, List<Item> subs) {
|
||||
for (Item item : items) {
|
||||
String name2 = Utils.removeExt(item.getName()).toLowerCase();
|
||||
if (name1.contains(name2) || name2.contains(name1)) subs.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
private String combineSubs(List<String> subs) {
|
||||
private String findSubs(String name1, List<Item> items) {
|
||||
List<Item> subs = new ArrayList<>();
|
||||
pair(Utils.removeExt(name1).toLowerCase(), items, subs);
|
||||
if (subs.isEmpty()) subs.addAll(items);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String sub : subs) sb.append("+").append(sub);
|
||||
for (Item sub : subs) sb.append("+").append(Utils.removeExt(sub.getName())).append("@@@").append(sub.getExt()).append("@@@").append(sub.getFileId());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
|
@ -457,13 +457,14 @@ public class API {
|
|||
}
|
||||
}
|
||||
|
||||
public Object[] proxySub(Map<String, String> params) {
|
||||
public Object[] proxySub(Map<String, String> params) throws Exception {
|
||||
String fileId = params.get("file_id");
|
||||
String text = OkHttp.string(getDownloadUrl(fileId), getHeaderAuth());
|
||||
Response res = OkHttp.newCall(getDownloadUrl(fileId), getHeaderAuth());
|
||||
byte[] body = Utils.getUTF8(res.body().bytes());
|
||||
Object[] result = new Object[3];
|
||||
result[0] = 200;
|
||||
result[1] = "application/octet-stream";
|
||||
result[2] = new ByteArrayInputStream(text.getBytes());
|
||||
result[2] = new ByteArrayInputStream(body);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class Ali extends Spider {
|
|||
return flag.equals("原畫") ? API.get().playerContent(ids) : API.get().playerContent(ids, flag);
|
||||
}
|
||||
|
||||
public static Object[] proxy(Map<String, String> params) {
|
||||
public static Object[] proxy(Map<String, String> params) throws Exception {
|
||||
String type = params.get("type");
|
||||
if (type.equals("sub")) return API.get().proxySub(params);
|
||||
if (type.equals("token")) return API.get().getToken();
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author ColaMint & FongMi
|
||||
* @author ColaMint & FongMi & 唐三
|
||||
*/
|
||||
public class Bili extends Spider {
|
||||
|
||||
|
|
@ -47,11 +47,8 @@ public class Bili extends Spider {
|
|||
private String getCookie() {
|
||||
String cache = Prefers.getString("BiliCookie");
|
||||
if (!TextUtils.isEmpty(cache)) return cache;
|
||||
if (!ext.optString("cookie").isEmpty()) {
|
||||
if (ext.optString("cookie").startsWith("http")) return OkHttp.string(ext.optString("cookie")).replace("\n", "").trim();
|
||||
return ext.optString("cookie");
|
||||
}
|
||||
return "buvid3=84B0395D-C9F2-C490-E92E-A09AB48FE26E71636infoc";
|
||||
if (ext.optString("cookie").startsWith("http")) return OkHttp.string(ext.optString("cookie")).replace("\n", "").trim();
|
||||
return ext.optString("cookie", "buvid3=84B0395D-C9F2-C490-E92E-A09AB48FE26E71636infoc");
|
||||
}
|
||||
|
||||
private void setHeader() {
|
||||
|
|
@ -60,27 +57,27 @@ public class Bili extends Spider {
|
|||
header.put("User-Agent", Utils.CHROME);
|
||||
}
|
||||
|
||||
private void generate() throws Exception {
|
||||
ext = new JSONObject();
|
||||
JSONArray classes = new JSONArray();
|
||||
JSONObject filters = new JSONObject();
|
||||
ext.put("classes", classes);
|
||||
ext.put("filter", filters);
|
||||
JSONArray filter = new JSONArray("[{\"key\":\"order\",\"name\":\"排序\",\"value\":[{\"n\":\"综合排序\",\"v\":\"0\"},{\"n\":\"最多点击\",\"v\":\"click\"},{\"n\":\"最新发布\",\"v\":\"pubdate\"},{\"n\":\"最多弹幕\",\"v\":\"dm\"},{\"n\":\"最多收藏\",\"v\":\"stow\"}]},{\"key\":\"duration\",\"name\":\"时长\",\"value\":[{\"n\":\"全部时长\",\"v\":\"0\"},{\"n\":\"60分钟以上\",\"v\":\"4\"},{\"n\":\"30~60分钟\",\"v\":\"3\"},{\"n\":\"10~30分钟\",\"v\":\"2\"},{\"n\":\"10分钟以下\",\"v\":\"1\"}]}]");
|
||||
String[] types = extend.split("#");
|
||||
for (String type : types) {
|
||||
JSONObject c = new JSONObject();
|
||||
c.put("type_name", type);
|
||||
c.put("type_id", type);
|
||||
filters.put(type, filter);
|
||||
classes.put(c);
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchRule() throws Exception {
|
||||
if (header.containsKey("cookie") && header.get("cookie").length() > 0) return;
|
||||
if (extend.startsWith("http")) {
|
||||
extend = OkHttp.string(extend);
|
||||
ext = new JSONObject(extend);
|
||||
} else {
|
||||
JSONArray newFilter = new JSONArray("[{\"key\":\"order\",\"name\":\"排序\",\"value\":[{\"n\":\"综合排序\",\"v\":\"0\"},{\"n\":\"最多点击\",\"v\":\"click\"},{\"n\":\"最新发布\",\"v\":\"pubdate\"},{\"n\":\"最多弹幕\",\"v\":\"dm\"},{\"n\":\"最多收藏\",\"v\":\"stow\"}]},{\"key\":\"duration\",\"name\":\"时长\",\"value\":[{\"n\":\"全部时长\",\"v\":\"0\"},{\"n\":\"60分钟以上\",\"v\":\"4\"},{\"n\":\"30~60分钟\",\"v\":\"3\"},{\"n\":\"10~30分钟\",\"v\":\"2\"},{\"n\":\"10分钟以下\",\"v\":\"1\"}]}]");
|
||||
String[] typeC = extend.split("#");
|
||||
JSONArray classes = new JSONArray();
|
||||
JSONObject filters = new JSONObject();
|
||||
for (String kk : typeC) {
|
||||
JSONObject c = new JSONObject();
|
||||
c.put("type_name", kk);
|
||||
c.put("type_id", kk);
|
||||
classes.put(c);
|
||||
filters.put(kk, newFilter);
|
||||
}
|
||||
ext = new JSONObject();
|
||||
ext.put("classes", classes);
|
||||
ext.put("filter", filters);
|
||||
}
|
||||
if (extend.startsWith("http")) ext = new JSONObject(extend = OkHttp.string(extend));
|
||||
else generate();
|
||||
setHeader();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import android.webkit.WebViewClient;
|
|||
import com.github.catvod.spider.Init;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
|
@ -48,6 +49,21 @@ public class Utils {
|
|||
return hasCamera && hasPhone && hasBT;
|
||||
}
|
||||
|
||||
public static boolean isGBK(byte[] bytes) {
|
||||
Charset charset = Charset.forName("GBK");
|
||||
String str = new String(bytes, charset);
|
||||
byte[] newBytes = str.getBytes(charset);
|
||||
return Arrays.equals(bytes, newBytes);
|
||||
}
|
||||
|
||||
public static byte[] getUTF8(byte[] bytes) throws Exception {
|
||||
if (isGBK(bytes)) {
|
||||
return new String(bytes, Charset.forName("GBK")).getBytes("UTF-8");
|
||||
} else {
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSub(String ext) {
|
||||
return ext.equals("srt") || ext.equals("ass") || ext.equals("ssa");
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
af37ed94ebfb6af49a33d48a6fe005da
|
||||
b33ab66a0bc515720d7e9083fb52fbfc
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;af37ed94ebfb6af49a33d48a6fe005da",
|
||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;b33ab66a0bc515720d7e9083fb52fbfc",
|
||||
"wallpaper": "https://gao.chuqiuyu.tk",
|
||||
"sites": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;af37ed94ebfb6af49a33d48a6fe005da",
|
||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;b33ab66a0bc515720d7e9083fb52fbfc",
|
||||
"wallpaper": "http://饭太硬.ga/深色壁纸/api.php",
|
||||
"sites": [
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue