Update alist
This commit is contained in:
parent
29f3a7b3d5
commit
753316d510
|
|
@ -0,0 +1,90 @@
|
|||
package com.github.catvod.bean.alist;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.github.catvod.bean.Class;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Config {
|
||||
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
@SerializedName("server")
|
||||
private String server;
|
||||
@SerializedName("password")
|
||||
private String password;
|
||||
@SerializedName("version")
|
||||
private int version;
|
||||
|
||||
public static List<Config> arrayFrom(String str) {
|
||||
Type listType = new TypeToken<ArrayList<Config>>() {
|
||||
}.getType();
|
||||
return new Gson().fromJson(str, listType);
|
||||
}
|
||||
|
||||
public Config(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return TextUtils.isEmpty(name) ? "" : name;
|
||||
}
|
||||
|
||||
public String getServer() {
|
||||
return TextUtils.isEmpty(server) ? "" : server;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return TextUtils.isEmpty(password) ? "" : password;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public boolean isNew() {
|
||||
return getVersion() == 3;
|
||||
}
|
||||
|
||||
public Class toType() {
|
||||
return new Class(getName(), getName(), "1");
|
||||
}
|
||||
|
||||
public String settingsApi() {
|
||||
return getServer() + "/api/public/settings";
|
||||
}
|
||||
|
||||
public String listApi() {
|
||||
return getServer() + (isNew() ? "/api/fs/list" : "/api/public/path");
|
||||
}
|
||||
|
||||
public String getApi() {
|
||||
return getServer() + (isNew() ? "/api/fs/get" : "/api/public/path");
|
||||
}
|
||||
|
||||
public String searchApi() {
|
||||
return getServer() + "/api/public/search";
|
||||
}
|
||||
|
||||
public String searchApi(String param) {
|
||||
return getServer() + "/search?box=" + param + "&url=";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof Config)) return false;
|
||||
Config it = (Config) obj;
|
||||
return getName().equals(it.getName());
|
||||
}
|
||||
}
|
||||
|
|
@ -6,16 +6,14 @@ import com.github.catvod.bean.Class;
|
|||
import com.github.catvod.bean.Filter;
|
||||
import com.github.catvod.bean.Result;
|
||||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.bean.alist.Config;
|
||||
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.OkHttpUtil;
|
||||
import com.github.catvod.utils.Misc;
|
||||
import com.github.catvod.utils.Trans;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
|
@ -28,48 +26,12 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
public class AList extends Spider {
|
||||
|
||||
private LinkedHashMap<String, String> ext;
|
||||
private Map<String, String> map;
|
||||
private String extend;
|
||||
|
||||
private boolean isJson(String json) {
|
||||
try {
|
||||
JsonParser.parseString(json);
|
||||
return true;
|
||||
} catch (JsonSyntaxException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void parseJson(String extend) throws Exception {
|
||||
JSONObject object = new JSONObject(extend);
|
||||
JSONArray array = object.names();
|
||||
ext = new LinkedHashMap<>();
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
String key = array.getString(i);
|
||||
ext.put(key, object.getString(key));
|
||||
}
|
||||
}
|
||||
|
||||
private void parseText(String extend) {
|
||||
String[] array = extend.split("#");
|
||||
ext = new LinkedHashMap<>();
|
||||
for (String text : array) {
|
||||
String[] arr = text.split("\\$");
|
||||
if (arr.length == 2) ext.put(arr[0], arr[1]);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean v3(String key) {
|
||||
if (!map.containsKey(key)) map.put(key, OkHttpUtil.string(ext.get(key) + "/api/public/settings").contains("v3.") ? "3" : "2");
|
||||
return Objects.equals(map.get(key), "3");
|
||||
}
|
||||
private List<Config> configs;
|
||||
private String ext;
|
||||
|
||||
private List<Filter> getFilter() {
|
||||
List<Filter> items = new ArrayList<>();
|
||||
|
|
@ -78,18 +40,21 @@ public class AList extends Spider {
|
|||
return items;
|
||||
}
|
||||
|
||||
private void fetchRule() throws Exception {
|
||||
if (ext != null && !ext.isEmpty()) return;
|
||||
if (extend.startsWith("http")) extend = OkHttpUtil.string(extend);
|
||||
if (isJson(extend)) parseJson(extend);
|
||||
else parseText(extend);
|
||||
private void fetchRule() {
|
||||
if (configs != null && !configs.isEmpty()) return;
|
||||
configs = Config.arrayFrom(ext);
|
||||
}
|
||||
|
||||
private Config getConfig(String name) {
|
||||
Config config = configs.get(configs.indexOf(new Config(name)));
|
||||
if (config.getVersion() == 0) config.setVersion(OkHttpUtil.string(config.settingsApi()).contains("v3.") ? 3 : 2);
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context, String extend) {
|
||||
try {
|
||||
this.map = new HashMap<>();
|
||||
this.extend = extend;
|
||||
ext = extend;
|
||||
fetchRule();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
|
@ -100,7 +65,7 @@ public class AList extends Spider {
|
|||
fetchRule();
|
||||
List<Class> classes = new ArrayList<>();
|
||||
LinkedHashMap<String, List<Filter>> filters = new LinkedHashMap<>();
|
||||
for (String key : ext.keySet()) classes.add(new Class(key, key, "1"));
|
||||
for (Config config : configs) classes.add(config.toType());
|
||||
for (Class item : classes) filters.put(item.getTypeId(), getFilter());
|
||||
return Result.string(classes, filters);
|
||||
}
|
||||
|
|
@ -145,11 +110,12 @@ public class AList extends Spider {
|
|||
try {
|
||||
String key = id.contains("/") ? id.substring(0, id.indexOf("/")) : id;
|
||||
String path = id.contains("/") ? id.substring(id.indexOf("/") + 1) : "";
|
||||
String url = ext.get(key) + (v3(key) ? "/api/fs/get" : "/api/public/path");
|
||||
Config config = getConfig(key);
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("path", path);
|
||||
String response = OkHttpUtil.postJson(url, params.toString());
|
||||
String json = v3(key) ? new JSONObject(response).getJSONObject("data").toString() : new JSONObject(response).getJSONObject("data").getJSONArray("files").getJSONObject(0).toString();
|
||||
params.put("password", config.getPassword());
|
||||
String response = OkHttpUtil.postJson(config.getApi(), params.toString());
|
||||
String json = config.isNew() ? new JSONObject(response).getJSONObject("data").toString() : new JSONObject(response).getJSONObject("data").getJSONArray("files").getJSONObject(0).toString();
|
||||
return Item.objectFrom(json);
|
||||
} catch (Exception e) {
|
||||
return new Item();
|
||||
|
|
@ -160,14 +126,15 @@ public class AList extends Spider {
|
|||
try {
|
||||
String key = id.contains("/") ? id.substring(0, id.indexOf("/")) : id;
|
||||
String path = id.contains("/") ? id.substring(id.indexOf("/") + 1) : "";
|
||||
String url = ext.get(key) + (v3(key) ? "/api/fs/list" : "/api/public/path");
|
||||
Config config = getConfig(key);
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("path", path);
|
||||
String response = OkHttpUtil.postJson(url, params.toString());
|
||||
String json = new JSONObject(response).getJSONObject("data").getJSONArray(v3(key) ? "content" : "files").toString();
|
||||
params.put("password", config.getPassword());
|
||||
String response = OkHttpUtil.postJson(config.listApi(), params.toString());
|
||||
String json = new JSONObject(response).getJSONObject("data").getJSONArray(config.isNew() ? "content" : "files").toString();
|
||||
List<Item> items = Item.arrayFrom(json);
|
||||
Iterator<Item> iterator = items.iterator();
|
||||
if (filter) while (iterator.hasNext()) if (iterator.next().ignore(v3(key))) iterator.remove();
|
||||
if (filter) while (iterator.hasNext()) if (iterator.next().ignore(config.isNew())) iterator.remove();
|
||||
return items;
|
||||
} catch (Exception e) {
|
||||
return Collections.emptyList();
|
||||
|
|
@ -178,8 +145,8 @@ public class AList extends Spider {
|
|||
public String searchContent(String keyword, boolean quick) throws Exception {
|
||||
fetchRule();
|
||||
List<Vod> list = new ArrayList<>();
|
||||
CountDownLatch cd = new CountDownLatch(ext.size());
|
||||
for (String key : ext.keySet()) new Thread(() -> search(cd, list, key, keyword)).start();
|
||||
CountDownLatch cd = new CountDownLatch(configs.size());
|
||||
for (Config config : configs) new Thread(() -> search(cd, list, config, keyword)).start();
|
||||
cd.await();
|
||||
return Result.string(list);
|
||||
}
|
||||
|
|
@ -201,15 +168,14 @@ public class AList extends Spider {
|
|||
}
|
||||
}
|
||||
|
||||
private void search(CountDownLatch cd, List<Vod> list, String key, String keyword) {
|
||||
if (v3(key)) searchV3(list, key, keyword);
|
||||
else searchV2(list, key, getParams(keyword));
|
||||
private void search(CountDownLatch cd, List<Vod> list, Config config, String keyword) {
|
||||
if (config.isNew()) searchV3(list, config, keyword);
|
||||
else searchV2(list, config, getParams(keyword));
|
||||
cd.countDown();
|
||||
}
|
||||
|
||||
private void searchV3(List<Vod> list, String key, String param) {
|
||||
String url = ext.get(key) + "/search?box=" + param + "&url=";
|
||||
Document doc = Jsoup.parse(OkHttpUtil.string(url));
|
||||
private void searchV3(List<Vod> list, Config config, String param) {
|
||||
Document doc = Jsoup.parse(OkHttpUtil.string(config.searchApi(param)));
|
||||
for (Element a : doc.select("ul > a")) {
|
||||
String text = a.text();
|
||||
String[] splits = text.split("\\.");
|
||||
|
|
@ -220,17 +186,16 @@ public class AList extends Spider {
|
|||
item.setPath("/" + text.substring(0, index));
|
||||
item.setName(text.substring(index + 1));
|
||||
item.setType(file ? 0 : 1);
|
||||
list.add(item.getVod(key));
|
||||
list.add(item.getVod(config.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
private void searchV2(List<Vod> list, String key, String param) {
|
||||
private void searchV2(List<Vod> list, Config config, String param) {
|
||||
try {
|
||||
String url = ext.get(key) + "/api/public/search";
|
||||
String response = OkHttpUtil.postJson(url, param);
|
||||
String response = OkHttpUtil.postJson(config.searchApi(), param);
|
||||
String json = new JSONObject(response).getJSONArray("data").toString();
|
||||
List<Item> items = Item.arrayFrom(json);
|
||||
for (Item item : items) if (!item.ignore(false)) list.add(item.getVod(key));
|
||||
for (Item item : items) if (!item.ignore(false)) list.add(item.getVod(config.getName()));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
ad5e07a700c8b50e0eb03e20422c788d
|
||||
7ee69b177d3dc555da364acebccca100
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"spider": "https://ghproxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;ad5e07a700c8b50e0eb03e20422c788d",
|
||||
"spider": "https://ghproxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;7ee69b177d3dc555da364acebccca100",
|
||||
"wallpaper": "https://gao.chuqiuyu.tk",
|
||||
"lives": [
|
||||
{
|
||||
|
|
@ -14,15 +14,6 @@
|
|||
}
|
||||
],
|
||||
"sites": [
|
||||
{
|
||||
"key": "AList",
|
||||
"name": "AList",
|
||||
"type": 3,
|
||||
"api": "csp_AList",
|
||||
"searchable": 1,
|
||||
"filterable": 1,
|
||||
"ext": "9T$https://drive.9t.ee#木偶$https://www.kugutsu.ml"
|
||||
},
|
||||
{
|
||||
"key": "泥巴",
|
||||
"name": "泥巴",
|
||||
|
|
|
|||
|
|
@ -1,20 +1,75 @@
|
|||
{
|
||||
"小兵": "https://6vv.app",
|
||||
"小雅": "http://alist.xiaoya.pro",
|
||||
"杜比": "https://dubi.tk",
|
||||
"帥鵬": "https://hi.shuaipeng.wang",
|
||||
"星夢": "https://pan.bashroot.top",
|
||||
"晴園": "https://alist.52qy.repl.co",
|
||||
"梓澪": "https://zi0.cc",
|
||||
"秋雨": "https://share.laowang.me",
|
||||
"米奇": "https://anime.mqmmw.ga",
|
||||
"觸光": "https://pan.ichuguang.com",
|
||||
"一只魚": "https://alist.youte.ml",
|
||||
"七米藍": "https://al.chirmyram.com",
|
||||
"浩瀚吧": "https://8023.haohanba.cn",
|
||||
"雲播放": "https://quanzi.laoxianghuijia.cn",
|
||||
"姬路白雪": "https://pan.jlbx.xyz",
|
||||
"神族九帝": "https://alist.shenzjd.com",
|
||||
"資源小站": "https://960303.xyz",
|
||||
"Disk": "http://124.222.140.243:8080"
|
||||
}
|
||||
[
|
||||
{
|
||||
"name": "小兵",
|
||||
"server": "https://6vv.app"
|
||||
},
|
||||
{
|
||||
"name": "小雅",
|
||||
"server": "http://alist.xiaoya.pro"
|
||||
},
|
||||
{
|
||||
"name": "杜比",
|
||||
"server": "https://dubi.tk"
|
||||
},
|
||||
{
|
||||
"name": "帥鵬",
|
||||
"server": "https://hi.shuaipeng.wang"
|
||||
},
|
||||
{
|
||||
"name": "星夢",
|
||||
"server": "https://pan.bashroot.top"
|
||||
},
|
||||
{
|
||||
"name": "晴園",
|
||||
"server": "https://alist.52qy.repl.co"
|
||||
},
|
||||
{
|
||||
"name": "梓澪",
|
||||
"server": "https://zi0.cc"
|
||||
},
|
||||
{
|
||||
"name": "秋雨",
|
||||
"server": "https://share.laowang.me",
|
||||
"password": "s8;K^h[j<b"
|
||||
},
|
||||
{
|
||||
"name": "米奇",
|
||||
"server": "https://anime.mqmmw.ga"
|
||||
},
|
||||
{
|
||||
"name": "觸光",
|
||||
"server": "https://pan.ichuguang.com"
|
||||
},
|
||||
{
|
||||
"name": "一只魚",
|
||||
"server": "https://alist.youte.ml"
|
||||
},
|
||||
{
|
||||
"name": "七米藍",
|
||||
"server": "https://al.chirmyram.com"
|
||||
},
|
||||
{
|
||||
"name": "浩瀚吧",
|
||||
"server": "https://8023.haohanba.cn"
|
||||
},
|
||||
{
|
||||
"name": "雲播放",
|
||||
"server": "https://quanzi.laoxianghuijia.cn"
|
||||
},
|
||||
{
|
||||
"name": "姬路白雪",
|
||||
"server": "https://pan.jlbx.xyz"
|
||||
},
|
||||
{
|
||||
"name": "神族九帝",
|
||||
"server": "https://alist.shenzjd.com"
|
||||
},
|
||||
{
|
||||
"name": "資源小站",
|
||||
"server": "https://960303.xyz"
|
||||
},
|
||||
{
|
||||
"name": "DISK",
|
||||
"server": "http://124.222.140.243:8080"
|
||||
}
|
||||
]
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"spider": "https://ghproxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;ad5e07a700c8b50e0eb03e20422c788d",
|
||||
"spider": "https://ghproxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;7ee69b177d3dc555da364acebccca100",
|
||||
"wallpaper": "http://www.kf666888.cn/api/tvbox/img",
|
||||
"lives": [
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue