Merge branch 'main' of https://github.com/FongMi/CatVodSpider
This commit is contained in:
commit
04a1b86f51
|
|
@ -6,6 +6,7 @@ import android.text.TextUtils;
|
|||
import com.github.catvod.bean.Class;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Image;
|
||||
import com.github.catvod.utils.Utils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
|
@ -19,7 +20,7 @@ public class Drive {
|
|||
@SerializedName("drives")
|
||||
private List<Drive> drives;
|
||||
@SerializedName("params")
|
||||
private Map<String, String> params;
|
||||
private List<Param> params;
|
||||
@SerializedName("login")
|
||||
private Login login;
|
||||
@SerializedName("vodPic")
|
||||
|
|
@ -32,6 +33,8 @@ public class Drive {
|
|||
private int version;
|
||||
@SerializedName("path")
|
||||
private String path;
|
||||
@SerializedName("token")
|
||||
private String token;
|
||||
|
||||
public static Drive objectFrom(String str) {
|
||||
return new Gson().fromJson(str, Drive.class);
|
||||
|
|
@ -41,8 +44,8 @@ public class Drive {
|
|||
return drives == null ? new ArrayList<>() : drives;
|
||||
}
|
||||
|
||||
public Map<String, String> getParams() {
|
||||
return params == null ? new HashMap<>() : params;
|
||||
public List<Param> getParams() {
|
||||
return params == null ? new ArrayList<>() : params;
|
||||
}
|
||||
|
||||
public Login getLogin() {
|
||||
|
|
@ -81,6 +84,14 @@ public class Drive {
|
|||
this.path = TextUtils.isEmpty(path) ? "" : path;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return TextUtils.isEmpty(token) ? "" : token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public boolean isNew() {
|
||||
return getVersion() == 3;
|
||||
}
|
||||
|
|
@ -135,6 +146,18 @@ public class Drive {
|
|||
}
|
||||
}
|
||||
|
||||
public HashMap<String, String> getHeader() {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", Utils.CHROME);
|
||||
if (!getToken().isEmpty()) headers.put("Authorization", token);
|
||||
return headers;
|
||||
}
|
||||
|
||||
public String findPass(String path) {
|
||||
for (Param param : getParams()) if (path.startsWith(param.getPath())) return param.getPass();
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package com.github.catvod.bean.alist;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class Param {
|
||||
|
||||
@SerializedName("path")
|
||||
private String path;
|
||||
@SerializedName("pass")
|
||||
private String pass;
|
||||
|
||||
public String getPath() {
|
||||
return TextUtils.isEmpty(path) ? "" : path;
|
||||
}
|
||||
|
||||
public String getPass() {
|
||||
return TextUtils.isEmpty(pass) ? "" : pass;
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,7 @@ import com.github.catvod.bean.alist.Drive;
|
|||
import com.github.catvod.bean.alist.Item;
|
||||
import com.github.catvod.bean.alist.Sorter;
|
||||
import com.github.catvod.crawler.Spider;
|
||||
import com.github.catvod.crawler.SpiderDebug;
|
||||
import com.github.catvod.net.OkHttp;
|
||||
import com.github.catvod.utils.Utils;
|
||||
|
||||
|
|
@ -30,7 +31,6 @@ public class AList extends Spider {
|
|||
|
||||
private List<Drive> drives;
|
||||
private String vodPic;
|
||||
private String token;
|
||||
private String ext;
|
||||
|
||||
private List<Filter> getFilter() {
|
||||
|
|
@ -52,19 +52,13 @@ public class AList extends Spider {
|
|||
return drives.get(drives.indexOf(new Drive(name))).check();
|
||||
}
|
||||
|
||||
public HashMap<String, String> getHeader() {
|
||||
HashMap<String, String> headers = new HashMap<>();
|
||||
headers.put("User-Agent", Utils.CHROME);
|
||||
if (token != null) headers.put("Authorization", token);
|
||||
return headers;
|
||||
}
|
||||
|
||||
private String post(Drive drive, String url, String param) {
|
||||
return post(drive, url, param, true);
|
||||
}
|
||||
|
||||
private String post(Drive drive, String url, String param, boolean retry) {
|
||||
String response = OkHttp.postJson(url, param, getHeader()).getBody();
|
||||
String response = OkHttp.postJson(url, param, drive.getHeader()).getBody();
|
||||
SpiderDebug.log(response);
|
||||
if (retry && response.contains("Guest user is disabled") && login(drive)) return post(drive, url, param, false);
|
||||
return response;
|
||||
}
|
||||
|
|
@ -156,7 +150,7 @@ public class AList extends Spider {
|
|||
params.put("username", drive.getLogin().getUsername());
|
||||
params.put("password", drive.getLogin().getPassword());
|
||||
String response = OkHttp.postJson(drive.loginApi(), params.toString()).getBody();
|
||||
token = new JSONObject(response).getJSONObject("data").getString("token");
|
||||
drive.setToken(new JSONObject(response).getJSONObject("data").getString("token"));
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
@ -172,7 +166,7 @@ public class AList extends Spider {
|
|||
path = path.startsWith(drive.getPath()) ? path : drive.getPath() + path;
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("path", path);
|
||||
params.put("password", drive.getParams().get(path));
|
||||
params.put("password", drive.findPass(path));
|
||||
String response = post(drive, drive.getApi(), params.toString());
|
||||
return Item.objectFrom(getDetailJson(drive.isNew(), response));
|
||||
} catch (Exception e) {
|
||||
|
|
@ -188,7 +182,7 @@ public class AList extends Spider {
|
|||
path = path.startsWith(drive.getPath()) ? path : drive.getPath() + path;
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("path", path);
|
||||
params.put("password", drive.getParams().get(path));
|
||||
params.put("password", drive.findPass(path));
|
||||
String response = post(drive, drive.listApi(), params.toString());
|
||||
List<Item> items = Item.arrayFrom(getListJson(drive.isNew(), response));
|
||||
Iterator<Item> iterator = items.iterator();
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
945ad30d5255359385ba59b8fb061bb7
|
||||
4556ab64060bfdf40d0e6dcc0145862e
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;945ad30d5255359385ba59b8fb061bb7",
|
||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;4556ab64060bfdf40d0e6dcc0145862e",
|
||||
"wallpaper": "https://gao.chuqiuyu.tk",
|
||||
"sites": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,9 +32,12 @@
|
|||
"username": "fongmi",
|
||||
"password": "fongmi"
|
||||
},
|
||||
"params": {
|
||||
"/18/安齋拉拉": "1234"
|
||||
}
|
||||
"params": [
|
||||
{
|
||||
"path": "/安齋拉拉",
|
||||
"pass": "18181818"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;945ad30d5255359385ba59b8fb061bb7",
|
||||
"spider": "https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;4556ab64060bfdf40d0e6dcc0145862e",
|
||||
"wallpaper": "http://饭太硬.ga/深色壁纸/api.php",
|
||||
"sites": [
|
||||
{
|
||||
|
|
@ -286,7 +286,7 @@
|
|||
},
|
||||
{
|
||||
"name": "火山嗅探",
|
||||
"host": [
|
||||
"hosts": [
|
||||
"huoshan.com"
|
||||
],
|
||||
"regex": [
|
||||
|
|
@ -295,7 +295,7 @@
|
|||
},
|
||||
{
|
||||
"name": "抖音嗅探",
|
||||
"host": [
|
||||
"hosts": [
|
||||
"douyin.com"
|
||||
],
|
||||
"regex": [
|
||||
|
|
|
|||
Loading…
Reference in New Issue