This commit is contained in:
GH Action - Upstream Sync 2023-05-22 12:31:22 +00:00
commit 04a1b86f51
8 changed files with 64 additions and 23 deletions

View File

@ -6,6 +6,7 @@ import android.text.TextUtils;
import com.github.catvod.bean.Class; import com.github.catvod.bean.Class;
import com.github.catvod.net.OkHttp; import com.github.catvod.net.OkHttp;
import com.github.catvod.utils.Image; import com.github.catvod.utils.Image;
import com.github.catvod.utils.Utils;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
@ -19,7 +20,7 @@ public class Drive {
@SerializedName("drives") @SerializedName("drives")
private List<Drive> drives; private List<Drive> drives;
@SerializedName("params") @SerializedName("params")
private Map<String, String> params; private List<Param> params;
@SerializedName("login") @SerializedName("login")
private Login login; private Login login;
@SerializedName("vodPic") @SerializedName("vodPic")
@ -32,6 +33,8 @@ public class Drive {
private int version; private int version;
@SerializedName("path") @SerializedName("path")
private String path; private String path;
@SerializedName("token")
private String token;
public static Drive objectFrom(String str) { public static Drive objectFrom(String str) {
return new Gson().fromJson(str, Drive.class); return new Gson().fromJson(str, Drive.class);
@ -41,8 +44,8 @@ public class Drive {
return drives == null ? new ArrayList<>() : drives; return drives == null ? new ArrayList<>() : drives;
} }
public Map<String, String> getParams() { public List<Param> getParams() {
return params == null ? new HashMap<>() : params; return params == null ? new ArrayList<>() : params;
} }
public Login getLogin() { public Login getLogin() {
@ -81,6 +84,14 @@ public class Drive {
this.path = TextUtils.isEmpty(path) ? "" : path; 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() { public boolean isNew() {
return getVersion() == 3; 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 @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true; if (this == obj) return true;

View File

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

View File

@ -12,6 +12,7 @@ import com.github.catvod.bean.alist.Drive;
import com.github.catvod.bean.alist.Item; import com.github.catvod.bean.alist.Item;
import com.github.catvod.bean.alist.Sorter; import com.github.catvod.bean.alist.Sorter;
import com.github.catvod.crawler.Spider; import com.github.catvod.crawler.Spider;
import com.github.catvod.crawler.SpiderDebug;
import com.github.catvod.net.OkHttp; import com.github.catvod.net.OkHttp;
import com.github.catvod.utils.Utils; import com.github.catvod.utils.Utils;
@ -30,7 +31,6 @@ public class AList extends Spider {
private List<Drive> drives; private List<Drive> drives;
private String vodPic; private String vodPic;
private String token;
private String ext; private String ext;
private List<Filter> getFilter() { private List<Filter> getFilter() {
@ -52,19 +52,13 @@ public class AList extends Spider {
return drives.get(drives.indexOf(new Drive(name))).check(); 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) { private String post(Drive drive, String url, String param) {
return post(drive, url, param, true); return post(drive, url, param, true);
} }
private String post(Drive drive, String url, String param, boolean retry) { 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); if (retry && response.contains("Guest user is disabled") && login(drive)) return post(drive, url, param, false);
return response; return response;
} }
@ -156,7 +150,7 @@ public class AList extends Spider {
params.put("username", drive.getLogin().getUsername()); params.put("username", drive.getLogin().getUsername());
params.put("password", drive.getLogin().getPassword()); params.put("password", drive.getLogin().getPassword());
String response = OkHttp.postJson(drive.loginApi(), params.toString()).getBody(); 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; return true;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -172,7 +166,7 @@ public class AList extends Spider {
path = path.startsWith(drive.getPath()) ? path : drive.getPath() + path; path = path.startsWith(drive.getPath()) ? path : drive.getPath() + path;
JSONObject params = new JSONObject(); JSONObject params = new JSONObject();
params.put("path", path); 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()); String response = post(drive, drive.getApi(), params.toString());
return Item.objectFrom(getDetailJson(drive.isNew(), response)); return Item.objectFrom(getDetailJson(drive.isNew(), response));
} catch (Exception e) { } catch (Exception e) {
@ -188,7 +182,7 @@ public class AList extends Spider {
path = path.startsWith(drive.getPath()) ? path : drive.getPath() + path; path = path.startsWith(drive.getPath()) ? path : drive.getPath() + path;
JSONObject params = new JSONObject(); JSONObject params = new JSONObject();
params.put("path", path); 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()); String response = post(drive, drive.listApi(), params.toString());
List<Item> items = Item.arrayFrom(getListJson(drive.isNew(), response)); List<Item> items = Item.arrayFrom(getListJson(drive.isNew(), response));
Iterator<Item> iterator = items.iterator(); Iterator<Item> iterator = items.iterator();

Binary file not shown.

View File

@ -1 +1 @@
945ad30d5255359385ba59b8fb061bb7 4556ab64060bfdf40d0e6dcc0145862e

View File

@ -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", "wallpaper": "https://gao.chuqiuyu.tk",
"sites": [ "sites": [
{ {

View File

@ -32,9 +32,12 @@
"username": "fongmi", "username": "fongmi",
"password": "fongmi" "password": "fongmi"
}, },
"params": { "params": [
"/18/安齋拉拉": "1234" {
} "path": "/安齋拉拉",
"pass": "18181818"
}
]
} }
] ]
} }

View File

@ -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", "wallpaper": "http://饭太硬.ga/深色壁纸/api.php",
"sites": [ "sites": [
{ {
@ -286,7 +286,7 @@
}, },
{ {
"name": "火山嗅探", "name": "火山嗅探",
"host": [ "hosts": [
"huoshan.com" "huoshan.com"
], ],
"regex": [ "regex": [
@ -295,7 +295,7 @@
}, },
{ {
"name": "抖音嗅探", "name": "抖音嗅探",
"host": [ "hosts": [
"douyin.com" "douyin.com"
], ],
"regex": [ "regex": [