mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2025-12-16 04:13:03 +00:00
目录解析支持优化 v0.1.9b2
This commit is contained in:
@@ -116,12 +116,21 @@ public abstract class PanBase implements IPanTool {
|
||||
*/
|
||||
protected void fail(Throwable t, String errorMsg, Object... args) {
|
||||
try {
|
||||
// 判断是否已经完成
|
||||
if (promise.future().isComplete()) {
|
||||
log.warn("Promise 已经完成, 无法再次失败: {}, {}", errorMsg, promise.future().cause());
|
||||
return;
|
||||
}
|
||||
String s = String.format(errorMsg.replaceAll("\\{}", "%s"), args);
|
||||
log.error("解析异常: " + s, t.fillInStackTrace());
|
||||
promise.fail(baseMsg() + ": 解析异常: " + s + " -> " + t);
|
||||
} catch (Exception e) {
|
||||
log.error("ErrorMsg format fail. The parameter has been discarded", e);
|
||||
log.error("解析异常: " + errorMsg, t.fillInStackTrace());
|
||||
if (promise.future().isComplete()) {
|
||||
log.warn("ErrorMsg format. Promise 已经完成, 无法再次失败: {}", errorMsg);
|
||||
return;
|
||||
}
|
||||
promise.fail(baseMsg() + ": 解析异常: " + errorMsg + " -> " + t);
|
||||
}
|
||||
}
|
||||
@@ -134,9 +143,18 @@ public abstract class PanBase implements IPanTool {
|
||||
*/
|
||||
protected void fail(String errorMsg, Object... args) {
|
||||
try {
|
||||
// 判断是否已经完成
|
||||
if (promise.future().isComplete()) {
|
||||
log.warn("Promise 已经完成, 无法再次失败: {}, {}", errorMsg, promise.future().cause());
|
||||
return;
|
||||
}
|
||||
String s = String.format(errorMsg.replaceAll("\\{}", "%s"), args);
|
||||
promise.fail(baseMsg() + " - 解析异常: " + s);
|
||||
} catch (Exception e) {
|
||||
if (promise.future().isComplete()) {
|
||||
log.warn("ErrorMsg format. Promise 已经完成, 无法再次失败: {}", errorMsg);
|
||||
return;
|
||||
}
|
||||
log.error("ErrorMsg format fail. The parameter has been discarded", e);
|
||||
promise.fail(baseMsg() + " - 解析异常: " + errorMsg);
|
||||
}
|
||||
|
||||
@@ -115,9 +115,17 @@ public class FjTool extends PanBase {
|
||||
fail(FIRST_REQUEST_URL + " 解析文件列表为空: " + resJson);
|
||||
return;
|
||||
}
|
||||
if (!resJson.containsKey("list") || resJson.getJsonArray("list").isEmpty()) {
|
||||
fail(FIRST_REQUEST_URL + " 解析文件列表为空: " + resJson);
|
||||
return;
|
||||
}
|
||||
// 文件Id
|
||||
JsonObject fileInfo = resJson.getJsonArray("list").getJsonObject(0);
|
||||
// 如果是目录返回目录ID
|
||||
if (!fileInfo.containsKey("fileList") || fileInfo.getJsonArray("fileList").isEmpty()) {
|
||||
fail(FIRST_REQUEST_URL + " 文件列表为空: " + fileInfo);
|
||||
return;
|
||||
}
|
||||
JsonObject fileList = fileInfo.getJsonArray("fileList").getJsonObject(0);
|
||||
if (fileList.getInteger("fileType") == 2) {
|
||||
promise.complete(fileList.getInteger("folderId").toString());
|
||||
@@ -172,6 +180,9 @@ public class FjTool extends PanBase {
|
||||
}
|
||||
parse().onSuccess(id -> {
|
||||
parserDir(id, shareId, promise);
|
||||
}).onFailure(failRes -> {
|
||||
log.error("解析目录失败: {}", failRes.getMessage());
|
||||
promise.fail(failRes);
|
||||
});
|
||||
return promise.future();
|
||||
}
|
||||
|
||||
@@ -101,9 +101,17 @@ public class IzTool extends PanBase {
|
||||
fail(FIRST_REQUEST_URL + " 解析文件列表为空: " + resJson);
|
||||
return;
|
||||
}
|
||||
if (!resJson.containsKey("list") || resJson.getJsonArray("list").isEmpty()) {
|
||||
fail(FIRST_REQUEST_URL + " 解析文件列表为空: " + resJson);
|
||||
return;
|
||||
}
|
||||
// 文件Id
|
||||
JsonObject fileInfo = resJson.getJsonArray("list").getJsonObject(0);
|
||||
// 如果是目录返回目录ID
|
||||
if (!fileInfo.containsKey("fileList") || fileInfo.getJsonArray("fileList").isEmpty()) {
|
||||
fail(FIRST_REQUEST_URL + " 文件列表为空: " + fileInfo);
|
||||
return;
|
||||
}
|
||||
JsonObject fileList = fileInfo.getJsonArray("fileList").getJsonObject(0);
|
||||
if (fileList.getInteger("fileType") == 2) {
|
||||
promise.complete(fileList.getInteger("folderId").toString());
|
||||
@@ -151,6 +159,9 @@ public class IzTool extends PanBase {
|
||||
}
|
||||
parse().onSuccess(id -> {
|
||||
parserDir(id, shareId, promise);
|
||||
}).onFailure(failRes -> {
|
||||
log.error("解析目录失败: {}", failRes.getMessage());
|
||||
promise.fail(failRes);
|
||||
});
|
||||
return promise.future();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<img :height="150" src="../public/images/lanzou111.png" alt="lz"></img>
|
||||
</div>
|
||||
</div>
|
||||
<h3 style="text-align: center;">NFD网盘直链解析0.1.9_bate1</h3>
|
||||
<h3 style="text-align: center;">NFD网盘直链解析0.1.9_bate2</h3>
|
||||
<div class="typo">
|
||||
<p style="text-align: center;">
|
||||
<span>
|
||||
@@ -296,10 +296,27 @@ export default {
|
||||
})
|
||||
const data = response.data.data
|
||||
const panList = ["iz", "lz", "fj"];
|
||||
const listUrl = `${window.location.origin}/list.html?url=${encodeURIComponent(this.link)}&pwd=${this.password}`
|
||||
if (panList.includes(data.shareLinkInfo.type)) {
|
||||
window.open(listUrl, '_blank');
|
||||
|
||||
if (!panList.includes(data.shareLinkInfo.type)) {
|
||||
this.$message.error("当前网盘不支持目录解析")
|
||||
}
|
||||
let listUrl = `${window.location.origin}/list.html?url=${encodeURIComponent(this.link)}`
|
||||
let apiUrl = new URL(data.apiLink).origin + `/v2/getFileList?url=${this.link}`;
|
||||
// 动态添加密码参数
|
||||
if (this.password) {
|
||||
listUrl += `&pwd=${this.password}`;
|
||||
apiUrl += `&pwd=${this.password}`;
|
||||
}
|
||||
this.$alert(
|
||||
`目录解析API: <a href="${apiUrl}" target="_blank">${apiUrl}</a><br>打开文件列表: <a href="${listUrl}" target="_blank">点击这里</a>`,
|
||||
'目录解析信息',
|
||||
{
|
||||
dangerouslyUseHTMLString: true,
|
||||
confirmButtonText: '确定',
|
||||
type: 'info'
|
||||
}
|
||||
);
|
||||
|
||||
} else {
|
||||
this.$message.error(response.data.msg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user