diff --git a/app/build.gradle b/app/build.gradle index e2563af..b4f57e1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,6 +12,7 @@ android { targetSdk 29 ndk { abiFilters "armeabi-v7a" } buildConfigField("String", "APP_ID", "\"${appId}\"") + buildConfigField("String", "CLIENT_ID", "\"${clientId}\"") } buildTypes { 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 5711614..1d4fca0 100644 --- a/app/src/main/java/com/github/catvod/ali/API.java +++ b/app/src/main/java/com/github/catvod/ali/API.java @@ -116,16 +116,16 @@ public class API { return result; } - private String authOpen(String url, JSONObject body, boolean retry) { - String result = OkHttp.postJson(url, body.toString(), getHeaderAuthOpen()); - if (retry && check401Open(result)) return authOpen(url, body, false); + private String authOpen(String url, String json, boolean retry) { + String result = OkHttp.postJson(url, json, getHeaderAuthOpen()); + if (retry && check401Open(result)) return authOpen(url, json, false); return result; } - private String sign(String url, JSONObject body, boolean retry) { + private String sign(String url, String json, boolean retry) { url = url.startsWith("https") ? url : "https://api.aliyundrive.com/" + url; - String result = OkHttp.postJson(url, body.toString(), getHeaderSign()); - if (retry && check401(result)) return sign(url, body, false); + String result = OkHttp.postJson(url, json, getHeaderSign()); + if (retry && check401(result)) return sign(url, json, false); return result; } @@ -170,7 +170,7 @@ public class API { body = new JSONObject(); body.put("authorize", 1); body.put("scope", "user:base,file:all:read,file:all:write"); - object = new JSONObject(auth("https://open.aliyundrive.com/oauth/users/authorize?client_id=76917ccccd4441c39457a04f6084fb2f&redirect_uri=https://alist.nn.ci/tool/aliyundrive/callback&scope=user:base,file:all:read,file:all:write&state=", body, false)); + object = new JSONObject(auth("https://open.aliyundrive.com/oauth/users/authorize?client_id=" + BuildConfig.CLIENT_ID + "&redirect_uri=https://alist.nn.ci/tool/aliyundrive/callback&scope=user:base,file:all:read,file:all:write&state=", body, false)); String code = object.toString().substring(object.toString().indexOf("code=") + 5, 104); //OAuth Redirect body = new JSONObject(); @@ -234,7 +234,7 @@ public class API { body.put("nonce", 0); body.put("pubKey", pubKey); body.put("refreshToken", auth.getRefreshToken()); - JSONObject object = new JSONObject(sign("users/v1/users/device/create_session", body, false)); + JSONObject object = new JSONObject(sign("users/v1/users/device/create_session", body.toString(), false)); if (!object.getBoolean("success")) throw new Exception(object.toString()); return true; } catch (Exception e) { @@ -358,7 +358,7 @@ public class API { JSONObject body = new JSONObject(); body.put("file_id", fileId); body.put("drive_id", auth.getDriveId()); - String url = new JSONObject(authOpen("https://open.aliyundrive.com/adrive/v1.0/openFile/getDownloadUrl", body, true)).optString("url"); + String url = new JSONObject(authOpen("https://open.aliyundrive.com/adrive/v1.0/openFile/getDownloadUrl", body.toString(), true)).optString("url"); delete(fileId); return url; } @@ -428,7 +428,7 @@ public class API { body.put("share_id", auth.getShareId()); body.put("template_id", ""); body.put("category", "live_transcoding"); - String json = sign("v2/file/get_share_link_video_preview_play_info", body, true); + String json = sign("v2/file/get_share_link_video_preview_play_info", body.toString(), true); JSONArray taskList = new JSONObject(json).getJSONObject("video_preview_play_info").getJSONArray("live_transcoding_task_list"); Map> respHeaders = new HashMap<>(); OkHttp.stringNoRedirect(getPreviewQuality(taskList, flag), getHeader(), respHeaders); diff --git a/gradle.properties b/gradle.properties index 78dee4e..024245e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,4 +19,5 @@ android.useAndroidX=true # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library android.nonTransitiveRClass=true -appId=5dde4e1bdf9e4966b387ba58f4b3fdc3 \ No newline at end of file +appId=5dde4e1bdf9e4966b387ba58f4b3fdc3 +clientId=76917ccccd4441c39457a04f6084fb2f \ No newline at end of file diff --git a/jar/custom_spider.jar b/jar/custom_spider.jar index a377289..189b2c9 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 32e4311..a69a518 100644 --- a/jar/custom_spider.jar.md5 +++ b/jar/custom_spider.jar.md5 @@ -1 +1 @@ -1862134a5028c5720a5c9eb24245144a +45d9462277175c390ccab72992b8c917