Merge branch 'main' of github.com:oiltea/CatVodSpider
This commit is contained in:
commit
1d9f219f85
|
|
@ -58,12 +58,10 @@ public class AliYun {
|
||||||
private final List<String> tempIds;
|
private final List<String> tempIds;
|
||||||
private AlertDialog dialog;
|
private AlertDialog dialog;
|
||||||
private String refreshToken;
|
private String refreshToken;
|
||||||
private String shareToken;
|
private Share share;
|
||||||
private String shareId;
|
|
||||||
private String driveId;
|
|
||||||
private OAuth oauth;
|
private OAuth oauth;
|
||||||
private User user;
|
|
||||||
private Drive drive;
|
private Drive drive;
|
||||||
|
private User user;
|
||||||
|
|
||||||
private static class Loader {
|
private static class Loader {
|
||||||
static volatile AliYun INSTANCE = new AliYun();
|
static volatile AliYun INSTANCE = new AliYun();
|
||||||
|
|
@ -87,8 +85,8 @@ public class AliYun {
|
||||||
|
|
||||||
private AliYun() {
|
private AliYun() {
|
||||||
tempIds = new ArrayList<>();
|
tempIds = new ArrayList<>();
|
||||||
oauth = OAuth.objectFrom(FileUtil.read(getOAuthCache()));
|
|
||||||
user = User.objectFrom(FileUtil.read(getUserCache()));
|
user = User.objectFrom(FileUtil.read(getUserCache()));
|
||||||
|
oauth = OAuth.objectFrom(FileUtil.read(getOAuthCache()));
|
||||||
drive = Drive.objectFrom(FileUtil.read(getDriveCache()));
|
drive = Drive.objectFrom(FileUtil.read(getDriveCache()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,14 +102,6 @@ public class AliYun {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShareId(String shareId) {
|
|
||||||
if (!getOAuthCache().exists()) oauth.clean().save();
|
|
||||||
if (!getUserCache().exists()) user.clean().save();
|
|
||||||
if (!getDriveCache().exists()) drive.clean().save();
|
|
||||||
this.shareId = shareId;
|
|
||||||
refreshShareToken();
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<String, String> getHeader() {
|
public HashMap<String, String> getHeader() {
|
||||||
HashMap<String, String> headers = new HashMap<>();
|
HashMap<String, String> headers = new HashMap<>();
|
||||||
headers.put("User-Agent", Utils.CHROME);
|
headers.put("User-Agent", Utils.CHROME);
|
||||||
|
|
@ -121,7 +111,7 @@ public class AliYun {
|
||||||
|
|
||||||
private HashMap<String, String> getHeaderAuth() {
|
private HashMap<String, String> getHeaderAuth() {
|
||||||
HashMap<String, String> headers = getHeader();
|
HashMap<String, String> headers = getHeader();
|
||||||
headers.put("x-share-token", shareToken);
|
headers.put("x-share-token", share.getShareToken());
|
||||||
headers.put("X-Canary", "client=Android,app=adrive,version=v4.3.1");
|
headers.put("X-Canary", "client=Android,app=adrive,version=v4.3.1");
|
||||||
if (user.isAuthed()) headers.put("authorization", user.getAuthorization());
|
if (user.isAuthed()) headers.put("authorization", user.getAuthorization());
|
||||||
return headers;
|
return headers;
|
||||||
|
|
@ -153,7 +143,7 @@ public class AliYun {
|
||||||
url = url.startsWith("https") ? url : "https://api.aliyundrive.com/" + url;
|
url = url.startsWith("https") ? url : "https://api.aliyundrive.com/" + url;
|
||||||
OkResult result = OkHttp.postJson(url, json, getHeaderAuth());
|
OkResult result = OkHttp.postJson(url, json, getHeaderAuth());
|
||||||
SpiderDebug.log(result.getCode() + "," + url + "," + result.getBody());
|
SpiderDebug.log(result.getCode() + "," + url + "," + result.getBody());
|
||||||
if (retry && (result.getCode() == 400 || result.getCode() == 401) && refreshAccessToken()) return auth(url, json, false);
|
if (retry && result.getCode() == 401 && refreshAccessToken()) return auth(url, json, false);
|
||||||
if (retry && result.getCode() == 429) return auth(url, json, false);
|
if (retry && result.getCode() == 429) return auth(url, json, false);
|
||||||
return result.getBody();
|
return result.getBody();
|
||||||
}
|
}
|
||||||
|
|
@ -178,14 +168,15 @@ public class AliYun {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshShareToken() {
|
private void refreshShareToken(String shareId) {
|
||||||
|
if (share != null && share.alive(shareId)) return;
|
||||||
SpiderDebug.log("refreshShareToken...");
|
SpiderDebug.log("refreshShareToken...");
|
||||||
JsonObject param = new JsonObject();
|
JsonObject param = new JsonObject();
|
||||||
param.addProperty("share_id", shareId);
|
param.addProperty("share_id", shareId);
|
||||||
param.addProperty("share_pwd", "");
|
param.addProperty("share_pwd", "");
|
||||||
String json = post("v2/share_link/get_share_token", param);
|
String json = post("v2/share_link/get_share_token", param);
|
||||||
shareToken = Share.objectFrom(json).getShareToken();
|
share = Share.objectFrom(json).setShareId(shareId).setTime();
|
||||||
if (shareToken.isEmpty()) Utils.notify("來晚啦,該分享已失效。");
|
if (share.getShareToken().isEmpty()) Utils.notify("來晚啦,該分享已失效。");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean refreshAccessToken() {
|
private boolean refreshAccessToken() {
|
||||||
|
|
@ -194,7 +185,7 @@ public class AliYun {
|
||||||
JsonObject param = new JsonObject();
|
JsonObject param = new JsonObject();
|
||||||
String token = user.getRefreshToken();
|
String token = user.getRefreshToken();
|
||||||
if (token.isEmpty()) token = refreshToken;
|
if (token.isEmpty()) token = refreshToken;
|
||||||
if (token.startsWith("http")) token = OkHttp.string(token).trim();
|
if (token != null && token.startsWith("http")) token = OkHttp.string(token).trim();
|
||||||
param.addProperty("refresh_token", token);
|
param.addProperty("refresh_token", token);
|
||||||
param.addProperty("grant_type", "refresh_token");
|
param.addProperty("grant_type", "refresh_token");
|
||||||
String json = post("https://auth.aliyundrive.com/v2/account/token", param);
|
String json = post("https://auth.aliyundrive.com/v2/account/token", param);
|
||||||
|
|
@ -214,10 +205,9 @@ public class AliYun {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getDriveId() {
|
private void getDriveId() {
|
||||||
SpiderDebug.log("Obtain drive id...");
|
SpiderDebug.log("Get Drive Id...");
|
||||||
String result = auth("https://user.aliyundrive.com/v2/user/get", "{}", false);
|
String json = auth("https://user.aliyundrive.com/v2/user/get", "{}", true);
|
||||||
drive = Drive.objectFrom(result).save();
|
drive = Drive.objectFrom(json).save();
|
||||||
driveId = drive.getResourceDriveId().isEmpty() ? drive.getDriveId() : drive.getResourceDriveId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean oauthRequest() {
|
private boolean oauthRequest() {
|
||||||
|
|
@ -247,18 +237,19 @@ public class AliYun {
|
||||||
return alist("token", param);
|
return alist("token", param);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vod getVod(String url, String fileId) {
|
public Vod getVod(String url, String shareId, String fileId) {
|
||||||
|
refreshShareToken(shareId);
|
||||||
JsonObject param = new JsonObject();
|
JsonObject param = new JsonObject();
|
||||||
param.addProperty("share_id", shareId);
|
param.addProperty("share_id", shareId);
|
||||||
Share share = Share.objectFrom(post("adrive/v3/share_link/get_share_by_anonymous", param));
|
Share share = Share.objectFrom(post("adrive/v3/share_link/get_share_by_anonymous", param));
|
||||||
List<Item> files = new ArrayList<>();
|
List<Item> files = new ArrayList<>();
|
||||||
List<Item> subs = new ArrayList<>();
|
List<Item> subs = new ArrayList<>();
|
||||||
listFiles(new Item(getParentFileId(fileId, share)), files, subs);
|
listFiles(shareId, new Item(getParentFileId(fileId, share)), files, subs);
|
||||||
Collections.sort(files);
|
Collections.sort(files);
|
||||||
List<String> playFrom = Arrays.asList("原畫", "普畫");
|
List<String> playFrom = Arrays.asList("原畫", "普畫");
|
||||||
List<String> episode = new ArrayList<>();
|
List<String> episode = new ArrayList<>();
|
||||||
List<String> playUrl = new ArrayList<>();
|
List<String> playUrl = new ArrayList<>();
|
||||||
for (Item file : files) episode.add(file.getDisplayName() + "$" + shareId + "@" + file.getFileId() + findSubs(file.getName(), subs));
|
for (Item file : files) episode.add(file.getDisplayName() + "$" + shareId + "+" + file.getFileId() + findSubs(file.getName(), subs));
|
||||||
for (int i = 0; i < playFrom.size(); i++) playUrl.add(TextUtils.join("#", episode));
|
for (int i = 0; i < playFrom.size(); i++) playUrl.add(TextUtils.join("#", episode));
|
||||||
Vod vod = new Vod();
|
Vod vod = new Vod();
|
||||||
vod.setVodId(url);
|
vod.setVodId(url);
|
||||||
|
|
@ -271,11 +262,11 @@ public class AliYun {
|
||||||
return vod;
|
return vod;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void listFiles(Item folder, List<Item> files, List<Item> subs) {
|
private void listFiles(String shareId, Item folder, List<Item> files, List<Item> subs) {
|
||||||
listFiles(folder, files, subs, "");
|
listFiles(shareId, folder, files, subs, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void listFiles(Item parent, List<Item> files, List<Item> subs, String marker) {
|
private void listFiles(String shareId, Item parent, List<Item> files, List<Item> subs, String marker) {
|
||||||
List<Item> folders = new ArrayList<>();
|
List<Item> folders = new ArrayList<>();
|
||||||
JsonObject param = new JsonObject();
|
JsonObject param = new JsonObject();
|
||||||
param.addProperty("limit", 200);
|
param.addProperty("limit", 200);
|
||||||
|
|
@ -295,10 +286,10 @@ public class AliYun {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (item.getNextMarker().length() > 0) {
|
if (item.getNextMarker().length() > 0) {
|
||||||
listFiles(parent, files, subs, item.getNextMarker());
|
listFiles(shareId, parent, files, subs, item.getNextMarker());
|
||||||
}
|
}
|
||||||
for (Item folder : folders) {
|
for (Item folder : folders) {
|
||||||
listFiles(folder, files, subs);
|
listFiles(shareId, folder, files, subs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -332,20 +323,20 @@ public class AliYun {
|
||||||
String[] split = text.split("@@@");
|
String[] split = text.split("@@@");
|
||||||
String name = split[0];
|
String name = split[0];
|
||||||
String ext = split[1];
|
String ext = split[1];
|
||||||
String url = Proxy.getUrl() + "?do=ali&type=sub&file_id=" + split[2];
|
String url = Proxy.getUrl() + "?do=ali&type=sub&shareId=" + ids[0] + "&fileId=" + split[2];
|
||||||
sub.add(Sub.create().name(name).ext(ext).url(url));
|
sub.add(Sub.create().name(name).ext(ext).url(url));
|
||||||
}
|
}
|
||||||
return sub;
|
return sub;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDownloadUrl(String fileId) {
|
public String getDownloadUrl(String shareId, String fileId) {
|
||||||
try {
|
try {
|
||||||
getDriveId();
|
refreshShareToken(shareId);
|
||||||
SpiderDebug.log("getDownloadUrl..." + fileId);
|
SpiderDebug.log("getDownloadUrl..." + fileId);
|
||||||
tempIds.add(0, copy(fileId, true));
|
tempIds.add(0, copy(shareId, fileId));
|
||||||
JsonObject param = new JsonObject();
|
JsonObject param = new JsonObject();
|
||||||
param.addProperty("file_id", tempIds.get(0));
|
param.addProperty("file_id", tempIds.get(0));
|
||||||
param.addProperty("drive_id", driveId);
|
param.addProperty("drive_id", drive.getDriveId());
|
||||||
String json = oauth("openFile/getDownloadUrl", param.toString(), true);
|
String json = oauth("openFile/getDownloadUrl", param.toString(), true);
|
||||||
return Download.objectFrom(json).getUrl();
|
return Download.objectFrom(json).getUrl();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
@ -356,14 +347,14 @@ public class AliYun {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Preview.Info getVideoPreviewPlayInfo(String fileId) {
|
public Preview.Info getVideoPreviewPlayInfo(String shareId, String fileId) {
|
||||||
try {
|
try {
|
||||||
getDriveId();
|
refreshShareToken(shareId);
|
||||||
SpiderDebug.log("getVideoPreviewPlayInfo..." + fileId);
|
SpiderDebug.log("getVideoPreviewPlayInfo..." + fileId);
|
||||||
tempIds.add(0, copy(fileId, true));
|
tempIds.add(0, copy(shareId, fileId));
|
||||||
JsonObject param = new JsonObject();
|
JsonObject param = new JsonObject();
|
||||||
param.addProperty("file_id", tempIds.get(0));
|
param.addProperty("file_id", tempIds.get(0));
|
||||||
param.addProperty("drive_id", driveId);
|
param.addProperty("drive_id", drive.getDriveId());
|
||||||
param.addProperty("category", "live_transcoding");
|
param.addProperty("category", "live_transcoding");
|
||||||
param.addProperty("url_expire_sec", "14400");
|
param.addProperty("url_expire_sec", "14400");
|
||||||
String json = oauth("openFile/getVideoPreviewPlayInfo", param.toString(), true);
|
String json = oauth("openFile/getVideoPreviewPlayInfo", param.toString(), true);
|
||||||
|
|
@ -377,12 +368,12 @@ public class AliYun {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String playerContent(String[] ids, boolean original) {
|
public String playerContent(String[] ids, boolean original) {
|
||||||
if (original) return Result.get().url(getDownloadUrl(ids[0])).octet().subs(getSubs(ids)).header(getHeader()).string();
|
if (original) return Result.get().url(getDownloadUrl(ids[0], ids[1])).octet().subs(getSubs(ids)).header(getHeader()).string();
|
||||||
else return getPreviewContent(ids);
|
else return getPreviewContent(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPreviewContent(String[] ids) {
|
private String getPreviewContent(String[] ids) {
|
||||||
Preview.Info info = getVideoPreviewPlayInfo(ids[0]);
|
Preview.Info info = getVideoPreviewPlayInfo(ids[0], ids[1]);
|
||||||
List<String> url = getPreviewUrl(info);
|
List<String> url = getPreviewUrl(info);
|
||||||
List<Sub> subs = getSubs(ids);
|
List<Sub> subs = getSubs(ids);
|
||||||
subs.addAll(getSubs(info));
|
subs.addAll(getSubs(info));
|
||||||
|
|
@ -405,14 +396,12 @@ public class AliYun {
|
||||||
return subs;
|
return subs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String copy(String fileId, boolean retry) throws Exception {
|
private String copy(String shareId, String fileId) {
|
||||||
|
if (drive.getDriveId().isEmpty()) getDriveId();
|
||||||
SpiderDebug.log("Copy..." + fileId);
|
SpiderDebug.log("Copy..." + fileId);
|
||||||
String json = "{\"requests\":[{\"body\":{\"file_id\":\"%s\",\"share_id\":\"%s\",\"auto_rename\":true,\"to_parent_file_id\":\"root\",\"to_drive_id\":\"%s\"},\"headers\":{\"Content-Type\":\"application/json\"},\"id\":\"0\",\"method\":\"POST\",\"url\":\"/file/copy\"}],\"resource\":\"file\"}";
|
String json = "{\"requests\":[{\"body\":{\"file_id\":\"%s\",\"share_id\":\"%s\",\"auto_rename\":true,\"to_parent_file_id\":\"root\",\"to_drive_id\":\"%s\"},\"headers\":{\"Content-Type\":\"application/json\"},\"id\":\"0\",\"method\":\"POST\",\"url\":\"/file/copy\"}],\"resource\":\"file\"}";
|
||||||
json = String.format(json, fileId, shareId, driveId);
|
json = String.format(json, fileId, shareId, drive.getDriveId());
|
||||||
Res res = Res.objectFrom(auth("adrive/v2/batch", json, true));
|
Res res = Res.objectFrom(auth("adrive/v2/batch", json, true));
|
||||||
if (res.getResponse().getStatus() == 403 && retry) refreshShareToken();
|
|
||||||
if (res.getResponse().getStatus() == 403 && retry) copy(fileId, false);
|
|
||||||
if (res.getResponse().getStatus() == 403 && !retry) throw new Exception(res.getResponse().getBody().getMessage());
|
|
||||||
return res.getResponse().getBody().getFileId();
|
return res.getResponse().getBody().getFileId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -427,14 +416,15 @@ public class AliYun {
|
||||||
private boolean delete(String fileId) {
|
private boolean delete(String fileId) {
|
||||||
SpiderDebug.log("Delete..." + fileId);
|
SpiderDebug.log("Delete..." + fileId);
|
||||||
String json = "{\"requests\":[{\"body\":{\"drive_id\":\"%s\",\"file_id\":\"%s\"},\"headers\":{\"Content-Type\":\"application/json\"},\"id\":\"%s\",\"method\":\"POST\",\"url\":\"/file/delete\"}],\"resource\":\"file\"}";
|
String json = "{\"requests\":[{\"body\":{\"drive_id\":\"%s\",\"file_id\":\"%s\"},\"headers\":{\"Content-Type\":\"application/json\"},\"id\":\"%s\",\"method\":\"POST\",\"url\":\"/file/delete\"}],\"resource\":\"file\"}";
|
||||||
json = String.format(json, driveId, fileId, fileId);
|
json = String.format(json, drive.getDriveId(), fileId, fileId);
|
||||||
Res res = Res.objectFrom(auth("adrive/v2/batch", json, true));
|
Res res = Res.objectFrom(auth("adrive/v2/batch", json, true));
|
||||||
return res.getResponse().getStatus() == 404;
|
return res.getResponse().getStatus() == 404;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] proxySub(Map<String, String> params) throws Exception {
|
public Object[] proxySub(Map<String, String> params) throws Exception {
|
||||||
String fileId = params.get("file_id");
|
String fileId = params.get("fileId");
|
||||||
Response res = OkHttp.newCall(getDownloadUrl(fileId), getHeaderAuth());
|
String shareId = params.get("shareId");
|
||||||
|
Response res = OkHttp.newCall(getDownloadUrl(shareId, fileId), getHeaderAuth());
|
||||||
byte[] body = Utils.toUtf8(res.body().bytes());
|
byte[] body = Utils.toUtf8(res.body().bytes());
|
||||||
Object[] result = new Object[3];
|
Object[] result = new Object[3];
|
||||||
result[0] = 200;
|
result[0] = 200;
|
||||||
|
|
|
||||||
|
|
@ -10,43 +10,29 @@ import com.google.gson.annotations.SerializedName;
|
||||||
public class Drive {
|
public class Drive {
|
||||||
|
|
||||||
@SerializedName("default_drive_id")
|
@SerializedName("default_drive_id")
|
||||||
private String driveId;
|
private String defaultDriveId;
|
||||||
@SerializedName("user_id")
|
|
||||||
private String userId;
|
|
||||||
@SerializedName("backup_drive_id")
|
|
||||||
private String backupDriveId;
|
|
||||||
@SerializedName("resource_drive_id")
|
@SerializedName("resource_drive_id")
|
||||||
private String resourceDriveId;
|
private String resourceDriveId;
|
||||||
@SerializedName("sbox_drive_id")
|
|
||||||
private String sboxDriveId;
|
|
||||||
|
|
||||||
public static Drive objectFrom(String str) {
|
public static Drive objectFrom(String str) {
|
||||||
Drive item = new Gson().fromJson(str, Drive.class);
|
Drive item = new Gson().fromJson(str, Drive.class);
|
||||||
return item == null ? new Drive() : item;
|
return item == null ? new Drive() : item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDriveId() {
|
private String getDefaultDriveId() {
|
||||||
return TextUtils.isEmpty(driveId) ? "" : driveId;
|
return TextUtils.isEmpty(defaultDriveId) ? "" : defaultDriveId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserId() {
|
private String getResourceDriveId() {
|
||||||
return TextUtils.isEmpty(userId) ? "" : userId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBackupDriveId() {
|
|
||||||
return TextUtils.isEmpty(backupDriveId) ? "" : backupDriveId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getResourceDriveId() {
|
|
||||||
return TextUtils.isEmpty(resourceDriveId) ? "" : resourceDriveId;
|
return TextUtils.isEmpty(resourceDriveId) ? "" : resourceDriveId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSboxDriveId() {
|
public String getDriveId() {
|
||||||
return TextUtils.isEmpty(sboxDriveId) ? "" : sboxDriveId;
|
return getResourceDriveId().isEmpty() ? getDefaultDriveId() : getResourceDriveId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drive clean() {
|
public Drive clean() {
|
||||||
this.driveId = "";
|
this.defaultDriveId = "";
|
||||||
this.resourceDriveId = "";
|
this.resourceDriveId = "";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.github.catvod.bean.ali;
|
package com.github.catvod.bean.ali;
|
||||||
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import com.github.catvod.utils.ChineseComparator;
|
|
||||||
import com.github.catvod.utils.Utils;
|
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;
|
||||||
|
|
@ -86,8 +86,12 @@ public class Item implements Comparable<Item> {
|
||||||
return TextUtils.join(" ", Arrays.asList(getParent(), getName(), getSize())).trim();
|
return TextUtils.join(" ", Arrays.asList(getParent(), getName(), getSize())).trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSortName() {
|
||||||
|
return TextUtils.join(" ", Arrays.asList(getParent(), getName())).trim();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Item item) {
|
public int compareTo(Item item) {
|
||||||
return ChineseComparator.compare(this.getDisplayName(), item.getDisplayName());
|
return Integer.compare(Utils.getDigit(getSortName()), Utils.getDigit(item.getSortName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ import java.util.List;
|
||||||
|
|
||||||
public class Share {
|
public class Share {
|
||||||
|
|
||||||
|
@SerializedName("share_id")
|
||||||
|
private String shareId;
|
||||||
@SerializedName("share_token")
|
@SerializedName("share_token")
|
||||||
private String shareToken;
|
private String shareToken;
|
||||||
@SerializedName("expire_time")
|
@SerializedName("expire_time")
|
||||||
|
|
@ -42,10 +44,16 @@ public class Share {
|
||||||
@SerializedName("file_infos")
|
@SerializedName("file_infos")
|
||||||
private List<Item> fileInfos;
|
private List<Item> fileInfos;
|
||||||
|
|
||||||
|
private long time;
|
||||||
|
|
||||||
public static Share objectFrom(String str) {
|
public static Share objectFrom(String str) {
|
||||||
return new Gson().fromJson(str, Share.class);
|
return new Gson().fromJson(str, Share.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getShareId() {
|
||||||
|
return TextUtils.isEmpty(shareId) ? "" : shareId;
|
||||||
|
}
|
||||||
|
|
||||||
public String getShareToken() {
|
public String getShareToken() {
|
||||||
return TextUtils.isEmpty(shareToken) ? "" : shareToken;
|
return TextUtils.isEmpty(shareToken) ? "" : shareToken;
|
||||||
}
|
}
|
||||||
|
|
@ -105,4 +113,18 @@ public class Share {
|
||||||
public List<Item> getFileInfos() {
|
public List<Item> getFileInfos() {
|
||||||
return fileInfos == null ? Collections.emptyList() : fileInfos;
|
return fileInfos == null ? Collections.emptyList() : fileInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Share setTime() {
|
||||||
|
this.time = System.currentTimeMillis() + 60 * 60 * 1000;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Share setShareId(String shareId) {
|
||||||
|
this.shareId = shareId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean alive(String shareId) {
|
||||||
|
return getShareId().equals(shareId) && System.currentTimeMillis() <= time;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,15 +37,13 @@ public class Ali extends Spider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String playerContent(String flag, String id, List<String> vipFlags) {
|
public String playerContent(String flag, String id, List<String> vipFlags) {
|
||||||
AliYun.get().setShareId(id.split("@")[0]);
|
return AliYun.get().playerContent(id.split("\\+"), flag.split("#")[0].equals("原畫"));
|
||||||
return AliYun.get().playerContent(id.split("@")[1].split("\\+"), flag.split("#")[0].equals("原畫"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vod parseVod(Matcher matcher, String id) {
|
private Vod parseVod(Matcher matcher, String id) {
|
||||||
String shareId = matcher.group(1);
|
String shareId = matcher.group(1);
|
||||||
String fileId = matcher.groupCount() == 3 ? matcher.group(3) : "";
|
String fileId = matcher.groupCount() == 3 ? matcher.group(3) : "";
|
||||||
AliYun.get().setShareId(shareId);
|
return AliYun.get().getVod(id, shareId, fileId);
|
||||||
return AliYun.get().getVod(id, fileId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -56,7 +54,7 @@ public class Ali extends Spider {
|
||||||
*/
|
*/
|
||||||
public String detailContentVodPlayFrom(List<String> ids) {
|
public String detailContentVodPlayFrom(List<String> ids) {
|
||||||
List<String> playFrom = new ArrayList<>();
|
List<String> playFrom = new ArrayList<>();
|
||||||
if (ids.size() < 1) return TextUtils.join("$$$", Arrays.asList("原畫", "普畫"));
|
if (ids.size() < 2) return TextUtils.join("$$$", Arrays.asList("原畫", "普畫"));
|
||||||
for (int i = 1; i <= ids.size(); i++) {
|
for (int i = 1; i <= ids.size(); i++) {
|
||||||
playFrom.add(String.format(Locale.getDefault(), "原畫#%02d", i));
|
playFrom.add(String.format(Locale.getDefault(), "原畫#%02d", i));
|
||||||
playFrom.add(String.format(Locale.getDefault(), "普畫#%02d", i));
|
playFrom.add(String.format(Locale.getDefault(), "普畫#%02d", i));
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,12 @@ public class Miss extends Spider {
|
||||||
List<Vod> list = new ArrayList<>();
|
List<Vod> list = new ArrayList<>();
|
||||||
List<Class> classes = new ArrayList<>();
|
List<Class> classes = new ArrayList<>();
|
||||||
LinkedHashMap<String, List<Filter>> filters = new LinkedHashMap<>();
|
LinkedHashMap<String, List<Filter>> filters = new LinkedHashMap<>();
|
||||||
List<String> typeIds = Arrays.asList("chinese-subtitle", "new", "release", "uncensored-leak", "today-hot", "weekly-hot", "monthly-hot", "siro", "luxu", "gana", "maan", "scute", "ara", "uncensored-leak", "fc2", "heyzo", "tokyohot", "1pondo", "caribbeancom", "caribbeancompr", "10musume", "pacopacomama", "gachinco", "xxxav", "marriedslash", "naughty4610", "naughty0930", "madou", "twav");
|
|
||||||
Document doc = Jsoup.parse(OkHttp.string(url));
|
Document doc = Jsoup.parse(OkHttp.string(url));
|
||||||
for (Element a : doc.select("nav").select("a")) {
|
for (Element a : doc.select("nav a")) {
|
||||||
String typeName = a.text();
|
String typeName = a.text();
|
||||||
|
if (!a.attr("href").startsWith("http")) continue;
|
||||||
String typeId = a.attr("href").replace(url, "");
|
String typeId = a.attr("href").replace(url, "");
|
||||||
if (!typeIds.contains(typeId)) continue;
|
if (typeId.startsWith("http")) continue;
|
||||||
classes.add(new Class(typeId, typeName));
|
classes.add(new Class(typeId, typeName));
|
||||||
filters.put(typeId, Arrays.asList(new Filter("filters", "過濾", Arrays.asList(new Filter.Value("全部", ""), new Filter.Value("單人作品", "individual"), new Filter.Value("中文字幕", "chinese-subtitle")))));
|
filters.put(typeId, Arrays.asList(new Filter("filters", "過濾", Arrays.asList(new Filter.Value("全部", ""), new Filter.Value("單人作品", "individual"), new Filter.Value("中文字幕", "chinese-subtitle")))));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import com.github.catvod.bean.Result;
|
||||||
import com.github.catvod.bean.Vod;
|
import com.github.catvod.bean.Vod;
|
||||||
import com.github.catvod.net.OkHttp;
|
import com.github.catvod.net.OkHttp;
|
||||||
import com.github.catvod.utils.Utils;
|
import com.github.catvod.utils.Utils;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
|
|
@ -31,7 +32,7 @@ public class Wogg extends Ali {
|
||||||
private final Pattern regexCategory = Pattern.compile("/vodtype/(\\w+).html");
|
private final Pattern regexCategory = Pattern.compile("/vodtype/(\\w+).html");
|
||||||
private final Pattern regexPageTotal = Pattern.compile("\\$\\(\"\\.mac_total\"\\)\\.text\\('(\\d+)'\\);");
|
private final Pattern regexPageTotal = Pattern.compile("\\$\\(\"\\.mac_total\"\\)\\.text\\('(\\d+)'\\);");
|
||||||
|
|
||||||
private String extend;
|
private JsonObject extend;
|
||||||
|
|
||||||
private Map<String, String> getHeader() {
|
private Map<String, String> getHeader() {
|
||||||
Map<String, String> header = new HashMap<>();
|
Map<String, String> header = new HashMap<>();
|
||||||
|
|
@ -41,12 +42,14 @@ public class Wogg extends Ali {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Context context, String extend) {
|
public void init(Context context, String extend) {
|
||||||
this.extend = extend;
|
this.extend = JsonParser.parseString(extend).getAsJsonObject();
|
||||||
|
super.init(context, this.extend.get("token").getAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String homeContent(boolean filter) {
|
public String homeContent(boolean filter) {
|
||||||
List<Class> classes = new ArrayList<>();
|
List<Class> classes = new ArrayList<>();
|
||||||
|
String url = extend.get("filter").getAsString();
|
||||||
Document doc = Jsoup.parse(OkHttp.string(siteUrl, getHeader()));
|
Document doc = Jsoup.parse(OkHttp.string(siteUrl, getHeader()));
|
||||||
Elements elements = doc.select(".nav-link");
|
Elements elements = doc.select(".nav-link");
|
||||||
for (Element e : elements) {
|
for (Element e : elements) {
|
||||||
|
|
@ -55,7 +58,7 @@ public class Wogg extends Ali {
|
||||||
classes.add(new Class(mather.group(1), e.text().trim()));
|
classes.add(new Class(mather.group(1), e.text().trim()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Result.string(classes, this.parseVodListFromDoc(doc), filter ? JsonParser.parseString(OkHttp.string(extend)) : null);
|
return Result.string(classes, parseVodListFromDoc(doc), filter ? JsonParser.parseString(OkHttp.string(url)) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -71,7 +74,7 @@ public class Wogg extends Ali {
|
||||||
Matcher matcher = regexPageTotal.matcher(doc.html());
|
Matcher matcher = regexPageTotal.matcher(doc.html());
|
||||||
if (matcher.find()) total = Integer.parseInt(matcher.group(1));
|
if (matcher.find()) total = Integer.parseInt(matcher.group(1));
|
||||||
int count = total <= limit ? 1 : ((int) Math.ceil(total / (double) limit));
|
int count = total <= limit ? 1 : ((int) Math.ceil(total / (double) limit));
|
||||||
return Result.get().vod(this.parseVodListFromDoc(doc)).page(page, count, limit, total).string();
|
return Result.get().vod(parseVodListFromDoc(doc)).page(page, count, limit, total).string();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Vod> parseVodListFromDoc(Document doc) {
|
private List<Vod> parseVodListFromDoc(Document doc) {
|
||||||
|
|
|
||||||
|
|
@ -1,124 +0,0 @@
|
||||||
package com.github.catvod.utils;
|
|
||||||
|
|
||||||
import java.text.Collator;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 按照 Windows 排序风格,对给定的数字、字母、汉字字符串进行排序
|
|
||||||
*
|
|
||||||
* @author Oiltea
|
|
||||||
*/
|
|
||||||
public class ChineseComparator {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数字类型
|
|
||||||
*/
|
|
||||||
private static final Integer TYPE_NUMBER = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字符类型(非数字)
|
|
||||||
*/
|
|
||||||
private static final Integer TYPE_CHARACTER = 1;
|
|
||||||
|
|
||||||
public static int compare(String o1, String o2) {
|
|
||||||
// 根据字符数组生成带分类的字符列表
|
|
||||||
// List<Object>的第一位为该字符的类型(TYPE_NUMBER, TYPE_CHARACTER)
|
|
||||||
// List<Object>的第二位为该字符的内容(一位数字, 一位非数字, 多位数字)
|
|
||||||
List<List<Object>> o1CharList = getCharList(o1);
|
|
||||||
List<List<Object>> o2CharList = getCharList(o2);
|
|
||||||
|
|
||||||
// 统一CharList的长度
|
|
||||||
int max = Math.max(o1CharList.size(), o2CharList.size());
|
|
||||||
while (o1CharList.size() < max) {
|
|
||||||
o1CharList.add(new ArrayList<>());
|
|
||||||
}
|
|
||||||
while (o2CharList.size() < max) {
|
|
||||||
o2CharList.add(new ArrayList<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 开始比较
|
|
||||||
int compare = 0;
|
|
||||||
for (int i = 0; i < max; i++) {
|
|
||||||
List<Object> o1list = o1CharList.get(i);
|
|
||||||
List<Object> o2list = o2CharList.get(i);
|
|
||||||
|
|
||||||
// CharList短的,排在前面
|
|
||||||
if (o1list.size() == 0) {
|
|
||||||
compare = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (o2list.size() == 0) {
|
|
||||||
compare = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 先比较类型
|
|
||||||
Integer o1Type = (Integer) o1list.get(0);
|
|
||||||
Integer o2Type = (Integer) o2list.get(0);
|
|
||||||
int typeCompare = Integer.compare(o1Type, o2Type);
|
|
||||||
if (typeCompare != 0) {
|
|
||||||
// 类型不同,则数字在前,非数字在后
|
|
||||||
compare = typeCompare;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
// 类型相同,则比较内容
|
|
||||||
if (TYPE_NUMBER.equals(o1Type)) {
|
|
||||||
// 比较数字
|
|
||||||
int o1Content = Integer.parseInt(o1list.get(1).toString());
|
|
||||||
int o2Content = Integer.parseInt(o2list.get(1).toString());
|
|
||||||
compare = Integer.compare(o1Content, o2Content);
|
|
||||||
} else if (TYPE_CHARACTER.equals(o1Type)) {
|
|
||||||
// 比较非数字
|
|
||||||
String o1Content = (String) o1list.get(1);
|
|
||||||
String o2Content = (String) o2list.get(1);
|
|
||||||
compare = Collator.getInstance(Locale.CHINESE).compare(o1Content, o2Content);
|
|
||||||
}
|
|
||||||
// 如果不相等,则退出比较
|
|
||||||
if (compare != 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return compare;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据字符数组生成带分类的字符列表
|
|
||||||
*
|
|
||||||
* @param text 字符串
|
|
||||||
* @return 带分类的字符列表,List<Object>的第一位为该字符的类型(TYPE_NUMBER, TYPE_CHARACTER),第二位为该字符的内容
|
|
||||||
*/
|
|
||||||
private static List<List<Object>> getCharList(String text) {
|
|
||||||
char[] chars = text.toCharArray();
|
|
||||||
List<List<Object>> charList = new ArrayList<>();
|
|
||||||
for (int i = 0; i < chars.length; i++) {
|
|
||||||
List<Object> list = new ArrayList<>();
|
|
||||||
// 是否为数字
|
|
||||||
char c = chars[i];
|
|
||||||
if ((int) c >= '0' && (int) c <= '9') {
|
|
||||||
StringBuilder str = new StringBuilder();
|
|
||||||
// 下一位是否为数字,如果为数字则组成多位数
|
|
||||||
do {
|
|
||||||
str.append(c);
|
|
||||||
if (i + 1 < chars.length) {
|
|
||||||
c = chars[++i];
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} while ((int) c >= '0' && (int) c <= '9');
|
|
||||||
if (!(i + 1 == chars.length) || !((int) c >= '0' && (int) c <= '9')) {
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
list.add(TYPE_NUMBER);
|
|
||||||
list.add(str.toString());
|
|
||||||
} else {
|
|
||||||
list.add(TYPE_CHARACTER);
|
|
||||||
list.add(String.valueOf(c));
|
|
||||||
}
|
|
||||||
charList.add(list);
|
|
||||||
}
|
|
||||||
return charList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -21,6 +21,7 @@ import java.security.MessageDigest;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
@ -28,11 +29,7 @@ public class Utils {
|
||||||
public static final String CHROME = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36";
|
public static final String CHROME = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36";
|
||||||
public static final String ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7";
|
public static final String ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7";
|
||||||
public static final List<String> MEDIA = Arrays.asList("mp4", "mkv", "wmv", "flv", "avi", "mp3", "aac", "flac", "m4a", "ape", "ogg");
|
public static final List<String> MEDIA = Arrays.asList("mp4", "mkv", "wmv", "flv", "avi", "mp3", "aac", "flac", "m4a", "ape", "ogg");
|
||||||
public static final Pattern RULE = Pattern.compile(
|
public static final Pattern RULE = Pattern.compile("http((?!http).){12,}?\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a|mp3)\\?.*|" + "http((?!http).){12,}\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a|mp3)|" + "http((?!http).)*?video/tos*");
|
||||||
"http((?!http).){12,}?\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a|mp3)\\?.*|" +
|
|
||||||
"http((?!http).){12,}\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a|mp3)|" +
|
|
||||||
"http((?!http).)*?video/tos*"
|
|
||||||
);
|
|
||||||
|
|
||||||
public static boolean isVip(String url) {
|
public static boolean isVip(String url) {
|
||||||
List<String> hosts = Arrays.asList("iqiyi.com", "v.qq.com", "youku.com", "le.com", "tudou.com", "mgtv.com", "sohu.com", "acfun.cn", "bilibili.com", "baofeng.com", "pptv.com");
|
List<String> hosts = Arrays.asList("iqiyi.com", "v.qq.com", "youku.com", "le.com", "tudou.com", "mgtv.com", "sohu.com", "acfun.cn", "bilibili.com", "baofeng.com", "pptv.com");
|
||||||
|
|
@ -194,4 +191,14 @@ public class Utils {
|
||||||
webView.loadUrl(url);
|
webView.loadUrl(url);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getDigit(String text) {
|
||||||
|
try {
|
||||||
|
Matcher matcher = Pattern.compile(".*(1080|720|2160|4k|4K).*").matcher(text);
|
||||||
|
if (matcher.find()) text = matcher.group(1) + text;
|
||||||
|
return Integer.parseInt(text.replaceAll("\\D+", ""));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
dede7a67d11523b79d649c152910fd6a
|
a296bd2bc81da9960738fa6edd394246
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue