This commit is contained in:
FongMi 2023-01-04 17:00:50 +08:00
parent 200957d0fa
commit 59f1030ed9
1 changed files with 3 additions and 6 deletions

View File

@ -12,7 +12,6 @@ import com.github.catvod.bean.Vod;
import com.github.catvod.bean.ali.Auth; import com.github.catvod.bean.ali.Auth;
import com.github.catvod.bean.ali.Data; import com.github.catvod.bean.ali.Data;
import com.github.catvod.bean.ali.Item; import com.github.catvod.bean.ali.Item;
import com.github.catvod.crawler.SpiderDebug;
import com.github.catvod.net.OkHttp; import com.github.catvod.net.OkHttp;
import com.github.catvod.utils.Misc; import com.github.catvod.utils.Misc;
import com.github.catvod.utils.Prefers; import com.github.catvod.utils.Prefers;
@ -58,8 +57,6 @@ public class Ali {
} }
public Ali init(String token) { public Ali init(String token) {
if (TextUtils.isEmpty(token)) Init.show("尚未設定 Token");
if (token.startsWith("http")) token = OkHttp.string(token);
auth.setRefreshToken(Prefers.getString("token", token)); auth.setRefreshToken(Prefers.getString("token", token));
return this; return this;
} }
@ -186,12 +183,13 @@ public class Ali {
private boolean refreshAccessToken() { private boolean refreshAccessToken() {
try { try {
JSONObject body = new JSONObject(); JSONObject body = new JSONObject();
body.put("refresh_token", auth.getRefreshToken()); String token = auth.getRefreshToken();
if (token.startsWith("http")) token = OkHttp.string(token);
body.put("refresh_token", token);
body.put("grant_type", "refresh_token"); body.put("grant_type", "refresh_token");
JSONObject object = new JSONObject(post("https://auth.aliyundrive.com/v2/account/token", body)); JSONObject object = new JSONObject(post("https://auth.aliyundrive.com/v2/account/token", body));
auth.setAccessToken(object.getString("token_type") + " " + object.getString("access_token")); auth.setAccessToken(object.getString("token_type") + " " + object.getString("access_token"));
auth.setRefreshToken(object.getString("refresh_token")); auth.setRefreshToken(object.getString("refresh_token"));
SpiderDebug.log("refresh token: " + auth.getRefreshToken());
return true; return true;
} catch (Exception e) { } catch (Exception e) {
checkService(); checkService();
@ -210,7 +208,6 @@ public class Ali {
body.put("share_pwd", ""); body.put("share_pwd", "");
JSONObject object = new JSONObject(post("v2/share_link/get_share_token", body)); JSONObject object = new JSONObject(post("v2/share_link/get_share_token", body));
auth.setShareToken(object.getString("share_token")); auth.setShareToken(object.getString("share_token"));
SpiderDebug.log("share token: " + auth.getShareToken());
return true; return true;
} catch (Exception e) { } catch (Exception e) {
Init.show("來晚啦,該分享已失效。"); Init.show("來晚啦,該分享已失效。");