Update ali
This commit is contained in:
parent
428aa208b3
commit
6900b74cd1
|
|
@ -35,5 +35,6 @@ dependencies {
|
||||||
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
|
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
|
||||||
implementation 'com.google.code.gson:gson:2.9.1'
|
implementation 'com.google.code.gson:gson:2.9.1'
|
||||||
implementation 'cn.wanghaomiao:JsoupXpath:2.5.1'
|
implementation 'cn.wanghaomiao:JsoupXpath:2.5.1'
|
||||||
|
implementation 'com.google.zxing:core:3.5.0'
|
||||||
implementation 'org.jsoup:jsoup:1.15.3'
|
implementation 'org.jsoup:jsoup:1.15.3'
|
||||||
}
|
}
|
||||||
|
|
@ -20,6 +20,12 @@
|
||||||
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
|
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
|
||||||
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken
|
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken
|
||||||
|
|
||||||
|
# Zxing
|
||||||
|
-keepclassmembers enum * {
|
||||||
|
public static **[] values();
|
||||||
|
public static ** valueOf(java.lang.String);
|
||||||
|
}
|
||||||
|
|
||||||
# OkHttp
|
# OkHttp
|
||||||
-keep class okio.**{*;}
|
-keep class okio.**{*;}
|
||||||
-keep class okhttp3.**{*;}
|
-keep class okhttp3.**{*;}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.github.catvod.bean.ali;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
public class Code {
|
||||||
|
|
||||||
|
@SerializedName("data")
|
||||||
|
private Data data;
|
||||||
|
@SerializedName("pds_login_result")
|
||||||
|
private Data result;
|
||||||
|
|
||||||
|
public static Code objectFrom(String str) {
|
||||||
|
try {
|
||||||
|
return new Gson().fromJson(str, Code.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return new Code();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Data getData() {
|
||||||
|
return data == null ? new Data() : data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Data getResult() {
|
||||||
|
return result == null ? new Data() : result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasToken() {
|
||||||
|
return getResult().getRefreshToken().length() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Data {
|
||||||
|
|
||||||
|
@SerializedName("t")
|
||||||
|
private String t;
|
||||||
|
@SerializedName("ck")
|
||||||
|
private String ck;
|
||||||
|
@SerializedName("codeContent")
|
||||||
|
private String codeContent;
|
||||||
|
@SerializedName("refreshToken")
|
||||||
|
private String refreshToken;
|
||||||
|
|
||||||
|
public String getT() {
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCk() {
|
||||||
|
return ck;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCodeContent() {
|
||||||
|
return codeContent == null ? "" : codeContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRefreshToken() {
|
||||||
|
return refreshToken == null ? "" : refreshToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -12,7 +12,6 @@ public class MainActivity extends Activity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
|
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,25 +1,22 @@
|
||||||
package com.github.catvod.spider;
|
package com.github.catvod.spider;
|
||||||
|
|
||||||
import android.graphics.BitmapFactory;
|
import android.os.SystemClock;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Looper;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Base64;
|
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.webkit.WebView;
|
|
||||||
import android.webkit.WebViewClient;
|
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import com.github.catvod.bean.Result;
|
import com.github.catvod.bean.Result;
|
||||||
import com.github.catvod.bean.Vod;
|
import com.github.catvod.bean.Vod;
|
||||||
|
import com.github.catvod.bean.ali.Code;
|
||||||
import com.github.catvod.bean.ali.Item;
|
import com.github.catvod.bean.ali.Item;
|
||||||
import com.github.catvod.net.OkHttpUtil;
|
import com.github.catvod.net.OkHttpUtil;
|
||||||
import com.github.catvod.utils.Misc;
|
import com.github.catvod.utils.Misc;
|
||||||
import com.github.catvod.utils.Prefers;
|
import com.github.catvod.utils.Prefers;
|
||||||
|
import com.github.catvod.utils.QRCode;
|
||||||
import com.github.catvod.utils.Trans;
|
import com.github.catvod.utils.Trans;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
|
@ -33,6 +30,9 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
@ -42,6 +42,7 @@ import java.util.regex.Pattern;
|
||||||
public class Ali {
|
public class Ali {
|
||||||
|
|
||||||
private final Pattern pattern = Pattern.compile("www.aliyundrive.com/s/([^/]+)(/folder/([^/]+))?");
|
private final Pattern pattern = Pattern.compile("www.aliyundrive.com/s/([^/]+)(/folder/([^/]+))?");
|
||||||
|
private ScheduledExecutorService service;
|
||||||
private static String accessToken;
|
private static String accessToken;
|
||||||
private String refreshToken;
|
private String refreshToken;
|
||||||
private ImageView code;
|
private ImageView code;
|
||||||
|
|
@ -90,7 +91,7 @@ public class Ali {
|
||||||
String fileId = ids[2];
|
String fileId = ids[2];
|
||||||
String sub = getSub(shareId, shareToken, ids);
|
String sub = getSub(shareId, shareToken, ids);
|
||||||
refreshAccessToken();
|
refreshAccessToken();
|
||||||
if (TextUtils.isEmpty(accessToken)) return "";
|
while (TextUtils.isEmpty(accessToken)) SystemClock.sleep(250);
|
||||||
if (flag.equals("原畫")) {
|
if (flag.equals("原畫")) {
|
||||||
return Result.get().url(getDownloadUrl(shareId, shareToken, fileId)).sub(sub).header(getHeaders()).string();
|
return Result.get().url(getDownloadUrl(shareId, shareToken, fileId)).sub(sub).header(getHeaders()).string();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -278,42 +279,37 @@ public class Ali {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getToken() {
|
public void getToken() {
|
||||||
Misc.loadWebView("https://easy-token.cooluc.com/", new WebViewClient() {
|
if (service != null) service.shutdownNow();
|
||||||
@Override
|
Code code = Code.objectFrom(OkHttpUtil.string("https://easy-token.cooluc.com/qr"));
|
||||||
public void onLoadResource(WebView view, String url) {
|
Init.run(() -> showQRCode(code.getData().getCodeContent()));
|
||||||
if (url.endsWith("/ck")) {
|
service = Executors.newScheduledThreadPool(2);
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(() -> view.evaluateJavascript("document.getElementsByTagName('input')[0].value", value -> saveToken(value)), 1000);
|
service.scheduleAtFixedRate(() -> {
|
||||||
} else if (url.endsWith("/qr")) {
|
JsonObject params = new JsonObject();
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(() -> view.evaluateJavascript("document.getElementsByTagName('img')[0].src", value -> showQRCode(value)), 3000);
|
params.addProperty("t", code.getData().getT());
|
||||||
}
|
params.addProperty("ck", code.getData().getCk());
|
||||||
}
|
Code result = Code.objectFrom(OkHttpUtil.postJson("https://easy-token.cooluc.com/ck", params.toString()));
|
||||||
});
|
if (result.hasToken()) saveToken(result.getResult().getRefreshToken());
|
||||||
|
}, 1, 1, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveToken(String value) {
|
private void saveToken(String value) {
|
||||||
if (value.length() == 2) return;
|
Prefers.put("token", refreshToken = value);
|
||||||
Prefers.put("token", refreshToken = value.replace("\"", ""));
|
Init.run(() -> code.setVisibility(View.GONE));
|
||||||
Init.show("請重新進入播放頁");
|
service.shutdownNow();
|
||||||
code.setVisibility(View.GONE);
|
|
||||||
Misc.removeView(code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showQRCode(String value) {
|
private void showQRCode(String text) {
|
||||||
if (!value.contains("base64,")) return;
|
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||||
byte[] bytes = Base64.decode(value.split("base64,")[1], Base64.DEFAULT);
|
|
||||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(Misc.dp2px(250), Misc.dp2px(250));
|
|
||||||
params.gravity = Gravity.CENTER;
|
params.gravity = Gravity.CENTER;
|
||||||
Misc.addView(code = create(bytes), params);
|
Misc.addView(code = create(text), params);
|
||||||
Init.show("請使用阿里雲盤 App 掃描二維碼");
|
Init.show("請使用阿里雲盤 App 掃描二維碼");
|
||||||
}
|
}
|
||||||
|
|
||||||
private ImageView create(byte[] bytes) {
|
private ImageView create(String value) {
|
||||||
ImageView view = new ImageView(Init.context());
|
ImageView view = new ImageView(Init.context());
|
||||||
view.setBackgroundColor(Color.WHITE);
|
|
||||||
view.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
view.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||||
view.setPadding(Misc.dp2px(20), Misc.dp2px(20), Misc.dp2px(20), Misc.dp2px(20));
|
view.setImageBitmap(QRCode.getBitmap(value, 250, 2));
|
||||||
view.setImageBitmap(BitmapFactory.decodeByteArray(bytes, 0, bytes.length));
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.github.catvod.utils;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
|
||||||
|
import com.google.zxing.BarcodeFormat;
|
||||||
|
import com.google.zxing.EncodeHintType;
|
||||||
|
import com.google.zxing.MultiFormatWriter;
|
||||||
|
import com.google.zxing.common.BitMatrix;
|
||||||
|
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class QRCode {
|
||||||
|
|
||||||
|
private static final int WHITE = 0xFFFFFFFF;
|
||||||
|
private static final int BLACK = 0xFF000000;
|
||||||
|
|
||||||
|
public static Bitmap createBitmap(BitMatrix matrix) {
|
||||||
|
int width = matrix.getWidth();
|
||||||
|
int height = matrix.getHeight();
|
||||||
|
int[] pixels = new int[width * height];
|
||||||
|
for (int y = 0; y < height; y++) {
|
||||||
|
int offset = y * width;
|
||||||
|
for (int x = 0; x < width; x++) {
|
||||||
|
pixels[offset + x] = matrix.get(x, y) ? BLACK : WHITE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||||
|
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Bitmap getBitmap(String contents, int size, int margin) {
|
||||||
|
try {
|
||||||
|
Map<EncodeHintType, Object> hints = new EnumMap<>(EncodeHintType.class);
|
||||||
|
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
|
||||||
|
hints.put(EncodeHintType.MARGIN, margin);
|
||||||
|
return createBitmap(new MultiFormatWriter().encode(contents, BarcodeFormat.QR_CODE, Misc.dp2px(size), Misc.dp2px(size), hints));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
6aa710655b59e0b3f88a283a3c4668ec
|
7071a7598ea9bffccc4fc76684f9b529
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue