Update mobile token fetch
This commit is contained in:
parent
59fe1d09da
commit
84c1ad8514
|
|
@ -7,6 +7,8 @@ import android.graphics.drawable.ColorDrawable;
|
|||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
|
|
@ -79,6 +81,14 @@ public class API {
|
|||
this.refreshToken = token;
|
||||
}
|
||||
|
||||
public Object[] getToken() {
|
||||
Object[] result = new Object[3];
|
||||
result[0] = 200;
|
||||
result[1] = "text/plain";
|
||||
result[2] = new ByteArrayInputStream(user.getRefreshToken().getBytes());
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setShareId(String shareId) {
|
||||
this.shareId = shareId;
|
||||
refreshShareToken();
|
||||
|
|
@ -178,6 +188,7 @@ public class API {
|
|||
if (oauth.getAccessToken().isEmpty()) oauthRequest();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
user.clean().save();
|
||||
SpiderDebug.log(e);
|
||||
stopService();
|
||||
|
|
@ -436,14 +447,35 @@ public class API {
|
|||
|
||||
private void getQRCode() {
|
||||
if (Utils.isMobile()) {
|
||||
user.setRefreshToken(refreshToken);
|
||||
refreshAccessToken();
|
||||
Init.run(this::showInput);
|
||||
} else {
|
||||
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.2.3")).getContent().getData();
|
||||
String url = "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.2.3";
|
||||
Data data = Data.objectFrom(OkHttp.string(url)).getContent().getData();
|
||||
Init.run(() -> showQRCode(data));
|
||||
}
|
||||
}
|
||||
|
||||
private void showInput() {
|
||||
try {
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(Utils.dp2px(16), Utils.dp2px(16), Utils.dp2px(16), Utils.dp2px(16));
|
||||
FrameLayout frame = new FrameLayout(Init.context());
|
||||
EditText input = new EditText(Init.context());
|
||||
frame.addView(input, params);
|
||||
dialog = new AlertDialog.Builder(Init.getActivity()).setTitle("請輸入Token").setView(frame).setNegativeButton(android.R.string.cancel, null).setPositiveButton(android.R.string.ok, (dialog, which) -> onPositive(input.getText().toString())).show();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private void onPositive(String text) {
|
||||
dialog.dismiss();
|
||||
Init.execute(() -> {
|
||||
if (text.startsWith("http")) setToken(OkHttp.string(text));
|
||||
else if (text.length() == 32) setToken(text);
|
||||
else if (text.contains(":")) setToken(OkHttp.string("http://" + text + "/proxy?do=ali&type=token"));
|
||||
});
|
||||
}
|
||||
|
||||
private void showQRCode(Data data) {
|
||||
try {
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(Utils.dp2px(240), Utils.dp2px(240));
|
||||
|
|
@ -470,7 +502,8 @@ public class API {
|
|||
}
|
||||
|
||||
private void setToken(String value) {
|
||||
Init.show("請重新進入播放頁");
|
||||
SpiderDebug.log("Token:" + value);
|
||||
Init.show("Token:" + value);
|
||||
this.refreshToken = value;
|
||||
refreshAccessToken();
|
||||
stopService();
|
||||
|
|
|
|||
|
|
@ -41,9 +41,10 @@ public class Ali extends Spider {
|
|||
return Result.get().url(url).subs(API.get().getSub(ids)).header(API.get().getHeader()).parse(0).string();
|
||||
}
|
||||
|
||||
public static Object[] vod(Map<String, String> params) {
|
||||
public static Object[] proxy(Map<String, String> params) {
|
||||
String type = params.get("type");
|
||||
if (type.equals("sub")) return API.get().proxySub(params);
|
||||
if (type.equals("token")) return API.get().getToken();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@ public class Proxy extends Spider {
|
|||
case "ck":
|
||||
return new Object[]{200, "text/plain; charset=utf-8", new ByteArrayInputStream("ok".getBytes("UTF-8"))};
|
||||
case "ali":
|
||||
return Ali.vod(params);
|
||||
return Ali.proxy(params);
|
||||
case "webdav":
|
||||
return WebDAV.vod(params);
|
||||
default:
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
dadcea0e365a64c6cd3c48b7dd948772
|
||||
73d83409ac27b38de28c7eb6ddcc1c0f
|
||||
|
|
|
|||
Loading…
Reference in New Issue