Update ali qrcode token
This commit is contained in:
parent
1e64219123
commit
bf2c9e501a
|
|
@ -0,0 +1,66 @@
|
||||||
|
package com.github.catvod.bean.ali;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Biz {
|
||||||
|
|
||||||
|
@SerializedName("pds_login_result")
|
||||||
|
private Biz pdsLoginResult;
|
||||||
|
@SerializedName("role")
|
||||||
|
private String role;
|
||||||
|
@SerializedName("isFirstLogin")
|
||||||
|
private Boolean isFirstLogin;
|
||||||
|
@SerializedName("needLink")
|
||||||
|
private Boolean needLink;
|
||||||
|
@SerializedName("loginType")
|
||||||
|
private String loginType;
|
||||||
|
@SerializedName("nickName")
|
||||||
|
private String nickName;
|
||||||
|
@SerializedName("needRpVerify")
|
||||||
|
private Boolean needRpVerify;
|
||||||
|
@SerializedName("avatar")
|
||||||
|
private String avatar;
|
||||||
|
@SerializedName("accessToken")
|
||||||
|
private String accessToken;
|
||||||
|
@SerializedName("userName")
|
||||||
|
private String userName;
|
||||||
|
@SerializedName("userId")
|
||||||
|
private String userId;
|
||||||
|
@SerializedName("defaultDriveId")
|
||||||
|
private String defaultDriveId;
|
||||||
|
@SerializedName("existLink")
|
||||||
|
private List<?> existLink;
|
||||||
|
@SerializedName("expiresIn")
|
||||||
|
private Integer expiresIn;
|
||||||
|
@SerializedName("expireTime")
|
||||||
|
private String expireTime;
|
||||||
|
@SerializedName("requestId")
|
||||||
|
private String requestId;
|
||||||
|
@SerializedName("dataPinSetup")
|
||||||
|
private Boolean dataPinSetup;
|
||||||
|
@SerializedName("state")
|
||||||
|
private String state;
|
||||||
|
@SerializedName("tokenType")
|
||||||
|
private String tokenType;
|
||||||
|
@SerializedName("dataPinSaved")
|
||||||
|
private Boolean dataPinSaved;
|
||||||
|
@SerializedName("refreshToken")
|
||||||
|
private String refreshToken;
|
||||||
|
@SerializedName("status")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
public static Biz objectFrom(String str) {
|
||||||
|
return new Gson().fromJson(str, Biz.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Biz getPdsLoginResult() {
|
||||||
|
return pdsLoginResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRefreshToken() {
|
||||||
|
return refreshToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,24 +1,31 @@
|
||||||
package com.github.catvod.bean.ali;
|
package com.github.catvod.bean.ali;
|
||||||
|
|
||||||
|
import android.util.Base64;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
public class Data {
|
public class Data {
|
||||||
|
|
||||||
@SerializedName(value = "data", alternate = "pds_login_result")
|
@SerializedName("data")
|
||||||
private Data data;
|
private Data data;
|
||||||
|
@SerializedName("content")
|
||||||
|
private Data content;
|
||||||
@SerializedName("t")
|
@SerializedName("t")
|
||||||
private String t;
|
private String t;
|
||||||
@SerializedName("ck")
|
@SerializedName("ck")
|
||||||
private String ck;
|
private String ck;
|
||||||
@SerializedName("codeContent")
|
@SerializedName("codeContent")
|
||||||
private String codeContent;
|
private String codeContent;
|
||||||
@SerializedName("refreshToken")
|
@SerializedName("qrCodeStatus")
|
||||||
private String refreshToken;
|
private String qrCodeStatus;
|
||||||
|
@SerializedName("bizExt")
|
||||||
|
private String bizExt;
|
||||||
|
|
||||||
public static Data objectFrom(String str) {
|
public static Data objectFrom(String str) {
|
||||||
try {
|
try {
|
||||||
return new Gson().fromJson(str, Data.class);
|
Data data = new Gson().fromJson(str, Data.class);
|
||||||
|
return data == null ? new Data() : data;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return new Data();
|
return new Data();
|
||||||
}
|
}
|
||||||
|
|
@ -28,8 +35,8 @@ public class Data {
|
||||||
return data == null ? new Data() : data;
|
return data == null ? new Data() : data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasToken() {
|
public Data getContent() {
|
||||||
return getData().getRefreshToken().length() > 0;
|
return content == null ? new Data() : content;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getT() {
|
public String getT() {
|
||||||
|
|
@ -44,7 +51,23 @@ public class Data {
|
||||||
return codeContent == null ? "" : codeContent;
|
return codeContent == null ? "" : codeContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRefreshToken() {
|
public String getQrCodeStatus() {
|
||||||
return refreshToken == null ? "" : refreshToken;
|
return qrCodeStatus == null ? "" : qrCodeStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBizExt() {
|
||||||
|
return bizExt == null ? "" : bizExt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToken() {
|
||||||
|
return Biz.objectFrom(new String(Base64.decode(getBizExt(), Base64.DEFAULT))).getPdsLoginResult().getRefreshToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasToken() {
|
||||||
|
return getQrCodeStatus().equals("CONFIRMED") && getBizExt().length() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExpired() {
|
||||||
|
return getQrCodeStatus().equals("EXPIRED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,10 @@ 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.net.OkHttp;
|
import com.github.catvod.net.OkHttp;
|
||||||
import com.github.catvod.utils.Utils;
|
|
||||||
import com.github.catvod.utils.Prefers;
|
import com.github.catvod.utils.Prefers;
|
||||||
import com.github.catvod.utils.QRCode;
|
import com.github.catvod.utils.QRCode;
|
||||||
import com.github.catvod.utils.Trans;
|
import com.github.catvod.utils.Trans;
|
||||||
import com.google.gson.JsonObject;
|
import com.github.catvod.utils.Utils;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
@ -32,6 +31,7 @@ import java.util.Map;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
@ -41,7 +41,6 @@ import java.util.regex.Pattern;
|
||||||
public class Ali {
|
public class Ali {
|
||||||
|
|
||||||
public static final Pattern pattern = Pattern.compile("www.aliyundrive.com/s/([^/]+)(/folder/([^/]+))?");
|
public static final Pattern pattern = Pattern.compile("www.aliyundrive.com/s/([^/]+)(/folder/([^/]+))?");
|
||||||
private static final String QRCODE = "https://token.cooluc.com/";
|
|
||||||
private ScheduledExecutorService service;
|
private ScheduledExecutorService service;
|
||||||
private final Auth auth;
|
private final Auth auth;
|
||||||
|
|
||||||
|
|
@ -195,7 +194,7 @@ public class Ali {
|
||||||
auth.setRefreshToken(object.getString("refresh_token"));
|
auth.setRefreshToken(object.getString("refresh_token"));
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
checkService();
|
stopService();
|
||||||
auth.clean();
|
auth.clean();
|
||||||
getQRCode();
|
getQRCode();
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -304,23 +303,32 @@ public class Ali {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkService() {
|
private void stopService() {
|
||||||
if (service != null) service.shutdownNow();
|
if (service != null) service.shutdownNow();
|
||||||
if (auth.getView() != null) Init.run(() -> Utils.removeView(auth.getView()));
|
if (auth.getView() != null) Init.run(() -> Utils.removeView(auth.getView()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getQRCode() {
|
private void getQRCode() {
|
||||||
HashMap<String, String> headers = new HashMap<>();
|
AtomicInteger time = new AtomicInteger();
|
||||||
headers.put("User-Agent", Utils.CHROME);
|
Data data = Data.objectFrom(OkHttp.string("https://passport.aliyundrive.com/newlogin/qrcode/generate.do?appName=aliyun_drive&fromSite=52&appName=aliyun_drive&appEntrance=web&isMobile=false&lang=zh_CN&returnUrl=&bizParams=&_bx-v=2.0.3")).getContent().getData();
|
||||||
Data data = Data.objectFrom(OkHttp.string(QRCODE + "qr", headers));
|
Init.run(() -> showCode(data));
|
||||||
if (data != null) Init.run(() -> showCode(data));
|
|
||||||
service = Executors.newScheduledThreadPool(1);
|
service = Executors.newScheduledThreadPool(1);
|
||||||
if (data != null) service.scheduleAtFixedRate(() -> {
|
service.scheduleAtFixedRate(() -> {
|
||||||
JsonObject params = new JsonObject();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.addProperty("t", data.getData().getT());
|
params.put("t", data.getT());
|
||||||
params.addProperty("ck", data.getData().getCk());
|
params.put("ck", data.getCk());
|
||||||
Data result = Data.objectFrom(OkHttp.postJson(QRCODE + "ck", params.toString(), headers));
|
params.put("appName", "aliyun_drive");
|
||||||
if (result.hasToken()) setToken(result.getData().getRefreshToken());
|
params.put("appEntrance", "web");
|
||||||
|
params.put("isMobile", "false");
|
||||||
|
params.put("lang", "zh_CN");
|
||||||
|
params.put("returnUrl", "");
|
||||||
|
params.put("fromSite", "52");
|
||||||
|
params.put("bizParams", "");
|
||||||
|
params.put("navlanguage", "zh-CN");
|
||||||
|
params.put("navPlatform", "MacIntel");
|
||||||
|
Data result = Data.objectFrom(OkHttp.post("https://passport.aliyundrive.com/newlogin/qrcode/query.do?appName=aliyun_drive&fromSite=52&_bx-v=2.0.31", params)).getContent().getData();
|
||||||
|
if (result.hasToken()) setToken(result.getToken());
|
||||||
|
if (time.incrementAndGet() > 29) stopService();
|
||||||
}, 1, 1, TimeUnit.SECONDS);
|
}, 1, 1, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -328,14 +336,14 @@ public class Ali {
|
||||||
Prefers.put("token", value);
|
Prefers.put("token", value);
|
||||||
Init.show("請重新進入播放頁");
|
Init.show("請重新進入播放頁");
|
||||||
auth.setRefreshToken(value);
|
auth.setRefreshToken(value);
|
||||||
checkService();
|
stopService();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showCode(Data data) {
|
private void showCode(Data data) {
|
||||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||||
params.gravity = Gravity.CENTER;
|
params.gravity = Gravity.CENTER;
|
||||||
Utils.addView(create(data.getData().getCodeContent()), params);
|
Utils.addView(create(data.getCodeContent()), params);
|
||||||
//Init.show("請使用阿里雲盤 App 掃描二維碼");
|
Init.show("請使用阿里雲盤 App 掃描二維碼");
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImageView create(String value) {
|
private ImageView create(String value) {
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
82faef05c014eb6446663824eb77535e
|
ff85cd0428496acedc5c8a4599583862
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue