Compare commits

...

1 Commits

Author SHA1 Message Date
q
c9fa83e57c Fixed 蓝奏云目录解析cookie验证问题 2026-02-03 13:26:40 +08:00

View File

@@ -294,9 +294,24 @@ public class LzTool extends PanBase {
String sUrl = shareLinkInfo.getShareUrl(); String sUrl = shareLinkInfo.getShareUrl();
String pwd = shareLinkInfo.getSharePassword(); String pwd = shareLinkInfo.getSharePassword();
WebClient client = clientNoRedirects; webClientSession.getAbs(sUrl).send().onSuccess(res -> {
client.getAbs(sUrl).send().onSuccess(res -> {
String html = res.bodyAsString(); String html = res.bodyAsString();
// 检查是否需要 cookie 验证
if (html.contains("var arg1='")) {
webClientSession = WebClientSession.create(clientNoRedirects);
setCookie(html);
// 重新请求
webClientSession.getAbs(sUrl).send().onSuccess(res2 -> {
handleFileListParse(res2.bodyAsString(), pwd, sUrl, promise);
}).onFailure(err -> promise.fail(err));
return;
}
handleFileListParse(html, pwd, sUrl, promise);
}).onFailure(err -> promise.fail(err));
return promise.future();
}
private void handleFileListParse(String html, String pwd, String sUrl, Promise<List<FileInfo>> promise) {
try { try {
String jsText = getJsByPwd(pwd, html, "var urls =window.location.href"); String jsText = getJsByPwd(pwd, html, "var urls =window.location.href");
ScriptObjectMirror scriptObjectMirror = JsExecUtils.executeDynamicJs(jsText, "file"); ScriptObjectMirror scriptObjectMirror = JsExecUtils.executeDynamicJs(jsText, "file");
@@ -307,8 +322,27 @@ public class LzTool extends PanBase {
MultiMap headers = getHeaders(sUrl); MultiMap headers = getHeaders(sUrl);
String url = SHARE_URL_PREFIX + "/filemoreajax.php?file=" + data.get("fid"); String url = SHARE_URL_PREFIX + "/filemoreajax.php?file=" + data.get("fid");
client.postAbs(url).putHeaders(headers).sendForm(map).onSuccess(res2 -> { webClientSession.postAbs(url).putHeaders(headers).sendForm(map).onSuccess(res2 -> {
JsonObject fileListJson = asJson(res2); String resBody = asText(res2);
// 再次检查是否需要 cookie 验证
if (resBody.contains("var arg1='")) {
setCookie(resBody);
// 重新请求
webClientSession.postAbs(url).putHeaders(headers).sendForm(map).onSuccess(res3 -> {
handleFileListResponse(asText(res3), promise);
}).onFailure(err -> promise.fail(err));
return;
}
handleFileListResponse(resBody, promise);
}).onFailure(err -> promise.fail(err));
} catch (ScriptException | NoSuchMethodException e) {
promise.fail(e);
}
}
private void handleFileListResponse(String responseBody, Promise<List<FileInfo>> promise) {
try {
JsonObject fileListJson = new JsonObject(responseBody);
if (fileListJson.getInteger("zt") != 1) { if (fileListJson.getInteger("zt") != 1) {
promise.fail(baseMsg() + fileListJson.getString("info")); promise.fail(baseMsg() + fileListJson.getString("info"));
return; return;
@@ -347,12 +381,9 @@ public class LzTool extends PanBase {
list.add(fileInfo); list.add(fileInfo);
}); });
promise.complete(list); promise.complete(list);
}); } catch (Exception e) {
} catch (ScriptException | NoSuchMethodException e) {
promise.fail(e); promise.fail(e);
} }
});
return promise.future();
} }
void setFileInfo(String html, ShareLinkInfo shareLinkInfo) { void setFileInfo(String html, ShareLinkInfo shareLinkInfo) {