mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2025-12-16 20:33:03 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b67544f0cd | ||
|
|
ef5826a73b | ||
|
|
a48adbd0df |
@@ -69,71 +69,38 @@ public class YeTool extends PanBase {
|
||||
final String dataKey = shareLinkInfo.getShareKey();
|
||||
final String pwd = shareLinkInfo.getSharePassword();
|
||||
|
||||
client.getAbs(UriTemplate.of(FIRST_REQUEST_URL)).setTemplateParam("key", dataKey).send().onSuccess(res -> {
|
||||
client.getAbs(UriTemplate.of(GET_FILE_INFO_URL))
|
||||
.setTemplateParam("shareKey", dataKey)
|
||||
.setTemplateParam("pwd", pwd)
|
||||
.setTemplateParam("ParentFileId", "0")
|
||||
// .setTemplateParam("authKey", AESUtils.getAuthKey("/a/api/share/get"))
|
||||
.putHeader("Platform", "web")
|
||||
.putHeader("App-Version", "3")
|
||||
.send().onSuccess(res2 -> {
|
||||
JsonObject infoJson = asJson(res2);
|
||||
if (infoJson.getInteger("code") != 0) {
|
||||
fail("{} 状态码异常 {}", dataKey, infoJson);
|
||||
return;
|
||||
}
|
||||
|
||||
String html = res.bodyAsString();
|
||||
// 分享页面是否存在判断\"UserID\"
|
||||
if (!html.contains("\\\"UserID\\\"")) {
|
||||
fail("该分享({})不存在, 可能分享已失效", shareLinkInfo.getShareUrl());
|
||||
return;
|
||||
}
|
||||
JsonObject getFileInfoJson =
|
||||
infoJson.getJsonObject("data").getJsonArray("InfoList").getJsonObject(0);
|
||||
getFileInfoJson.put("ShareKey", dataKey);
|
||||
|
||||
String fileInfoString = parserHtml(html);
|
||||
|
||||
String shareKey = shareLinkInfo.getShareKey().replaceAll("(\\..*)|(#.*)", "");
|
||||
|
||||
if (fileInfoString == null) {
|
||||
// 加密分享
|
||||
if (StringUtils.isNotEmpty(pwd)) {
|
||||
client.getAbs(UriTemplate.of(GET_FILE_INFO_URL))
|
||||
.setTemplateParam("shareKey", shareKey)
|
||||
.setTemplateParam("pwd", pwd)
|
||||
.setTemplateParam("ParentFileId", "0")
|
||||
// .setTemplateParam("authKey", AESUtils.getAuthKey("/a/api/share/get"))
|
||||
.putHeader("Platform", "web")
|
||||
.putHeader("App-Version", "3")
|
||||
.send().onSuccess(res2 -> {
|
||||
JsonObject infoJson = asJson(res2);
|
||||
if (infoJson.getInteger("code") != 0) {
|
||||
fail("{} 状态码异常 {}", dataKey, infoJson);
|
||||
return;
|
||||
}
|
||||
|
||||
JsonObject getFileInfoJson =
|
||||
infoJson.getJsonObject("data").getJsonArray("InfoList").getJsonObject(0);
|
||||
getFileInfoJson.put("ShareKey", shareKey);
|
||||
|
||||
// 判断是否为文件夹: data->InfoList->0->Type: 1为文件夹, 0为文件
|
||||
try {
|
||||
int type = (Integer)JsonPointer.from("/data/InfoList/0/Type").queryJson(infoJson);
|
||||
if (type == 1) {
|
||||
getZipDownUrl(client, getFileInfoJson);
|
||||
return;
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
fail("该分享[{}]解析异常: {}", dataKey, exception.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
getDownUrl(client, getFileInfoJson);
|
||||
}).onFailure(this.handleFail(GET_FILE_INFO_URL));
|
||||
} else {
|
||||
fail("该分享[{}]需要密码",dataKey);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
JsonObject fileInfoJson = new JsonObject(fileInfoString);
|
||||
JsonObject reqBodyJson = fileInfoJson;
|
||||
reqBodyJson.put("ShareKey", shareKey);
|
||||
if (reqBodyJson.getInteger("Type") == 1) {
|
||||
// 文件夹
|
||||
getZipDownUrl(client, reqBodyJson);
|
||||
return;
|
||||
}
|
||||
getDownUrl(client, reqBodyJson);
|
||||
}).onFailure(this.handleFail(FIRST_REQUEST_URL));
|
||||
// 判断是否为文件夹: data->InfoList->0->Type: 1为文件夹, 0为文件
|
||||
try {
|
||||
int type = (Integer)JsonPointer.from("/data/InfoList/0/Type").queryJson(infoJson);
|
||||
if (type == 1) {
|
||||
getZipDownUrl(client, getFileInfoJson);
|
||||
return;
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
fail("该分享[{}]解析异常: {}", dataKey, exception.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
getDownUrl(client, getFileInfoJson);
|
||||
}).onFailure(this.handleFail(GET_FILE_INFO_URL));
|
||||
return promise.future();
|
||||
}
|
||||
|
||||
@@ -337,15 +304,4 @@ public class YeTool extends PanBase {
|
||||
down(client, paramJson, DOWNLOAD_API_URL);
|
||||
return promise.future();
|
||||
}
|
||||
|
||||
String parserHtml(String html) {
|
||||
// 正则匹配 { ... } 中包含 S3KeyFlag 的对象
|
||||
Pattern pattern = Pattern.compile("\\{[^{}]*?S3KeyFlag[^{}]*?\\}");
|
||||
Matcher matcher = pattern.matcher(html);
|
||||
|
||||
if (matcher.find()) {
|
||||
return matcher.group().replace("\\", "");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.3.1",
|
||||
"@vueuse/core": "^11.2.0",
|
||||
"axios": "1.11.0",
|
||||
"axios": "1.12.0",
|
||||
"clipboard": "^2.0.11",
|
||||
"core-js": "^3.8.3",
|
||||
"element-plus": "^2.8.7",
|
||||
|
||||
Reference in New Issue
Block a user