diff --git a/app/src/main/java/com/github/catvod/ali/API.java b/app/src/main/java/com/github/catvod/ali/API.java index 1fb3ffb0..d3efb518 100644 --- a/app/src/main/java/com/github/catvod/ali/API.java +++ b/app/src/main/java/com/github/catvod/ali/API.java @@ -30,12 +30,15 @@ import org.json.JSONArray; import org.json.JSONObject; import java.io.ByteArrayInputStream; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; +import java.util.TimeZone; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -69,7 +72,15 @@ public class API { } public void setRefreshToken(String token) { - if (auth.getRefreshToken().isEmpty()) auth.setRefreshToken(token); + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault()); + sdf.setTimeZone(TimeZone.getTimeZone("GMT")); + long expireTime = sdf.parse(auth.getExpireTime()).getTime(); + boolean expired = expireTime < System.currentTimeMillis(); + if (expired) auth.setRefreshToken(token); + } catch (Exception e) { + auth.setRefreshToken(token); + } } public void setShareId(String shareId) { @@ -365,9 +376,14 @@ public class API { } private void delete(String 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\"}"; - json = String.format(json, auth.getDriveId(), fileId, fileId); - auth("adrive/v2/batch", json, true); + try { + JSONObject body = new JSONObject(); + body.put("file_id", fileId); + body.put("drive_id", auth.getDriveId()); + oauth("openFile/delete", body.toString(), false); + } catch (Exception e) { + e.printStackTrace(); + } } public Object[] proxySub(Map params) { diff --git a/app/src/main/java/com/github/catvod/bean/ali/Auth.java b/app/src/main/java/com/github/catvod/bean/ali/Auth.java index 178bf7d6..9dde59a1 100644 --- a/app/src/main/java/com/github/catvod/bean/ali/Auth.java +++ b/app/src/main/java/com/github/catvod/bean/ali/Auth.java @@ -20,6 +20,8 @@ public class Auth { private String userId; @SerializedName("driveId") private String driveId; + @SerializedName("expire_time") + private String expireTime; public static Auth objectFrom(String str) { Auth item = new Gson().fromJson(str, Auth.class); @@ -74,6 +76,10 @@ public class Auth { this.userId = userId; } + public String getExpireTime() { + return TextUtils.isEmpty(expireTime) ? "" : expireTime; + } + public boolean isEmpty() { return getAccessToken().isEmpty(); } diff --git a/jar/custom_spider.jar b/jar/custom_spider.jar index fe48eefe..d05312b5 100644 Binary files a/jar/custom_spider.jar and b/jar/custom_spider.jar differ diff --git a/jar/custom_spider.jar.md5 b/jar/custom_spider.jar.md5 index 57ee7ff2..ed2a1aa6 100644 --- a/jar/custom_spider.jar.md5 +++ b/jar/custom_spider.jar.md5 @@ -1 +1 @@ -ac115573e4f120c68c0702f89150dbf3 +1ca9fdc9e2698559f42704622465c286 diff --git a/json/adult.json b/json/adult.json index 981ce678..90b9b53a 100644 --- a/json/adult.json +++ b/json/adult.json @@ -1,5 +1,5 @@ { - "spider": "https://ghproxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;ac115573e4f120c68c0702f89150dbf3", + "spider": "https://ghproxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;1ca9fdc9e2698559f42704622465c286", "wallpaper": "https://gao.chuqiuyu.tk", "sites": [ { diff --git a/json/config.json b/json/config.json index f36da0fa..1c7ea35d 100644 --- a/json/config.json +++ b/json/config.json @@ -1,5 +1,5 @@ { - "spider": "https://ghproxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;ac115573e4f120c68c0702f89150dbf3", + "spider": "https://ghproxy.com/https://raw.githubusercontent.com/FongMi/CatVodSpider/main/jar/custom_spider.jar;md5;1ca9fdc9e2698559f42704622465c286", "wallpaper": "http://饭太硬.ga/深色壁纸/api.php", "sites": [ {