Update alist format
This commit is contained in:
parent
52996032ca
commit
cc5dc7fdcf
|
|
@ -5,11 +5,12 @@ 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.Util;
|
||||
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.HashMap;
|
||||
import java.util.List;
|
||||
|
|
@ -17,14 +18,10 @@ import java.util.Map;
|
|||
|
||||
public class Drive {
|
||||
|
||||
@SerializedName("drives")
|
||||
private List<Drive> drives;
|
||||
@SerializedName("params")
|
||||
private List<Param> params;
|
||||
@SerializedName("login")
|
||||
private Login login;
|
||||
@SerializedName("vodPic")
|
||||
private String vodPic;
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
@SerializedName("server")
|
||||
|
|
@ -40,12 +37,9 @@ public class Drive {
|
|||
@SerializedName("hidden")
|
||||
private Boolean hidden;
|
||||
|
||||
public static Drive objectFrom(String str) {
|
||||
return new Gson().fromJson(str, Drive.class);
|
||||
}
|
||||
|
||||
public List<Drive> getDrives() {
|
||||
return drives == null ? new ArrayList<>() : drives;
|
||||
public static List<Drive> arrayFrom(String str) {
|
||||
Type listType = new TypeToken<List<Drive>>() {}.getType();
|
||||
return new Gson().fromJson(str, listType);
|
||||
}
|
||||
|
||||
public List<Param> getParams() {
|
||||
|
|
@ -60,10 +54,6 @@ public class Drive {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public String getVodPic() {
|
||||
return TextUtils.isEmpty(vodPic) ? Image.FOLDER : vodPic;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return TextUtils.isEmpty(name) ? "" : name;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.github.catvod.bean.alist;
|
|||
import android.text.TextUtils;
|
||||
|
||||
import com.github.catvod.bean.Vod;
|
||||
import com.github.catvod.utils.Image;
|
||||
import com.github.catvod.utils.Util;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
|
@ -117,19 +118,19 @@ public class Item {
|
|||
return id + getPath() + "/" + getName();
|
||||
}
|
||||
|
||||
public String getPic(String pic) {
|
||||
return getThumb().isEmpty() && isFolder() ? pic : getThumb();
|
||||
public String getPic() {
|
||||
return getThumb().isEmpty() && isFolder() ? Image.FOLDER : getThumb();
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return Util.getSize(getSize());
|
||||
}
|
||||
|
||||
public Vod getVod(String id, String pic) {
|
||||
return new Vod(getVodId(id), getName(), getPic(pic), getRemark(), isFolder());
|
||||
public Vod getVod(String id) {
|
||||
return new Vod(getVodId(id), getName(), getPic(), getRemark(), isFolder());
|
||||
}
|
||||
|
||||
public Vod getVod(Drive drive, String pic) {
|
||||
return new Vod(getVodId(drive.getName()), getName(), getPic(pic), drive.getName(), isFolder());
|
||||
public Vod getVod(Drive drive) {
|
||||
return new Vod(getVodId(drive.getName()), getName(), getPic(), drive.getName(), isFolder());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ import java.util.concurrent.TimeUnit;
|
|||
public class AList extends Spider {
|
||||
|
||||
private List<Drive> drives;
|
||||
private String vodPic;
|
||||
private String ext;
|
||||
|
||||
private List<Filter> getFilter() {
|
||||
|
|
@ -52,9 +51,7 @@ public class AList extends Spider {
|
|||
private void fetchRule() {
|
||||
if (drives != null && !drives.isEmpty()) return;
|
||||
if (ext.startsWith("http")) ext = OkHttp.string(ext);
|
||||
Drive drive = Drive.objectFrom(ext);
|
||||
drives = drive.getDrives();
|
||||
vodPic = drive.getVodPic();
|
||||
drives = Drive.arrayFrom(ext);
|
||||
}
|
||||
|
||||
private Drive getDrive(String name) {
|
||||
|
|
@ -109,8 +106,8 @@ public class AList extends Spider {
|
|||
Sorter.sort(type, order, files);
|
||||
}
|
||||
|
||||
for (Item item : folders) list.add(item.getVod(tid, vodPic));
|
||||
for (Item item : files) list.add(item.getVod(tid, vodPic));
|
||||
for (Item item : folders) list.add(item.getVod(tid));
|
||||
for (Item item : files) list.add(item.getVod(tid));
|
||||
return Result.get().vod(list).page().string();
|
||||
}
|
||||
|
||||
|
|
@ -126,7 +123,6 @@ public class AList extends Spider {
|
|||
vod.setVodPlayFrom(key);
|
||||
vod.setVodId(id);
|
||||
vod.setVodName(name);
|
||||
vod.setVodPic(vodPic);
|
||||
List<String> playUrls = new ArrayList<>();
|
||||
List<Item> parents = getList(path, false);
|
||||
for (Item item : parents) if (item.isMedia(drive.isNew())) playUrls.add(item.getName() + "$" + encodeVodId(item.getVodId(path) + findSubs(path, parents)));
|
||||
|
|
@ -279,7 +275,7 @@ public class AList extends Spider {
|
|||
@Override
|
||||
public List<Vod> call() {
|
||||
List<Vod> alist = alist();
|
||||
return alist.size() > 0 ? alist : xiaoya();
|
||||
return !alist.isEmpty() ? alist : xiaoya();
|
||||
}
|
||||
|
||||
private List<Vod> xiaoya() {
|
||||
|
|
@ -295,7 +291,7 @@ public class AList extends Spider {
|
|||
item.setThumb(splits.length > 3 ? splits[4] : "");
|
||||
item.setPath("/" + splits[0].substring(0, index));
|
||||
item.setName(splits[0].substring(index + 1));
|
||||
list.add(item.getVod(drive, vodPic));
|
||||
list.add(item.getVod(drive));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
|
@ -305,7 +301,7 @@ public class AList extends Spider {
|
|||
List<Vod> list = new ArrayList<>();
|
||||
String response = post(drive, drive.searchApi(), drive.params(keyword));
|
||||
List<Item> items = Item.arrayFrom(getSearchJson(drive.isNew(), response));
|
||||
for (Item item : items) if (!item.ignore(drive.isNew())) list.add(item.getVod(drive, vodPic));
|
||||
for (Item item : items) if (!item.ignore(drive.isNew())) list.add(item.getVod(drive));
|
||||
return list;
|
||||
} catch (Exception e) {
|
||||
return Collections.emptyList();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
{
|
||||
"vodPic": "https://x.imgs.ovh/x/2023/09/05/64f680bb030b4.png",
|
||||
"drives": [
|
||||
[
|
||||
{
|
||||
"name": "小雅",
|
||||
"server": "http://alist.xiaoya.pro"
|
||||
|
|
@ -42,4 +40,3 @@
|
|||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue