修改123网盘解析规则

This commit is contained in:
QAIU
2023-07-22 12:34:02 +08:00
parent e2273587a0
commit dbef574cbc
5 changed files with 108 additions and 18 deletions

View File

@@ -1,6 +1,7 @@
package cn.qaiu.lz.common.parser.impl;
import cn.qaiu.lz.common.parser.IPanTool;
import cn.qaiu.lz.common.util.AESUtils;
import cn.qaiu.lz.common.util.CommonUtils;
import cn.qaiu.lz.common.util.PanExceptionUtils;
import cn.qaiu.vx.core.util.VertxHolder;
@@ -29,6 +30,8 @@ public class YeTool implements IPanTool {
"=file_name&orderDirection=asc&shareKey={shareKey}&SharePwd={pwd}&ParentFileId=0&Page=1&event" +
"=homeListFile&operateType=1";
private static final String DOWNLOAD_API_URL = "https://www.123pan.com/b/api/share/download/info?auth-key={authKey}";
public Future<String> parse(String data, String code) {
String dataKey = CommonUtils.adaptShortPaths(SHARE_URL_PREFIX, data);
@@ -88,10 +91,15 @@ public class YeTool implements IPanTool {
private static void getDownUrl(Promise<String> promise, WebClient client, JsonObject reqBodyJson) {
log.info(reqBodyJson.encodePrettily());
client.postAbs("https://www.123pan.com/a/api/share/download/info").sendJsonObject(reqBodyJson).onSuccess(res2 -> {
client.postAbs(UriTemplate.of(DOWNLOAD_API_URL))
.setTemplateParam("authKey", AESUtils.getAuthKey())
.putHeader("Platform", "web")
.putHeader("App-Version", "3")
.sendJsonObject(reqBodyJson).onSuccess(res2 -> {
JsonObject downURLJson = res2.bodyAsJsonObject();
System.out.println(downURLJson);
if (downURLJson.getInteger("code") != 0) {
promise.fail("Ye: downURLJson返回值异常->" + downURLJson);
return;
}
String downURL = downURLJson.getJsonObject("data").getString("DownloadURL");
@@ -99,7 +107,20 @@ public class YeTool implements IPanTool {
Map<String, String> urlParams = CommonUtils.getURLParams(downURL);
String params = urlParams.get("params");
byte[] decodeByte = Base64.getDecoder().decode(params);
promise.complete(new String(decodeByte));
String downUrl2 = new String(decodeByte);
// 获取直链
client.getAbs(downUrl2).send().onSuccess(res3 -> {
JsonObject res3Json = res3.bodyAsJsonObject();
if (res3Json.getInteger("code") != 0) {
promise.fail("Ye: downUrl2返回值异常->" + res3Json);
return;
}
promise.complete(res3Json.getJsonObject("data").getString("redirect_url"));
}).onFailure(t -> promise.fail(PanExceptionUtils.fillRunTimeException("Ye",
reqBodyJson.encodePrettily(), t)));
} catch (MalformedURLException e) {
promise.fail("urlParams解析异常" + e.getMessage());
}

View File

@@ -4,11 +4,14 @@ import org.apache.commons.lang3.StringUtils;
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import java.util.Date;
import java.util.HexFormat;
import java.util.Random;
@@ -257,5 +260,31 @@ public class AESUtils {
}
//=============================== 123pan加密相关 ===============================
public static String getMD5Str(String str) {
byte[] digest;
try {
MessageDigest md5 = MessageDigest.getInstance("md5");
digest = md5.digest(str.getBytes(StandardCharsets.UTF_8));
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
//16是表示转换为16进制数
return new BigInteger(1, digest).toString(16);
}
public static String getAuthKey() {
String _0x2207af = "/b/api/share/download/info";
String _0x467baa = "web";
int _0x4965f1 = 3;
String _0x430930 = String.valueOf(Math.round(0x989680 * Math.random()));
String _0x53928f = String.valueOf(new Date().getTime() / 0x3e8);
String _0x49ec94 = getMD5Str(_0x53928f + "|" + _0x430930 + "|" + _0x2207af + "|" + _0x467baa + "|" + _0x4965f1
+ "|8-8D$sL8gPjom7bk#cY");
return _0x53928f + "-" + _0x430930 + "-" + _0x49ec94;
}
}

View File

@@ -82,3 +82,26 @@ Content-Type:application/json;charset=UTF-8
},
"publicPath": "https://www.123pan.com/a/api/"
}
###
https://www.123pan.com/b/api/share/get?limit=100&next=1&orderBy=file_name&orderDirection=asc&shareKey=iaKtVv-6OECd&SharePwd=DcGe&ParentFileId=0&Page=1&event=homeListFile&operateType=1&auth-key=1689990170-3703305-62c1030a465013b7c18eddb49156b67b
# 23/07/22 123pan添加header
###
POST https://www.123pan.com/b/api/share/download/info?auth-key=1689996626-2926572-49f4cde9a911469869ee264cb6ae8426
App-Version:3
Platform:web
{"ShareKey":"iaKtVv-6OECd","FileID":2193732,"S3keyFlag":"1811834632-0","Size":4203111,"Etag":"69c94adbc0b9190cf23c4e958d8c7c53"}
###
https://www.123pan.com/a/api/share/get?limit=100&next=1&orderBy=file_name&orderDirection=asc&shareKey=iaKtVv-6OECd&SharePwd=DcGe&ParentFileId=0&Page=1&event=homeListFile&operateType=1

View File

@@ -76,12 +76,14 @@ GET http://127.0.0.1:6400/fc/e5079007dc31226096628870c7@QAIU
#https://v2.fangcloud.com/sharing/e5079007dc31226096628870c7
# https://www.123pan.com/s/iaKtVv-ICECd.html
### 123
GET http://127.0.0.1:6400/json/ye/iaKtVv-qOECd
GET http://127.0.0.1:6400/json/ye/iaKtVv-ICECd
### 123
# @no-redirect
GET http://127.0.0.1:6400/ye/iaKtVv-qOECd@asdads
GET http://127.0.0.1:6400/ye/iaKtVv-qOECd
### 123
# @no-redirect

View File

@@ -62,4 +62,19 @@ public class TestAESUtil {
System.out.println(AESUtils.getRandomString());
System.out.println(AESUtils.getRandomString());
}
@Test
public void testKeyAuth(){
System.out.println(AESUtils.getAuthKey());
System.out.println(AESUtils.getAuthKey());
System.out.println(AESUtils.getAuthKey());
}
@Test
public void testAES2() throws NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException,
BadPaddingException, InvalidKeyException {
System.out.println(AESUtils.encryptBase64ByAES("AAAAA", "123123"));
System.out.println(AESUtils.encryptBase64ByAES("AAAAA", AESUtils.generateKey("123123")));
}
}