Update alist

This commit is contained in:
FongMi 2023-03-25 14:11:12 +08:00
parent dae6761062
commit bdcb7e8fab
4 changed files with 25 additions and 9 deletions

View File

@ -1,5 +1,6 @@
package com.github.catvod.bean.alist; package com.github.catvod.bean.alist;
import android.net.Uri;
import android.text.TextUtils; import android.text.TextUtils;
import com.github.catvod.bean.Class; import com.github.catvod.bean.Class;
@ -24,6 +25,8 @@ public class Drive {
private String password; private String password;
@SerializedName("version") @SerializedName("version")
private int version; private int version;
@SerializedName("path")
private String path;
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);
@ -57,6 +60,14 @@ public class Drive {
this.version = version; this.version = version;
} }
public String getPath() {
return TextUtils.isEmpty(path) ? "" : path;
}
public void setPath(String path) {
this.path = TextUtils.isEmpty(path) ? "" : path;
}
public boolean isNew() { public boolean isNew() {
return getVersion() == 3; return getVersion() == 3;
} }
@ -65,24 +76,29 @@ public class Drive {
return new Class(getName(), getName(), "1"); return new Class(getName(), getName(), "1");
} }
public String getHost() {
return getServer().replace(getPath(), "");
}
public String settingsApi() { public String settingsApi() {
return getServer() + "/api/public/settings"; return getHost() + "/api/public/settings";
} }
public String listApi() { public String listApi() {
return getServer() + (isNew() ? "/api/fs/list" : "/api/public/path"); return getHost() + (isNew() ? "/api/fs/list" : "/api/public/path");
} }
public String getApi() { public String getApi() {
return getServer() + (isNew() ? "/api/fs/get" : "/api/public/path"); return getHost() + (isNew() ? "/api/fs/get" : "/api/public/path");
} }
public String searchApi() { public String searchApi() {
return getServer() + (isNew() ? "/api/fs/search" : "/api/public/search"); return getHost() + (isNew() ? "/api/fs/search" : "/api/public/search");
} }
public Drive check() { public Drive check() {
if (getVersion() == 0) setVersion(OkHttp.string(settingsApi()).contains("v2.") ? 2 : 3); if (path == null) setPath(Uri.parse(getServer()).getPath());
if (version == 0) setVersion(OkHttp.string(settingsApi()).contains("v2.") ? 2 : 3);
return this; return this;
} }

View File

@ -13,8 +13,8 @@ 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.net.OkHttp; import com.github.catvod.net.OkHttp;
import com.github.catvod.utils.Utils;
import com.github.catvod.utils.Trans; import com.github.catvod.utils.Trans;
import com.github.catvod.utils.Utils;
import org.json.JSONObject; import org.json.JSONObject;
@ -136,7 +136,7 @@ public class AList extends Spider {
String path = id.contains("/") ? id.substring(id.indexOf("/")) : ""; String path = id.contains("/") ? id.substring(id.indexOf("/")) : "";
Drive drive = getDrive(key); Drive drive = getDrive(key);
JSONObject params = new JSONObject(); JSONObject params = new JSONObject();
params.put("path", path); params.put("path", drive.getPath() + path);
params.put("password", drive.getPassword()); params.put("password", drive.getPassword());
String response = OkHttp.postJson(drive.getApi(), params.toString()); String response = OkHttp.postJson(drive.getApi(), params.toString());
return Item.objectFrom(getDetailJson(drive.isNew(), response)); return Item.objectFrom(getDetailJson(drive.isNew(), response));
@ -151,7 +151,7 @@ public class AList extends Spider {
String path = id.contains("/") ? id.substring(id.indexOf("/")) : ""; String path = id.contains("/") ? id.substring(id.indexOf("/")) : "";
Drive drive = getDrive(key); Drive drive = getDrive(key);
JSONObject params = new JSONObject(); JSONObject params = new JSONObject();
params.put("path", path); params.put("path", drive.getPath() + path);
params.put("password", drive.getPassword()); params.put("password", drive.getPassword());
String response = OkHttp.postJson(drive.listApi(), params.toString()); String response = OkHttp.postJson(drive.listApi(), params.toString());
List<Item> items = Item.arrayFrom(getListJson(drive.isNew(), response)); List<Item> items = Item.arrayFrom(getListJson(drive.isNew(), response));

Binary file not shown.

View File

@ -1 +1 @@
13c054ce951b3560b9495b2ed5983074 3473c6feb44308efdb18ef8ea90ed6eb