mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-10-16 19:48:34 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfa6453ee8 |
@@ -18,8 +18,6 @@ QQ交流群:1017480890
|
|||||||

|

|
||||||
|
|
||||||
|
|
||||||
> 本平台所有音乐解析工具不再维护,请移步[Sonder播放器](https://sodecode.qaiu.top)
|
|
||||||
> 需要百度,迅雷,UC,夸克的完整支持请使用[专业版](https://189.qaiu.top)
|
|
||||||
|
|
||||||
## 介绍
|
## 介绍
|
||||||
> netdisk-fast-download网盘直链解析可以把云盘分享链接转为直链,可广泛应用于各类下载站,资源站,个人博客,图床,APP下载更新,视频点播等领域。支持市面各大主流云盘的文件分享以及文件夹分享链接,已支持蓝奏云/蓝奏云优享/移动云云空间/小飞机盘/亿方云/123云盘/永硕E盘/Cloudreve等,支持加密分享,以及部分网盘文件夹分享。
|
> netdisk-fast-download网盘直链解析可以把云盘分享链接转为直链,可广泛应用于各类下载站,资源站,个人博客,图床,APP下载更新,视频点播等领域。支持市面各大主流云盘的文件分享以及文件夹分享链接,已支持蓝奏云/蓝奏云优享/移动云云空间/小飞机盘/亿方云/123云盘/永硕E盘/Cloudreve等,支持加密分享,以及部分网盘文件夹分享。
|
||||||
@@ -238,8 +236,6 @@ auths:
|
|||||||
```
|
```
|
||||||
|
|
||||||
> ⚠️ 注意:YAML 中 key 后面不写值(如 `authorization:` 空着)等同于没配置,不会生效,必须填入真实的账号密码或 token 内容。
|
> ⚠️ 注意:YAML 中 key 后面不写值(如 `authorization:` 空着)等同于没配置,不会生效,必须填入真实的账号密码或 token 内容。
|
||||||
>
|
|
||||||
> 若 123 云盘账号密码登录触发验证码或风控,解析会直接失败并提示改用 Authorization,不会尝试验证码。请改填上面的 `authorization` / `token`(浏览器 localStorage 的 `authorToken`,或请求头 `authorization` / Cookie `sso-token` 里的 JWT)。
|
|
||||||
|
|
||||||
如果只是临时调用一次,不想改动服务端配置,也可以用上面提到的 `auth` 参数临时传递(`authType` 可选 `password`/`accesstoken`/`authorization`),无需重启服务,仅本次请求生效。
|
如果只是临时调用一次,不想改动服务端配置,也可以用上面提到的 `auth` 参数临时传递(`authType` 可选 `password`/`accesstoken`/`authorization`),无需重启服务,仅本次请求生效。
|
||||||
|
|
||||||
@@ -463,7 +459,7 @@ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtow
|
|||||||
> 注意: netdisk-fast-download.service中的ExecStart的路径改为实际路径
|
> 注意: netdisk-fast-download.service中的ExecStart的路径改为实际路径
|
||||||
```shell
|
```shell
|
||||||
cd ~
|
cd ~
|
||||||
wget -O netdisk-fast-download.zip https://github.com/qaiu/netdisk-fast-download/releases/download/v0.4.7/netdisk-fast-download-linux-amd64.zip
|
wget -O netdisk-fast-download.zip https://github.com/qaiu/netdisk-fast-download/releases/download/v0.4.6/netdisk-fast-download-linux-amd64.zip
|
||||||
unzip netdisk-fast-download.zip
|
unzip netdisk-fast-download.zip
|
||||||
cd netdisk-fast-download
|
cd netdisk-fast-download
|
||||||
bash service-install.sh
|
bash service-install.sh
|
||||||
|
|||||||
@@ -109,8 +109,6 @@ URL解码 → Base64解码 → AES解密 → JSON对象
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
> 123云盘(`ye`)账号密码登录如果返回验证码或风控,解析会直接失败,并提示改用 Authorization,不会尝试验证码。请在浏览器登录后复制 `authorToken` / 请求头 `authorization` / Cookie `sso-token`,用 `authType=authorization` 或 `accesstoken` 传入,或写入 `app-dev.yml` 的 `auths.ye.authorization`。
|
|
||||||
|
|
||||||
#### 4. 自定义认证
|
#### 4. 自定义认证
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -341,4 +339,3 @@ server:
|
|||||||
## 更新日志
|
## 更新日志
|
||||||
|
|
||||||
- **2026-02-05**: 初始版本,支持 accesstoken、cookie、password、custom 认证类型
|
- **2026-02-05**: 初始版本,支持 accesstoken、cookie、password、custom 认证类型
|
||||||
- **2026-09-27**: 补充 123云盘账号密码登录触发验证码/风控时改用 Authorization 的说明
|
|
||||||
|
|||||||
@@ -57,8 +57,6 @@
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
> 123云盘(`ye`)账号密码登录触发验证码/风控时,请改用 `authType=authorization` 或 `accesstoken`(`token` 填浏览器中的 Bearer token / JWT),或在 `app-dev.yml` 配置 `auths.ye.authorization`。解析不会尝试验证码。
|
|
||||||
|
|
||||||
### 自定义认证
|
### 自定义认证
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,270 +0,0 @@
|
|||||||
package cn.qaiu.parser;
|
|
||||||
|
|
||||||
import io.vertx.core.json.JsonArray;
|
|
||||||
import io.vertx.core.json.JsonObject;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 账号密码登录撞上验证码/风控时的用户提示。
|
|
||||||
* 只识别失败形态并引导改用 Authorization,不实现验证码求解、扫码或重试。
|
|
||||||
*/
|
|
||||||
public final class PasswordLoginRisk {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 123 云盘(ye)账号密码登录被验证码/风控拦住时返回给调用方的固定说明。
|
|
||||||
* 上游 code/message 会另附在这句话后面,便于和“密码错误”区分。
|
|
||||||
*/
|
|
||||||
public static final String AUTHORIZATION_HINT =
|
|
||||||
"账号密码登录触发了验证码/风控,已停止用户名密码登录(不会尝试验证码)。"
|
|
||||||
+ "请改为配置 Authorization(浏览器登录后的 Bearer token / JWT,"
|
|
||||||
+ "例如 localStorage 的 authorToken、请求头 authorization 或 Cookie 的 sso-token)。"
|
|
||||||
+ "静态配置写在 app-dev.yml 的 auths.ye.authorization(与 auths.ye.token 等价);"
|
|
||||||
+ "临时请求使用 authType=authorization 或 authType=accesstoken,token 填该令牌(不要重复带 Bearer 前缀)。"
|
|
||||||
+ "说明见 parser/doc/auth-param/。";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上游文案命中这些片段时视为验证码/风控,而不是单纯的密码错误。
|
|
||||||
* 依据公开客户端(AList/OpenList)实际展示过的 123 登录失败文案,以及登录页上的滑块/人机验证提示。
|
|
||||||
*/
|
|
||||||
private static final String[] RISK_KEYWORDS = {
|
|
||||||
"验证码",
|
|
||||||
"风控",
|
|
||||||
"安全风险",
|
|
||||||
"安全验证",
|
|
||||||
"安全校验",
|
|
||||||
"滑块",
|
|
||||||
"滑动验证",
|
|
||||||
"拼图验证",
|
|
||||||
"短信验证",
|
|
||||||
"微信登录",
|
|
||||||
"微信进行登录",
|
|
||||||
"境外登录",
|
|
||||||
"需要验证",
|
|
||||||
"请验证",
|
|
||||||
"请你验证",
|
|
||||||
"进行验证",
|
|
||||||
"完成验证",
|
|
||||||
"二次验证",
|
|
||||||
"人机验证",
|
|
||||||
"操作频繁",
|
|
||||||
"请求过于频繁",
|
|
||||||
"请求频繁",
|
|
||||||
"captcha",
|
|
||||||
"recaptcha",
|
|
||||||
"risk control"
|
|
||||||
};
|
|
||||||
|
|
||||||
private PasswordLoginRisk() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isLoginSuccess(JsonObject json) {
|
|
||||||
if (json == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Integer code = readCode(json);
|
|
||||||
return code != null && code == 200 && StringUtils.isNotBlank(readToken(json));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean indicatesCaptchaOrRisk(JsonObject json) {
|
|
||||||
if (json == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (hasTruthyRiskField(json) || hasTruthyRiskField(dataObject(json))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return textIndicatesCaptchaOrRisk(collectMessageText(json));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean textIndicatesCaptchaOrRisk(String text) {
|
|
||||||
if (StringUtils.isBlank(text)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String lower = text.toLowerCase(Locale.ROOT);
|
|
||||||
for (String keyword : RISK_KEYWORDS) {
|
|
||||||
if (lower.contains(keyword.toLowerCase(Locale.ROOT))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 非成功登录响应的用户可见说明。验证码/风控走 Authorization 引导,其余保持“登录失败: 上游文案”。
|
|
||||||
*/
|
|
||||||
public static String describeLoginFailure(JsonObject json) {
|
|
||||||
if (json == null) {
|
|
||||||
return "登录响应格式异常";
|
|
||||||
}
|
|
||||||
if (indicatesCaptchaOrRisk(json)) {
|
|
||||||
return AUTHORIZATION_HINT + " 上游返回:" + upstreamSummary(json);
|
|
||||||
}
|
|
||||||
Integer code = readCode(json);
|
|
||||||
if (code != null && code == 200) {
|
|
||||||
return "未获取到token";
|
|
||||||
}
|
|
||||||
String message = firstMessage(json);
|
|
||||||
if (StringUtils.isBlank(message)) {
|
|
||||||
return "登录失败";
|
|
||||||
}
|
|
||||||
return "登录失败: " + message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String nonJsonLoginFailure(String body) {
|
|
||||||
if (textIndicatesCaptchaOrRisk(body)) {
|
|
||||||
return AUTHORIZATION_HINT + " 上游返回:" + truncate(body, 300);
|
|
||||||
}
|
|
||||||
return "登录响应格式异常: " + body;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String collectMessageText(JsonObject json) {
|
|
||||||
StringBuilder text = new StringBuilder();
|
|
||||||
appendMessage(text, json);
|
|
||||||
JsonObject data = dataObject(json);
|
|
||||||
if (data != null) {
|
|
||||||
appendMessage(text, data);
|
|
||||||
}
|
|
||||||
return text.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void appendMessage(StringBuilder text, JsonObject json) {
|
|
||||||
append(text, json.getString("message"));
|
|
||||||
append(text, json.getString("msg"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void append(StringBuilder text, String value) {
|
|
||||||
if (StringUtils.isNotBlank(value)) {
|
|
||||||
if (text.length() > 0) {
|
|
||||||
text.append(' ');
|
|
||||||
}
|
|
||||||
text.append(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean hasTruthyRiskField(JsonObject obj) {
|
|
||||||
if (obj == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (String key : obj.fieldNames()) {
|
|
||||||
if (!isRiskFieldName(key)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (isTruthyRiskValue(obj.getValue(key))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isRiskFieldName(String key) {
|
|
||||||
String lower = key.toLowerCase(Locale.ROOT);
|
|
||||||
return lower.contains("captcha")
|
|
||||||
|| lower.contains("vcode")
|
|
||||||
|| lower.contains("risk")
|
|
||||||
|| "needverify".equals(lower)
|
|
||||||
|| "need_verify".equals(lower)
|
|
||||||
|| "slideverify".equals(lower)
|
|
||||||
|| "verifycode".equals(lower)
|
|
||||||
|| "verify_code".equals(lower);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isTruthyRiskValue(Object value) {
|
|
||||||
if (value == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (value instanceof Boolean) {
|
|
||||||
return (Boolean) value;
|
|
||||||
}
|
|
||||||
if (value instanceof Number) {
|
|
||||||
return ((Number) value).doubleValue() != 0d;
|
|
||||||
}
|
|
||||||
if (value instanceof CharSequence) {
|
|
||||||
String text = value.toString().trim();
|
|
||||||
if (text.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String lower = text.toLowerCase(Locale.ROOT);
|
|
||||||
return !"false".equals(lower) && !"0".equals(lower) && !"null".equals(lower) && !"none".equals(lower);
|
|
||||||
}
|
|
||||||
if (value instanceof JsonObject) {
|
|
||||||
return !((JsonObject) value).isEmpty();
|
|
||||||
}
|
|
||||||
if (value instanceof JsonArray) {
|
|
||||||
return !((JsonArray) value).isEmpty();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String upstreamSummary(JsonObject json) {
|
|
||||||
StringBuilder summary = new StringBuilder();
|
|
||||||
Integer code = readCode(json);
|
|
||||||
if (code != null) {
|
|
||||||
summary.append("code=").append(code);
|
|
||||||
}
|
|
||||||
String message = firstMessage(json);
|
|
||||||
if (StringUtils.isNotBlank(message)) {
|
|
||||||
if (summary.length() > 0) {
|
|
||||||
summary.append(", ");
|
|
||||||
}
|
|
||||||
summary.append("message=").append(message);
|
|
||||||
}
|
|
||||||
if (summary.length() == 0) {
|
|
||||||
summary.append(json.encode());
|
|
||||||
}
|
|
||||||
return truncate(summary.toString(), 300);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String firstMessage(JsonObject json) {
|
|
||||||
String message = json.getString("message");
|
|
||||||
if (StringUtils.isBlank(message)) {
|
|
||||||
message = json.getString("msg");
|
|
||||||
}
|
|
||||||
if (StringUtils.isBlank(message)) {
|
|
||||||
JsonObject data = dataObject(json);
|
|
||||||
if (data != null) {
|
|
||||||
message = data.getString("message");
|
|
||||||
if (StringUtils.isBlank(message)) {
|
|
||||||
message = data.getString("msg");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
static String readToken(JsonObject json) {
|
|
||||||
JsonObject data = dataObject(json);
|
|
||||||
if (data == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Object token = data.getValue("token");
|
|
||||||
return token == null ? null : token.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static JsonObject dataObject(JsonObject json) {
|
|
||||||
Object data = json.getValue("data");
|
|
||||||
return data instanceof JsonObject ? (JsonObject) data : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Integer readCode(JsonObject json) {
|
|
||||||
Object code = json.getValue("code");
|
|
||||||
if (code instanceof Number) {
|
|
||||||
return ((Number) code).intValue();
|
|
||||||
}
|
|
||||||
if (code instanceof String && StringUtils.isNumeric(((String) code).trim())) {
|
|
||||||
return Integer.parseInt(((String) code).trim());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String truncate(String value, int max) {
|
|
||||||
if (value == null) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
String trimmed = value.trim();
|
|
||||||
if (trimmed.length() <= max) {
|
|
||||||
return trimmed;
|
|
||||||
}
|
|
||||||
return trimmed.substring(0, max) + "...";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,6 @@ import cn.qaiu.parser.PanBase;
|
|||||||
import cn.qaiu.util.*;
|
import cn.qaiu.util.*;
|
||||||
import io.netty.handler.codec.http.cookie.DefaultCookie;
|
import io.netty.handler.codec.http.cookie.DefaultCookie;
|
||||||
import io.vertx.core.Future;
|
import io.vertx.core.Future;
|
||||||
import io.vertx.core.Handler;
|
|
||||||
import io.vertx.core.MultiMap;
|
import io.vertx.core.MultiMap;
|
||||||
import io.vertx.core.Promise;
|
import io.vertx.core.Promise;
|
||||||
import io.vertx.core.buffer.Buffer;
|
import io.vertx.core.buffer.Buffer;
|
||||||
@@ -42,37 +41,9 @@ public class LzTool extends PanBase {
|
|||||||
|
|
||||||
private final WebClientSession webClientSession;
|
private final WebClientSession webClientSession;
|
||||||
|
|
||||||
/**
|
/** 实测服务器出口 IP 上 wwww.lanzoux.com 可用,且个性域名目录内文件 ID 也能打开。 */
|
||||||
* 没有原始分享页主机时才使用(目录内文件 ID、shareKey 占位)。
|
public static final String SHARE_URL_PREFIX = "https://wwww.lanzoux.com/";
|
||||||
* 与 PanDomainTemplate.LZ 标准模板一致:{@code https://w1.lanzn.com/{shareKey}}。
|
private static final String SHARE_ORIGIN = "https://wwww.lanzoux.com";
|
||||||
* 已有分享页不要改写到 wwww.lanzoux.com,部分出口连四个 w 的域名会超时。
|
|
||||||
*/
|
|
||||||
public static final String SHARE_URL_PREFIX = "https://w1.lanzn.com/";
|
|
||||||
/** 页面 URL 解析失败时的源站兜底,与 {@link #SHARE_URL_PREFIX} 同主机。 */
|
|
||||||
private static final String SHARE_ORIGIN = "https://w1.lanzn.com";
|
|
||||||
/**
|
|
||||||
* 目录 filemoreajax.php 换域顺序。个性域名上会立刻返回「已超时」。
|
|
||||||
* wwww 只放最后,避免单一主机超时直接失败。
|
|
||||||
* 文件 ajax 走 {@link #FILE_AJAX_FALLBACK_ORIGINS},不要把 apifile 混进目录列表。
|
|
||||||
*/
|
|
||||||
static final List<String> AJAX_FALLBACK_ORIGINS = List.of(
|
|
||||||
"https://w1.lanzn.com",
|
|
||||||
"https://www.lanzoux.com",
|
|
||||||
"https://wwww.lanzoux.com"
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* 文件页 iframe / 密码页里的 ajaxfile.php 经常是绝对地址
|
|
||||||
* {@code https://apifile.lanzouw.com/ajaxfile.php?file=…}。
|
|
||||||
* 相对路径打到页面源站或 w1/www 会空响应。apifile 放在文件 ajax 兜底的最前,
|
|
||||||
* 页面源站空响应后立刻换过去,不在四 w 上耗光超时。
|
|
||||||
*/
|
|
||||||
static final String APIFILE_ORIGIN = "https://apifile.lanzouw.com";
|
|
||||||
static final List<String> FILE_AJAX_FALLBACK_ORIGINS = List.of(
|
|
||||||
APIFILE_ORIGIN,
|
|
||||||
"https://w1.lanzn.com",
|
|
||||||
"https://www.lanzoux.com",
|
|
||||||
"https://wwww.lanzoux.com"
|
|
||||||
);
|
|
||||||
/** 分享页 / ajax 请求超时 */
|
/** 分享页 / ajax 请求超时 */
|
||||||
private static final long REQUEST_TIMEOUT = 8000;
|
private static final long REQUEST_TIMEOUT = 8000;
|
||||||
/** 下载域跳转与二次验证超时,链路更长 */
|
/** 下载域跳转与二次验证超时,链路更长 */
|
||||||
@@ -83,10 +54,6 @@ public class LzTool extends PanBase {
|
|||||||
private static final Pattern P_AJAXDATA = Pattern.compile("ajaxdata\\s*=\\s*'([^']+)'");
|
private static final Pattern P_AJAXDATA = Pattern.compile("ajaxdata\\s*=\\s*'([^']+)'");
|
||||||
private static final Pattern P_WEBSIGN = Pattern.compile("'websign'\\s*:\\s*'([^']*)'");
|
private static final Pattern P_WEBSIGN = Pattern.compile("'websign'\\s*:\\s*'([^']*)'");
|
||||||
private static final Pattern P_WEBPAGE = Pattern.compile("[?&]webpage=([^&\"'\\s#]+)");
|
private static final Pattern P_WEBPAGE = Pattern.compile("[?&]webpage=([^&\"'\\s#]+)");
|
||||||
/** 页面脚本里的绝对 ajax,例如 https://apifile.lanzouw.com/ajaxfile.php?file=123 */
|
|
||||||
private static final Pattern P_AJAX_ABSOLUTE = Pattern.compile(
|
|
||||||
"['\"]((?:https?:)?//[^'\"\\s<>]+/ajax(?:m|file)\\.php\\?file=\\d+)['\"]",
|
|
||||||
Pattern.CASE_INSENSITIVE);
|
|
||||||
private static final Pattern P_AJAX_PATH = Pattern.compile("(?:['\"/]|^)(ajax(?:m|file)\\.php\\?file=\\d+)");
|
private static final Pattern P_AJAX_PATH = Pattern.compile("(?:['\"/]|^)(ajax(?:m|file)\\.php\\?file=\\d+)");
|
||||||
private static final Pattern P_SIGN = Pattern.compile("'sign'\\s*:\\s*'([^']+)'");
|
private static final Pattern P_SIGN = Pattern.compile("'sign'\\s*:\\s*'([^']+)'");
|
||||||
private static final Pattern P_ISNGIS = Pattern.compile("var\\s+isngis\\s*=\\s*'([^']+)'");
|
private static final Pattern P_ISNGIS = Pattern.compile("var\\s+isngis\\s*=\\s*'([^']+)'");
|
||||||
@@ -292,17 +259,18 @@ public class LzTool extends PanBase {
|
|||||||
return path.isEmpty() || "-".equals(path);
|
return path.isEmpty() || "-".equals(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 统一改写到 {@link #SHARE_URL_PREFIX},只保留分享路径。 */
|
||||||
* 分享页 / 目录页 GET 保留原始主机和路径。
|
private String resolveShareUrl() {
|
||||||
* 只有分享路径缺失(空链接、shareKey 占位)时才落到 {@link #SHARE_URL_PREFIX}。
|
String u = shareLinkInfo.getShareUrl();
|
||||||
*/
|
|
||||||
static String resolveSharePageUrl(String shareUrl, String standardUrl, String shareKey) {
|
|
||||||
String u = shareUrl;
|
|
||||||
if (isPlaceholderShare(u)) {
|
if (isPlaceholderShare(u)) {
|
||||||
u = standardUrl;
|
u = shareLinkInfo.getStandardUrl();
|
||||||
}
|
}
|
||||||
if (isPlaceholderShare(u)) {
|
if (isPlaceholderShare(u)) {
|
||||||
return canonicalShareUrl(shareKey, null);
|
String key = shareLinkInfo.getShareKey();
|
||||||
|
if (key == null || key.isBlank() || "-".equals(key)) {
|
||||||
|
return SHARE_URL_PREFIX;
|
||||||
|
}
|
||||||
|
return SHARE_URL_PREFIX + key;
|
||||||
}
|
}
|
||||||
int q = u.indexOf('?');
|
int q = u.indexOf('?');
|
||||||
String query = null;
|
String query = null;
|
||||||
@@ -316,167 +284,10 @@ public class LzTool extends PanBase {
|
|||||||
}
|
}
|
||||||
int pathStart = u.indexOf('/', schemeEnd + 3);
|
int pathStart = u.indexOf('/', schemeEnd + 3);
|
||||||
if (pathStart < 0) {
|
if (pathStart < 0) {
|
||||||
String base = u.endsWith("/") ? u : u + "/";
|
String key = shareLinkInfo.getShareKey();
|
||||||
if (shareKey == null || shareKey.isBlank() || "-".equals(shareKey)) {
|
return appendWebpage(SHARE_URL_PREFIX + (key == null ? "" : key), query);
|
||||||
return appendWebpage(base, query);
|
|
||||||
}
|
|
||||||
return appendWebpage(base + shareKey, query);
|
|
||||||
}
|
}
|
||||||
return appendWebpage(u, query);
|
return appendWebpage(SHARE_ORIGIN + u.substring(pathStart), query);
|
||||||
}
|
|
||||||
|
|
||||||
private String resolveShareUrl() {
|
|
||||||
return resolveSharePageUrl(
|
|
||||||
shareLinkInfo.getShareUrl(),
|
|
||||||
shareLinkInfo.getStandardUrl(),
|
|
||||||
shareLinkInfo.getShareKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 无原始主机时用标准下载域拼分享路径,不再写死 wwww.lanzoux.com。 */
|
|
||||||
private static String canonicalShareUrl(String shareKey, String query) {
|
|
||||||
if (shareKey == null || shareKey.isBlank() || "-".equals(shareKey)) {
|
|
||||||
return appendWebpage(SHARE_URL_PREFIX, query);
|
|
||||||
}
|
|
||||||
return appendWebpage(SHARE_URL_PREFIX + shareKey, query);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 目录内文件页主机:沿用已有分享主机,否则用 {@link #SHARE_URL_PREFIX}。
|
|
||||||
*/
|
|
||||||
static String sharePageHostBase(String shareUrl, String standardUrl) {
|
|
||||||
String u = !isPlaceholderShare(shareUrl) ? shareUrl : standardUrl;
|
|
||||||
if (!isPlaceholderShare(u)) {
|
|
||||||
String origin = normalizeOrigin(originOf(u, SHARE_ORIGIN));
|
|
||||||
return origin + "/";
|
|
||||||
}
|
|
||||||
return SHARE_URL_PREFIX;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 目录 filemore 的 POST 主机顺序:分享页源站优先(普通节点通常可用),
|
|
||||||
* 然后是稳定下载域。wwww.lanzoux.com 固定排在最后。
|
|
||||||
*/
|
|
||||||
static List<String> ajaxOrigins(String pageUrl) {
|
|
||||||
List<String> origins = new ArrayList<>();
|
|
||||||
addAjaxOrigin(origins, normalizeOrigin(originOf(pageUrl, "")));
|
|
||||||
for (String candidate : AJAX_FALLBACK_ORIGINS) {
|
|
||||||
addAjaxOrigin(origins, candidate);
|
|
||||||
}
|
|
||||||
return origins;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件 ajax 主机顺序。页面里若写出绝对 ajax URL,该主机最先尝试;
|
|
||||||
* 否则先打页面源站。空响应后再试 {@link #APIFILE_ORIGIN},四 w 仍在最后。
|
|
||||||
*
|
|
||||||
* @param ajaxTarget {@link #fileAjaxTarget} 的返回值,绝对 URL 或相对路径;可为 null
|
|
||||||
*/
|
|
||||||
static List<String> fileAjaxOrigins(String pageUrl, String ajaxTarget) {
|
|
||||||
List<String> origins = new ArrayList<>();
|
|
||||||
addAjaxOrigin(origins, originFromAjaxTarget(ajaxTarget));
|
|
||||||
addAjaxOrigin(origins, normalizeOrigin(originOf(pageUrl, "")));
|
|
||||||
for (String candidate : FILE_AJAX_FALLBACK_ORIGINS) {
|
|
||||||
addAjaxOrigin(origins, candidate);
|
|
||||||
}
|
|
||||||
return origins;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从分享页或 iframe HTML 取出文件 ajax 地址。
|
|
||||||
* 绝对 URL(含协议相对 {@code //host/...})原样返回;否则返回以 {@code /} 开头的相对路径。
|
|
||||||
*/
|
|
||||||
static String fileAjaxTarget(String html) {
|
|
||||||
if (html == null || html.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Matcher abs = P_AJAX_ABSOLUTE.matcher(html);
|
|
||||||
if (abs.find()) {
|
|
||||||
String url = abs.group(1);
|
|
||||||
if (url.startsWith("//")) {
|
|
||||||
url = "https:" + url;
|
|
||||||
}
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
Matcher ajax = P_AJAX_PATH.matcher(html);
|
|
||||||
if (!ajax.find()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return "/" + ajax.group(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addAjaxOrigin(List<String> origins, String origin) {
|
|
||||||
if (origin != null && origin.contains("://") && !origins.contains(origin)) {
|
|
||||||
origins.add(origin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String originFromAjaxTarget(String ajaxTarget) {
|
|
||||||
if (ajaxTarget == null) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
if (ajaxTarget.startsWith("http://") || ajaxTarget.startsWith("https://")) {
|
|
||||||
return normalizeOrigin(originOf(ajaxTarget, ""));
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String normalizeOrigin(String origin) {
|
|
||||||
if (origin == null) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
String o = origin.trim();
|
|
||||||
while (o.endsWith("/")) {
|
|
||||||
o = o.substring(0, o.length() - 1);
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 个性域名常见 {@code inf=已超时},或响应根本不是 JSON。这类结果说明当前主机不可用,应换下一个域名。
|
|
||||||
* 密码错误、分享失效等业务错误不换域名。
|
|
||||||
*/
|
|
||||||
static boolean ajaxResponseShouldFallback(String text) {
|
|
||||||
if (text == null || text.isBlank()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
JsonObject json = parseLzJson(text);
|
|
||||||
if (json == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer zt = jsonInt(json, "zt");
|
|
||||||
if (zt != null && zt == 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String info = ajaxInfoText(json);
|
|
||||||
return info != null && info.contains("超时");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Integer jsonInt(JsonObject json, String key) {
|
|
||||||
Object v = json.getValue(key);
|
|
||||||
if (v instanceof Number n) {
|
|
||||||
return n.intValue();
|
|
||||||
}
|
|
||||||
if (v instanceof CharSequence) {
|
|
||||||
try {
|
|
||||||
return Integer.parseInt(v.toString().trim());
|
|
||||||
} catch (NumberFormatException ignored) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String ajaxInfoText(JsonObject json) {
|
|
||||||
for (String key : new String[]{"inf", "info"}) {
|
|
||||||
Object v = json.getValue(key);
|
|
||||||
if (v instanceof CharSequence) {
|
|
||||||
String s = v.toString().trim();
|
|
||||||
if (!s.isEmpty() && !"null".equalsIgnoreCase(s)) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 目录文件 ID 可能带 webpage=,必须保留;pwd 走独立字段,不拼进 URL。 */
|
/** 目录文件 ID 可能带 webpage=,必须保留;pwd 走独立字段,不拼进 URL。 */
|
||||||
@@ -600,12 +411,8 @@ public class LzTool extends PanBase {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 页面里提取出的 ajax 调用。absoluteUrl 非空时优先打该主机。 */
|
/** 页面里提取出的 ajax 调用:相对路径 + 表单参数。 */
|
||||||
private record AjaxCall(String path, Map<String, String> form, String absoluteUrl) {
|
private record AjaxCall(String path, Map<String, String> form) {
|
||||||
private AjaxCall(String path, Map<String, String> form) {
|
|
||||||
this(path, form, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
MultiMap toForm() {
|
MultiMap toForm() {
|
||||||
MultiMap m = MultiMap.caseInsensitiveMultiMap();
|
MultiMap m = MultiMap.caseInsensitiveMultiMap();
|
||||||
form.forEach(m::set);
|
form.forEach(m::set);
|
||||||
@@ -617,12 +424,11 @@ public class LzTool extends PanBase {
|
|||||||
if (html == null || html.isEmpty()) {
|
if (html == null || html.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String target = fileAjaxTarget(html);
|
Matcher ajax = P_AJAX_PATH.matcher(html);
|
||||||
if (target == null) {
|
if (!ajax.find()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String absolute = target.startsWith("http://") || target.startsWith("https://") ? target : null;
|
String ajaxPath = ajax.group(1);
|
||||||
String ajaxPath = absolute == null ? target : pathOfAbsolute(absolute);
|
|
||||||
Map<String, String> data = new LinkedHashMap<>();
|
Map<String, String> data = new LinkedHashMap<>();
|
||||||
data.put("action", "downprocess");
|
data.put("action", "downprocess");
|
||||||
Matcher wp = P_WP_SIGN.matcher(html);
|
Matcher wp = P_WP_SIGN.matcher(html);
|
||||||
@@ -676,23 +482,7 @@ public class LzTool extends PanBase {
|
|||||||
data.put("signs", ad2.group(1));
|
data.put("signs", ad2.group(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new AjaxCall(ajaxPath, data, absolute);
|
return new AjaxCall("/" + ajaxPath, data);
|
||||||
}
|
|
||||||
|
|
||||||
private static String pathOfAbsolute(String url) {
|
|
||||||
try {
|
|
||||||
URL u = new URL(url);
|
|
||||||
String path = u.getPath() == null ? "" : u.getPath();
|
|
||||||
if (u.getQuery() != null && !u.getQuery().isEmpty()) {
|
|
||||||
path = path + "?" + u.getQuery();
|
|
||||||
}
|
|
||||||
if (!path.startsWith("/")) {
|
|
||||||
path = "/" + path;
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AjaxCall extractFolderAjax(String html, String pwd) {
|
private static AjaxCall extractFolderAjax(String html, String pwd) {
|
||||||
@@ -786,58 +576,12 @@ public class LzTool extends PanBase {
|
|||||||
|
|
||||||
private void getDownURL(String referer, AjaxCall call) {
|
private void getDownURL(String referer, AjaxCall call) {
|
||||||
MultiMap headers = HeaderUtils.parseHeaders(DOWN_AJAX_HEADERS);
|
MultiMap headers = HeaderUtils.parseHeaders(DOWN_AJAX_HEADERS);
|
||||||
// 文件 ajax 优先用页面里的绝对地址(常见 apifile.lanzouw.com)。
|
// 个性域名 ajaxfile.php 会立刻 inf=已超时;POST 必须打 wwww。iframe 请求 Referer 用 iframe 地址。
|
||||||
// 页面源站空响应再换 FILE_AJAX_FALLBACK_ORIGINS,wwww 仍在最后。
|
headers.set("referer", referer != null && !referer.isBlank() ? referer : resolveShareUrl());
|
||||||
// iframe / 分享页的 Referer 保持原主机,不把页面 GET 改写到 wwww。
|
String url = joinUrl(SHARE_ORIGIN + "/", call.path());
|
||||||
String page = referer != null && !referer.isBlank() ? referer : resolveShareUrl();
|
|
||||||
headers.set("referer", page);
|
|
||||||
String target = call.absoluteUrl() != null ? call.absoluteUrl() : call.path();
|
|
||||||
postAjaxAt(fileAjaxOrigins(page, target), 0, call, headers, this::handleAjaxDownResponse, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 依次向 {@link #ajaxOrigins} 发 POST。连接失败或「已超时」换下一个主机;
|
|
||||||
* wwww.lanzoux.com 只在最后尝试。业务错误(密码、失效)立即返回。
|
|
||||||
*/
|
|
||||||
private void postAjaxWithFallback(String pageUrl, AjaxCall call, MultiMap headers,
|
|
||||||
Handler<String> onBody, Handler<Throwable> onFailure) {
|
|
||||||
postAjaxAt(ajaxOrigins(pageUrl), 0, call, headers, onBody, onFailure);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void postAjaxAt(List<String> origins, int index, AjaxCall call, MultiMap headers,
|
|
||||||
Handler<String> onBody, Handler<Throwable> onFailure) {
|
|
||||||
if (index >= origins.size()) {
|
|
||||||
String msg = "蓝奏 ajax 全部域名均失败";
|
|
||||||
if (onFailure != null) {
|
|
||||||
onFailure.handle(new RuntimeException(msg));
|
|
||||||
} else {
|
|
||||||
fail(msg);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String url = joinUrl(origins.get(index) + "/", call.path());
|
|
||||||
boolean hasNext = index + 1 < origins.size();
|
|
||||||
postFormWithArg1Retry(url, headers, call.toForm())
|
postFormWithArg1Retry(url, headers, call.toForm())
|
||||||
.onSuccess(text -> {
|
.onSuccess(this::handleAjaxDownResponse)
|
||||||
if (hasNext && ajaxResponseShouldFallback(text)) {
|
.onFailure(handleFail(url));
|
||||||
log.warn("蓝奏 ajax {} 不可用,改试下一域名", url);
|
|
||||||
postAjaxAt(origins, index + 1, call, headers, onBody, onFailure);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
onBody.handle(text);
|
|
||||||
})
|
|
||||||
.onFailure(err -> {
|
|
||||||
if (hasNext) {
|
|
||||||
log.warn("蓝奏 ajax {} 请求失败: {},改试下一域名", url, err.getMessage());
|
|
||||||
postAjaxAt(origins, index + 1, call, headers, onBody, onFailure);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (onFailure != null) {
|
|
||||||
onFailure.handle(err);
|
|
||||||
} else {
|
|
||||||
handleFail(url).handle(err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleAjaxDownResponse(String text) {
|
private void handleAjaxDownResponse(String text) {
|
||||||
@@ -1169,9 +913,10 @@ public class LzTool extends PanBase {
|
|||||||
}
|
}
|
||||||
log.debug("解析参数: {}", call.form());
|
log.debug("解析参数: {}", call.form());
|
||||||
|
|
||||||
postAjaxWithFallback(sUrl, call, folderListHeaders(sUrl),
|
String url = joinUrl(originOf(sUrl, SHARE_ORIGIN) + "/", call.path());
|
||||||
body -> handleFileListResponse(body, listPromise),
|
postFormWithArg1Retry(url, folderListHeaders(sUrl), call.toForm())
|
||||||
listPromise::fail);
|
.onSuccess(body -> handleFileListResponse(body, listPromise))
|
||||||
|
.onFailure(listPromise::fail);
|
||||||
} catch (ScriptException | NoSuchMethodException | RuntimeException e) {
|
} catch (ScriptException | NoSuchMethodException | RuntimeException e) {
|
||||||
listPromise.fail(e);
|
listPromise.fail(e);
|
||||||
}
|
}
|
||||||
@@ -1324,7 +1069,7 @@ public class LzTool extends PanBase {
|
|||||||
if (webpage == null || webpage.isBlank()) {
|
if (webpage == null || webpage.isBlank()) {
|
||||||
webpage = extractWebpage(shareLinkInfo.getShareUrl(), null);
|
webpage = extractWebpage(shareLinkInfo.getShareUrl(), null);
|
||||||
}
|
}
|
||||||
String fileUrl = sharePageHostBase(shareLinkInfo.getShareUrl(), shareLinkInfo.getStandardUrl()) + id;
|
String fileUrl = SHARE_URL_PREFIX + id;
|
||||||
if (webpage != null && !webpage.isBlank()) {
|
if (webpage != null && !webpage.isBlank()) {
|
||||||
fileUrl = fileUrl + "?webpage=" + webpage;
|
fileUrl = fileUrl + "?webpage=" + webpage;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package cn.qaiu.parser.impl;
|
|||||||
import cn.qaiu.entity.FileInfo;
|
import cn.qaiu.entity.FileInfo;
|
||||||
import cn.qaiu.entity.ShareLinkInfo;
|
import cn.qaiu.entity.ShareLinkInfo;
|
||||||
import cn.qaiu.parser.PanBase;
|
import cn.qaiu.parser.PanBase;
|
||||||
import cn.qaiu.parser.PasswordLoginRisk;
|
|
||||||
import cn.qaiu.parser.TokenCache;
|
import cn.qaiu.parser.TokenCache;
|
||||||
import cn.qaiu.util.CommonUtils;
|
import cn.qaiu.util.CommonUtils;
|
||||||
import cn.qaiu.util.FileSizeConverter;
|
import cn.qaiu.util.FileSizeConverter;
|
||||||
@@ -273,27 +272,24 @@ public class Ye2Tool extends PanBase {
|
|||||||
.putHeader("platform", "web")
|
.putHeader("platform", "web")
|
||||||
.sendJsonObject(loginBody)
|
.sendJsonObject(loginBody)
|
||||||
.onSuccess(res -> {
|
.onSuccess(res -> {
|
||||||
JsonObject json;
|
JsonObject json = res.bodyAsJsonObject();
|
||||||
try {
|
|
||||||
json = res.bodyAsJsonObject();
|
|
||||||
} catch (Exception e) {
|
|
||||||
promise.fail(PasswordLoginRisk.nonJsonLoginFailure(res.bodyAsString()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (json == null) {
|
if (json == null) {
|
||||||
promise.fail(PasswordLoginRisk.nonJsonLoginFailure(res.bodyAsString()));
|
promise.fail("登录响应格式异常: " + res.bodyAsString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!json.containsKey("code")) {
|
if (!json.containsKey("code")) {
|
||||||
promise.fail("登录响应格式异常: " + res.bodyAsString());
|
promise.fail("登录响应格式异常: " + res.bodyAsString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 验证码/风控只提示改用 Authorization,不求解、不重试。
|
if (json.getInteger("code") != 200) {
|
||||||
if (!PasswordLoginRisk.isLoginSuccess(json)) {
|
promise.fail("登录失败: " + json.getString("message"));
|
||||||
promise.fail(PasswordLoginRisk.describeLoginFailure(json));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JsonObject data = json.getJsonObject("data");
|
JsonObject data = json.getJsonObject("data");
|
||||||
|
if (data == null || !data.containsKey("token")) {
|
||||||
|
promise.fail("未获取到token");
|
||||||
|
return;
|
||||||
|
}
|
||||||
String ssoToken = data.getString("token");
|
String ssoToken = data.getString("token");
|
||||||
String expireStr = data.getString("expire");
|
String expireStr = data.getString("expire");
|
||||||
long expireMs;
|
long expireMs;
|
||||||
|
|||||||
@@ -55,50 +55,8 @@ def encode123(url, way, version, timestamp):
|
|||||||
# 返回加密后的URL参数
|
# 返回加密后的URL参数
|
||||||
return f"?{y}={time_long}-{a}-{final_crc}"
|
return f"?{y}={time_long}-{a}-{final_crc}"
|
||||||
|
|
||||||
# 与 parser PasswordLoginRisk 保持一致:验证码/风控只提示改用 Authorization,不求解、不重试。
|
|
||||||
_RISK_KEYWORDS = (
|
|
||||||
"验证码", "风控", "安全风险", "安全验证", "安全校验", "滑块", "滑动验证",
|
|
||||||
"拼图验证", "短信验证", "微信登录", "微信进行登录", "境外登录", "需要验证", "请验证",
|
|
||||||
"请你验证", "进行验证", "完成验证", "二次验证", "人机验证", "操作频繁", "请求过于频繁",
|
|
||||||
"请求频繁", "captcha", "recaptcha", "risk control",
|
|
||||||
)
|
|
||||||
_AUTH_HINT = (
|
|
||||||
"账号密码登录触发了验证码/风控,已停止用户名密码登录(不会尝试验证码)。"
|
|
||||||
"请改为配置 Authorization(浏览器登录后的 Bearer token / JWT,"
|
|
||||||
"例如 localStorage 的 authorToken、请求头 authorization 或 Cookie 的 sso-token)。"
|
|
||||||
"静态配置写在 app-dev.yml 的 auths.ye.authorization(与 auths.ye.token 等价);"
|
|
||||||
"临时请求使用 authType=authorization 或 authType=accesstoken,token 填该令牌(不要重复带 Bearer 前缀)。"
|
|
||||||
"说明见 parser/doc/auth-param/。"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def format_login_failure(result):
|
|
||||||
"""把 123 登录失败响应转成用户可见说明。"""
|
|
||||||
if not isinstance(result, dict):
|
|
||||||
return "登录失败"
|
|
||||||
message = result.get("message") or result.get("msg") or ""
|
|
||||||
data = result.get("data") if isinstance(result.get("data"), dict) else {}
|
|
||||||
data_message = data.get("message") or data.get("msg") or ""
|
|
||||||
blob = f"{message} {data_message}".lower()
|
|
||||||
risk_field = any(
|
|
||||||
key.lower().find(flag) >= 0 and data.get(key) not in (None, False, 0, "", "false", "0")
|
|
||||||
for key in data
|
|
||||||
for flag in ("captcha", "vcode", "risk", "needverify", "need_verify", "slideverify", "verifycode", "verify_code")
|
|
||||||
)
|
|
||||||
if risk_field or any(keyword.lower() in blob for keyword in _RISK_KEYWORDS):
|
|
||||||
code = result.get("code")
|
|
||||||
upstream = message or data_message
|
|
||||||
extra = f"code={code}" if code is not None else ""
|
|
||||||
if upstream:
|
|
||||||
extra = f"{extra}, message={upstream}" if extra else f"message={upstream}"
|
|
||||||
return f"{_AUTH_HINT} 上游返回:{extra}" if extra else _AUTH_HINT
|
|
||||||
if result.get("code") == 200:
|
|
||||||
return "未获取到token"
|
|
||||||
return f"登录失败: {message}" if message else "登录失败"
|
|
||||||
|
|
||||||
|
|
||||||
def login_123pan(username, password):
|
def login_123pan(username, password):
|
||||||
"""登录123盘获取token。成功返回 token,失败返回 None(错误已打印)。"""
|
"""登录123盘获取token"""
|
||||||
print(f"🔐 正在登录账号: {username}")
|
print(f"🔐 正在登录账号: {username}")
|
||||||
|
|
||||||
login_data = {
|
login_data = {
|
||||||
@@ -115,18 +73,16 @@ def login_123pan(username, password):
|
|||||||
)
|
)
|
||||||
result = response.json()
|
result = response.json()
|
||||||
|
|
||||||
if result.get('code') == 200 and result.get('data', {}).get('token'):
|
if result.get('code') == 200:
|
||||||
token = result.get('data', {}).get('token', '')
|
token = result.get('data', {}).get('token', '')
|
||||||
print(f"✅ 登录成功!")
|
print(f"✅ 登录成功!")
|
||||||
return token
|
return token
|
||||||
else:
|
else:
|
||||||
error_msg = format_login_failure(result)
|
error_msg = result.get('message', '未知错误')
|
||||||
login_123pan.last_error = error_msg
|
print(f"❌ 登录失败: {error_msg}")
|
||||||
print(f"❌ {error_msg}")
|
|
||||||
return None
|
return None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
login_123pan.last_error = f"登录请求失败: {e}"
|
print(f"❌ 登录请求失败: {e}")
|
||||||
print(f"❌ {login_123pan.last_error}")
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_share_info(share_key, password=''):
|
def get_share_info(share_key, password=''):
|
||||||
@@ -233,7 +189,7 @@ def start(link, password='', username='', user_password=''):
|
|||||||
if not token:
|
if not token:
|
||||||
return {
|
return {
|
||||||
"code": 201,
|
"code": 201,
|
||||||
"message": getattr(login_123pan, "last_error", None) or "登录失败"
|
"message": "登录失败"
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
print("⚠️ 未提供登录信息,某些文件可能无法下载")
|
print("⚠️ 未提供登录信息,某些文件可能无法下载")
|
||||||
|
|||||||
@@ -1,115 +0,0 @@
|
|||||||
package cn.qaiu.parser;
|
|
||||||
|
|
||||||
import io.vertx.core.json.JsonObject;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class PasswordLoginRiskTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void securityRiskMessageGuidesAuthorization() {
|
|
||||||
JsonObject body = new JsonObject()
|
|
||||||
.put("code", 401)
|
|
||||||
.put("message", "当前账号存在安全风险,请使用短信验证码或者微信进行登录。");
|
|
||||||
|
|
||||||
assertTrue(PasswordLoginRisk.indicatesCaptchaOrRisk(body));
|
|
||||||
String message = PasswordLoginRisk.describeLoginFailure(body);
|
|
||||||
assertTrue(message.startsWith(PasswordLoginRisk.AUTHORIZATION_HINT));
|
|
||||||
assertTrue(message.contains("验证码/风控"));
|
|
||||||
assertTrue(message.contains("auths.ye.authorization"));
|
|
||||||
assertTrue(message.contains("authType=authorization"));
|
|
||||||
assertTrue(message.contains("authType=accesstoken"));
|
|
||||||
assertTrue(message.contains("code=401"));
|
|
||||||
assertTrue(message.contains("当前账号存在安全风险"));
|
|
||||||
assertFalse(message.startsWith("登录失败:"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void overseasRiskAndCaptchaPhrasesMatch() {
|
|
||||||
assertRisk("当前账号存在境外登录风险,请使用短信验证码或者微信进行登录。");
|
|
||||||
assertRisk("请完成安全验证");
|
|
||||||
assertRisk("请进行滑块验证");
|
|
||||||
assertRisk("操作频繁,请稍后再试");
|
|
||||||
assertRisk("captcha required");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void wrongPasswordStaysDistinct() {
|
|
||||||
JsonObject body = new JsonObject()
|
|
||||||
.put("code", 500)
|
|
||||||
.put("message", "用户名或密码错误");
|
|
||||||
|
|
||||||
assertFalse(PasswordLoginRisk.indicatesCaptchaOrRisk(body));
|
|
||||||
assertEquals("登录失败: 用户名或密码错误", PasswordLoginRisk.describeLoginFailure(body));
|
|
||||||
|
|
||||||
JsonObject account = new JsonObject().put("code", 1).put("msg", "账号或密码错误");
|
|
||||||
assertFalse(PasswordLoginRisk.indicatesCaptchaOrRisk(account));
|
|
||||||
assertEquals("登录失败: 账号或密码错误", PasswordLoginRisk.describeLoginFailure(account));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void riskFieldWithoutKeywordStillHints() {
|
|
||||||
JsonObject body = new JsonObject()
|
|
||||||
.put("code", 200)
|
|
||||||
.put("message", "ok")
|
|
||||||
.put("data", new JsonObject().put("needCaptcha", true));
|
|
||||||
|
|
||||||
assertFalse(PasswordLoginRisk.isLoginSuccess(body));
|
|
||||||
assertTrue(PasswordLoginRisk.indicatesCaptchaOrRisk(body));
|
|
||||||
assertTrue(PasswordLoginRisk.describeLoginFailure(body).contains("Authorization"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void falseCaptchaFlagDoesNotHint() {
|
|
||||||
JsonObject body = new JsonObject()
|
|
||||||
.put("code", 500)
|
|
||||||
.put("message", "用户名或密码错误")
|
|
||||||
.put("data", new JsonObject().put("needCaptcha", false));
|
|
||||||
|
|
||||||
assertFalse(PasswordLoginRisk.indicatesCaptchaOrRisk(body));
|
|
||||||
assertEquals("登录失败: 用户名或密码错误", PasswordLoginRisk.describeLoginFailure(body));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void successTokenIsNotTreatedAsFailure() {
|
|
||||||
JsonObject body = new JsonObject()
|
|
||||||
.put("code", 200)
|
|
||||||
.put("message", "ok")
|
|
||||||
.put("data", new JsonObject().put("token", "jwt-token"));
|
|
||||||
|
|
||||||
assertTrue(PasswordLoginRisk.isLoginSuccess(body));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void blankTokenWithoutRiskKeepsMissingTokenMessage() {
|
|
||||||
JsonObject body = new JsonObject()
|
|
||||||
.put("code", 200)
|
|
||||||
.put("message", "ok")
|
|
||||||
.put("data", new JsonObject().put("token", ""));
|
|
||||||
|
|
||||||
assertFalse(PasswordLoginRisk.isLoginSuccess(body));
|
|
||||||
assertEquals("未获取到token", PasswordLoginRisk.describeLoginFailure(body));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void nonJsonCaptchaBodyUsesHint() {
|
|
||||||
String body = "<html>请完成滑块验证</html>";
|
|
||||||
String message = PasswordLoginRisk.nonJsonLoginFailure(body);
|
|
||||||
assertTrue(message.startsWith(PasswordLoginRisk.AUTHORIZATION_HINT));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void nonJsonWrongPasswordStaysFormatError() {
|
|
||||||
assertEquals("登录响应格式异常: 用户名或密码错误",
|
|
||||||
PasswordLoginRisk.nonJsonLoginFailure("用户名或密码错误"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void assertRisk(String message) {
|
|
||||||
JsonObject body = new JsonObject().put("code", 5202).put("message", message);
|
|
||||||
assertTrue(message, PasswordLoginRisk.indicatesCaptchaOrRisk(body));
|
|
||||||
assertTrue(PasswordLoginRisk.describeLoginFailure(body).startsWith(PasswordLoginRisk.AUTHORIZATION_HINT));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,178 +0,0 @@
|
|||||||
package cn.qaiu.parser.impl;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 个性域名 a.lanzouw.com 不能被改写到 wwww.lanzoux.com(四个 w)。
|
|
||||||
* 部分出口连不上四 w,页面请求会超时;ajax 只把四 w 当作最后兜底。
|
|
||||||
*/
|
|
||||||
public class LzToolShareUrlTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void personalDomainPageStaysOffWwww() {
|
|
||||||
String resolved = LzTool.resolveSharePageUrl(
|
|
||||||
"https://a.lanzouw.com/xxx",
|
|
||||||
"https://w1.lanzn.com/xxx",
|
|
||||||
"xxx");
|
|
||||||
assertEquals("https://a.lanzouw.com/xxx", resolved);
|
|
||||||
assertFalse(resolved.contains("wwww.lanzoux.com"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void folderPageKeepsOriginalHost() {
|
|
||||||
String resolved = LzTool.resolveSharePageUrl(
|
|
||||||
"https://a.lanzouw.com/b710887",
|
|
||||||
"https://w1.lanzn.com/b710887",
|
|
||||||
"b710887");
|
|
||||||
assertEquals("https://a.lanzouw.com/b710887", resolved);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void nodeShareIsNotRewrittenToWwww() {
|
|
||||||
String resolved = LzTool.resolveSharePageUrl(
|
|
||||||
"https://wwn.lanzouy.com/ihLkw1gezutg",
|
|
||||||
"https://w1.lanzn.com/ihLkw1gezutg",
|
|
||||||
"ihLkw1gezutg");
|
|
||||||
assertEquals("https://wwn.lanzouy.com/ihLkw1gezutg", resolved);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void webpageQueryStaysOnOriginalHost() {
|
|
||||||
String resolved = LzTool.resolveSharePageUrl(
|
|
||||||
"https://a.lanzouw.com/iabc?webpage=wp1&pwd=secret",
|
|
||||||
"https://w1.lanzn.com/iabc",
|
|
||||||
"iabc");
|
|
||||||
assertEquals("https://a.lanzouw.com/iabc?webpage=wp1", resolved);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void placeholderUsesStandardHostNotWwww() {
|
|
||||||
assertEquals("https://w1.lanzn.com/", LzTool.SHARE_URL_PREFIX);
|
|
||||||
assertFalse(LzTool.SHARE_URL_PREFIX.contains("wwww"));
|
|
||||||
String resolved = LzTool.resolveSharePageUrl(
|
|
||||||
"https://w1.lanzn.com/-",
|
|
||||||
"https://w1.lanzn.com/-",
|
|
||||||
"iFileId");
|
|
||||||
assertEquals("https://w1.lanzn.com/iFileId", resolved);
|
|
||||||
assertFalse(resolved.contains("wwww.lanzoux.com"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void missingShareUrlKeepsRealStandardHost() {
|
|
||||||
String resolved = LzTool.resolveSharePageUrl(
|
|
||||||
null,
|
|
||||||
"https://www.lanzoux.com/iabc",
|
|
||||||
"iabc");
|
|
||||||
assertEquals("https://www.lanzoux.com/iabc", resolved);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void ajaxFallbackOrderPutsWwwwLast() {
|
|
||||||
List<String> fallback = LzTool.AJAX_FALLBACK_ORIGINS;
|
|
||||||
assertEquals("https://w1.lanzn.com", fallback.get(0));
|
|
||||||
assertEquals("https://www.lanzoux.com", fallback.get(1));
|
|
||||||
assertEquals("https://wwww.lanzoux.com", fallback.get(fallback.size() - 1));
|
|
||||||
|
|
||||||
List<String> origins = LzTool.ajaxOrigins("https://a.lanzouw.com/xxx");
|
|
||||||
assertEquals("https://a.lanzouw.com", origins.get(0));
|
|
||||||
assertEquals("https://w1.lanzn.com", origins.get(1));
|
|
||||||
assertEquals("https://www.lanzoux.com", origins.get(2));
|
|
||||||
assertEquals("https://wwww.lanzoux.com", origins.get(origins.size() - 1));
|
|
||||||
assertTrue(origins.indexOf("https://wwww.lanzoux.com")
|
|
||||||
> origins.indexOf("https://w1.lanzn.com"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void ajaxOriginsDoNotDuplicateKnownHost() {
|
|
||||||
List<String> origins = LzTool.ajaxOrigins("https://www.lanzoux.com/iabc");
|
|
||||||
assertEquals(3, origins.size());
|
|
||||||
assertEquals("https://www.lanzoux.com", origins.get(0));
|
|
||||||
assertEquals("https://w1.lanzn.com", origins.get(1));
|
|
||||||
assertEquals("https://wwww.lanzoux.com", origins.get(2));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void timeoutAjaxFallsBackButBusinessErrorDoesNot() {
|
|
||||||
assertTrue(LzTool.ajaxResponseShouldFallback("{\"zt\":0,\"inf\":\"已超时\"}"));
|
|
||||||
assertTrue(LzTool.ajaxResponseShouldFallback("{\"info\":\"请求超时\"}"));
|
|
||||||
assertTrue(LzTool.ajaxResponseShouldFallback(""));
|
|
||||||
assertTrue(LzTool.ajaxResponseShouldFallback("<html>blocked</html>"));
|
|
||||||
assertFalse(LzTool.ajaxResponseShouldFallback("{\"zt\":0,\"inf\":\"密码错误\"}"));
|
|
||||||
assertFalse(LzTool.ajaxResponseShouldFallback(
|
|
||||||
"{\"zt\":1,\"inf\":\"name.zip\",\"dom\":\"https://x\",\"url\":\"abc\"}"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void filePagePrefersExistingHostOverWwww() {
|
|
||||||
assertEquals("https://a.lanzouw.com/",
|
|
||||||
LzTool.sharePageHostBase("https://a.lanzouw.com/b123", "https://w1.lanzn.com/b123"));
|
|
||||||
assertEquals("https://w1.lanzn.com/",
|
|
||||||
LzTool.sharePageHostBase("https://w1.lanzn.com/-", "https://w1.lanzn.com/-"));
|
|
||||||
assertFalse(LzTool.sharePageHostBase("https://a.lanzouw.com/b123", null).contains("wwww"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void absoluteAjaxUrlIsKeptAndTriedFirst() {
|
|
||||||
String html = """
|
|
||||||
url : 'https://apifile.lanzouw.com/ajaxfile.php?file=320665771',
|
|
||||||
data : { 'action':'downprocess','sign':isngis,'kd':kdns,'p':pwd, },
|
|
||||||
""";
|
|
||||||
String target = LzTool.fileAjaxTarget(html);
|
|
||||||
assertEquals("https://apifile.lanzouw.com/ajaxfile.php?file=320665771", target);
|
|
||||||
|
|
||||||
List<String> origins = LzTool.fileAjaxOrigins(
|
|
||||||
"https://wwaqg.lanzouu.com/iqouM49vy9ib", target);
|
|
||||||
assertEquals("https://apifile.lanzouw.com", origins.get(0));
|
|
||||||
assertTrue(origins.contains("https://wwaqg.lanzouu.com"));
|
|
||||||
assertEquals("https://wwww.lanzoux.com", origins.get(origins.size() - 1));
|
|
||||||
assertTrue(origins.indexOf("https://apifile.lanzouw.com")
|
|
||||||
< origins.indexOf("https://wwaqg.lanzouu.com"));
|
|
||||||
assertTrue(origins.indexOf("https://wwww.lanzoux.com")
|
|
||||||
> origins.indexOf("https://w1.lanzn.com"));
|
|
||||||
assertEquals(1, origins.stream().filter("https://apifile.lanzouw.com"::equals).count());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void protocolRelativeAjaxBecomesHttps() {
|
|
||||||
String html = "url : '//apifile.lanzouw.com/ajaxfile.php?file=9',";
|
|
||||||
assertEquals("https://apifile.lanzouw.com/ajaxfile.php?file=9", LzTool.fileAjaxTarget(html));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void absoluteAjaxWinsOverRelativePathInSamePage() {
|
|
||||||
String html = """
|
|
||||||
//data : { url : '/ajaxfile.php?file=1' }
|
|
||||||
url : "https://apifile.lanzouw.com/ajaxm.php?file=42",
|
|
||||||
""";
|
|
||||||
assertEquals("https://apifile.lanzouw.com/ajaxm.php?file=42", LzTool.fileAjaxTarget(html));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void relativeFileAjaxFallsThroughToApifileBeforeWwww() {
|
|
||||||
String html = "url : '/ajaxfile.php?file=150233466',";
|
|
||||||
assertEquals("/ajaxfile.php?file=150233466", LzTool.fileAjaxTarget(html));
|
|
||||||
|
|
||||||
List<String> origins = LzTool.fileAjaxOrigins("https://a.lanzouw.com/xxx", LzTool.fileAjaxTarget(html));
|
|
||||||
assertEquals("https://a.lanzouw.com", origins.get(0));
|
|
||||||
assertEquals("https://apifile.lanzouw.com", origins.get(1));
|
|
||||||
assertEquals("https://wwww.lanzoux.com", origins.get(origins.size() - 1));
|
|
||||||
assertTrue(origins.indexOf("https://apifile.lanzouw.com")
|
|
||||||
< origins.indexOf("https://wwww.lanzoux.com"));
|
|
||||||
assertFalse(LzTool.ajaxOrigins("https://a.lanzouw.com/xxx").contains("https://apifile.lanzouw.com"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void missingAjaxTargetStillPutsApifileBeforeWwww() {
|
|
||||||
List<String> origins = LzTool.fileAjaxOrigins("https://www.lanzoux.com/ihLkw1gezutg", null);
|
|
||||||
assertEquals("https://www.lanzoux.com", origins.get(0));
|
|
||||||
assertEquals("https://apifile.lanzouw.com", origins.get(1));
|
|
||||||
assertEquals("https://wwww.lanzoux.com", origins.get(origins.size() - 1));
|
|
||||||
assertFalse(origins.get(0).contains("wwww"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<revision>0.4.7</revision>
|
<revision>0.4.6</revision>
|
||||||
<java.version>17</java.version>
|
<java.version>17</java.version>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nfd-web",
|
"name": "nfd-web",
|
||||||
"version": "0.4.7",
|
"version": "0.4.6",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "vue-cli-service serve",
|
"serve": "vue-cli-service serve",
|
||||||
|
|||||||
@@ -139,113 +139,114 @@
|
|||||||
style="background:transparent;"
|
style="background:transparent;"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="batchMode" class="tree-sidebar-footer">
|
<TreeBatchActionBar
|
||||||
<span class="tree-sidebar-count">已勾选 {{ selectedFiles.length }} 个文件</span>
|
v-if="batchMode"
|
||||||
<div class="tree-sidebar-actions">
|
class="tree-sidebar-footer"
|
||||||
<el-button
|
v-bind="treeBatchBarBind"
|
||||||
type="primary"
|
@browser-download="batchBrowserDownload"
|
||||||
size="small"
|
@send-downloader="batchSendToDownloader"
|
||||||
:disabled="selectedFiles.length === 0 || batchDownloading || treeExpanding || batchBrowserDownloadDisabled"
|
@cancel="toggleBatchMode"
|
||||||
:loading="batchDownloading"
|
/>
|
||||||
@click="batchBrowserDownload"
|
|
||||||
:title="batchBrowserDownloadDisabled ? '所选文件需使用下载器下载' : ''"
|
|
||||||
>
|
|
||||||
浏览器下载
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
type="success"
|
|
||||||
size="small"
|
|
||||||
:disabled="selectedFiles.length === 0 || batchDownloading || treeExpanding"
|
|
||||||
:loading="batchDownloading"
|
|
||||||
@click="batchSendToDownloader"
|
|
||||||
>
|
|
||||||
发送到下载器
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
size="small"
|
|
||||||
@click="toggleBatchMode"
|
|
||||||
>
|
|
||||||
取消
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
<div v-if="batchDownloading" class="batch-progress-info">
|
|
||||||
<el-progress :percentage="batchProgressPercent" :status="batchProgressStatus" />
|
|
||||||
<p>{{ batchProgress.current }} / {{ batchProgress.total }}
|
|
||||||
<span v-if="batchProgress.failed > 0" style="color:#f56c6c;"> ({{ batchProgress.failed }} 失败)</span>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</pane>
|
</pane>
|
||||||
<pane>
|
<pane>
|
||||||
<div class="tree-content">
|
<div class="tree-content">
|
||||||
<div v-if="selectedNode" class="file-detail-panel">
|
<div class="tree-toolbar tree-content-toolbar">
|
||||||
<div class="file-detail-icon-wrap">
|
<span class="tree-toolbar-title">
|
||||||
<i :class="getFileIcon(selectedNode)" class="file-detail-icon"></i>
|
<i class="fas fa-file-alt" aria-hidden="true"></i> 详情
|
||||||
</div>
|
</span>
|
||||||
<h4 class="file-detail-name">{{ selectedNode.fileName }}</h4>
|
<el-button
|
||||||
<div v-if="selectedNode.fileType !== 'folder'" class="file-detail-meta">
|
v-if="!batchMode"
|
||||||
<p>类型: {{ selectedNode.fileType === 'url' ? '超链接' : getFileTypeClass(selectedNode) }}</p>
|
type="warning"
|
||||||
<p v-if="selectedNode.fileType !== 'url'">大小: {{ selectedNode.sizeStr || '0B' }}</p>
|
size="small"
|
||||||
<p v-if="selectedNode.fileType === 'url' && selectedNode.previewUrl" class="file-detail-link">
|
@click="toggleBatchMode"
|
||||||
链接: {{ selectedNode.previewUrl }}
|
>
|
||||||
</p>
|
|
||||||
<p v-if="formatDate(selectedNode.createTime)">创建时间: {{ formatDate(selectedNode.createTime) }}</p>
|
|
||||||
<p v-if="formatDate(selectedNode.updateTime)">更新时间: {{ formatDate(selectedNode.updateTime) }}</p>
|
|
||||||
</div>
|
|
||||||
<div class="file-detail-actions">
|
|
||||||
<el-button
|
|
||||||
v-if="selectedNode.fileType === 'url' && selectedNode.previewUrl"
|
|
||||||
type="primary" size="small"
|
|
||||||
@click="openExternalLink(selectedNode)"
|
|
||||||
>
|
|
||||||
<i class="fas fa-external-link-alt"></i> 打开链接
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
v-else-if="selectedNode.parserUrl || selectedNode.previewUrl"
|
|
||||||
size="small"
|
|
||||||
@click="previewFile(selectedNode)"
|
|
||||||
>
|
|
||||||
<i class="fas fa-external-link-alt"></i> 打开
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
v-if="isDownloadableFile(selectedNode)"
|
|
||||||
type="success" size="small"
|
|
||||||
@click="handleDownload(selectedNode)"
|
|
||||||
:loading="downloadLoading"
|
|
||||||
:disabled="needsDownloader(selectedNode)"
|
|
||||||
:title="needsDownloader(selectedNode) ? '该网盘需使用下载器下载' : ''"
|
|
||||||
>
|
|
||||||
<i class="fas fa-download"></i> 下载
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
v-if="isDownloadableFile(selectedNode)"
|
|
||||||
type="primary" size="small"
|
|
||||||
@click="sendSingleToDownloader(selectedNode)"
|
|
||||||
:loading="singleSendLoading"
|
|
||||||
>
|
|
||||||
<i class="fas fa-paper-plane"></i> 发送到下载器
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
v-if="isDownloadableFile(selectedNode)"
|
|
||||||
size="small"
|
|
||||||
@click="copyDirectLink(selectedNode)"
|
|
||||||
:loading="copyLinkLoading"
|
|
||||||
:disabled="needsDownloader(selectedNode)"
|
|
||||||
:title="needsDownloader(selectedNode) ? '该网盘需使用下载器,无法直接复制直链' : ''"
|
|
||||||
>
|
|
||||||
<i class="fas fa-link"></i> 复制直链
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-else class="file-detail-empty">
|
|
||||||
<i class="fas fa-hand-pointer" style="font-size:32px;color:#bbb;margin-bottom:12px;"></i>
|
|
||||||
<p>请在左侧选择文件查看详情</p>
|
|
||||||
</div>
|
|
||||||
<div v-if="!batchMode" class="tree-batch-trigger">
|
|
||||||
<el-button type="warning" size="small" @click="toggleBatchMode">
|
|
||||||
<i class="fas fa-check-double"></i> 批量下载
|
<i class="fas fa-check-double"></i> 批量下载
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<span v-else class="tree-toolbar-hint">
|
||||||
|
{{ treeExpanding ? '正在展开并收集文件…' : `勾选左侧文件夹将自动展开(最多 ${effectiveBatchMaxDepth} 层)` }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="tree-content-body">
|
||||||
|
<div v-if="selectedNode" class="file-detail-panel">
|
||||||
|
<div class="file-detail-icon-wrap">
|
||||||
|
<i :class="getFileIcon(selectedNode)" class="file-detail-icon"></i>
|
||||||
|
</div>
|
||||||
|
<h4 class="file-detail-name">{{ selectedNode.fileName }}</h4>
|
||||||
|
<div v-if="selectedNode.fileType !== 'folder'" class="file-detail-meta">
|
||||||
|
<p>类型: {{ selectedNode.fileType === 'url' ? '超链接' : getFileTypeClass(selectedNode) }}</p>
|
||||||
|
<p v-if="selectedNode.fileType !== 'url'">大小: {{ selectedNode.sizeStr || '0B' }}</p>
|
||||||
|
<p v-if="selectedNode.fileType === 'url' && selectedNode.previewUrl" class="file-detail-link">
|
||||||
|
链接: {{ selectedNode.previewUrl }}
|
||||||
|
</p>
|
||||||
|
<p v-if="formatDate(selectedNode.createTime)">创建时间: {{ formatDate(selectedNode.createTime) }}</p>
|
||||||
|
<p v-if="formatDate(selectedNode.updateTime)">更新时间: {{ formatDate(selectedNode.updateTime) }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="file-detail-actions">
|
||||||
|
<el-button
|
||||||
|
v-if="selectedNode.fileType === 'url' && selectedNode.previewUrl"
|
||||||
|
type="primary" size="small"
|
||||||
|
@click="openExternalLink(selectedNode)"
|
||||||
|
>
|
||||||
|
<i class="fas fa-external-link-alt"></i> 打开链接
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-else-if="selectedNode.parserUrl || selectedNode.previewUrl"
|
||||||
|
size="small"
|
||||||
|
@click="previewFile(selectedNode)"
|
||||||
|
>
|
||||||
|
<i class="fas fa-external-link-alt"></i> 打开
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="isDownloadableFile(selectedNode)"
|
||||||
|
type="success" size="small"
|
||||||
|
@click="handleDownload(selectedNode)"
|
||||||
|
:loading="downloadLoading"
|
||||||
|
:disabled="needsDownloader(selectedNode)"
|
||||||
|
:title="needsDownloader(selectedNode) ? '该网盘需使用下载器下载' : ''"
|
||||||
|
>
|
||||||
|
<i class="fas fa-download"></i> 下载
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="isDownloadableFile(selectedNode)"
|
||||||
|
type="primary" size="small"
|
||||||
|
@click="sendSingleToDownloader(selectedNode)"
|
||||||
|
:loading="singleSendLoading"
|
||||||
|
>
|
||||||
|
<i class="fas fa-paper-plane"></i> 发送到下载器
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="isDownloadableFile(selectedNode)"
|
||||||
|
size="small"
|
||||||
|
@click="copyDirectLink(selectedNode)"
|
||||||
|
:loading="copyLinkLoading"
|
||||||
|
:disabled="needsDownloader(selectedNode)"
|
||||||
|
:title="needsDownloader(selectedNode) ? '该网盘需使用下载器,无法直接复制直链' : ''"
|
||||||
|
>
|
||||||
|
<i class="fas fa-link"></i> 复制直链
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else class="file-detail-empty">
|
||||||
|
<i class="fas fa-hand-pointer" style="font-size:32px;color:#bbb;margin-bottom:12px;"></i>
|
||||||
|
<p>请在左侧选择文件查看详情</p>
|
||||||
|
<p v-if="!batchMode" class="file-detail-empty-hint">或直接点击「批量下载」勾选多个文件</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="tree-content-footer" :class="{ 'is-batch': batchMode }">
|
||||||
|
<template v-if="!batchMode">
|
||||||
|
<span class="tree-content-footer-hint">可直接勾选多个文件下载</span>
|
||||||
|
<el-button type="warning" size="small" @click="toggleBatchMode">
|
||||||
|
<i class="fas fa-check-double"></i> 批量下载
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
<TreeBatchActionBar
|
||||||
|
v-else
|
||||||
|
v-bind="treeBatchBarBind"
|
||||||
|
@browser-download="batchBrowserDownload"
|
||||||
|
@send-downloader="batchSendToDownloader"
|
||||||
|
@cancel="toggleBatchMode"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</pane>
|
</pane>
|
||||||
@@ -353,26 +354,21 @@
|
|||||||
<div v-else class="file-detail-empty">
|
<div v-else class="file-detail-empty">
|
||||||
<i class="fas fa-hand-pointer" style="font-size:24px;color:#bbb;margin-bottom:8px;"></i>
|
<i class="fas fa-hand-pointer" style="font-size:24px;color:#bbb;margin-bottom:8px;"></i>
|
||||||
<p>请在上方选择文件查看详情</p>
|
<p>请在上方选择文件查看详情</p>
|
||||||
|
<p v-if="!batchMode" class="file-detail-empty-hint">或直接点击「批量下载」勾选多个文件</p>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="!batchMode" class="mobile-batch-trigger">
|
<div v-if="!batchMode" class="mobile-batch-trigger">
|
||||||
<el-button type="warning" size="small" @click="toggleBatchMode">
|
<el-button type="warning" size="small" @click="toggleBatchMode">
|
||||||
<i class="fas fa-check-double"></i> 批量下载
|
<i class="fas fa-check-double"></i> 批量下载
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="batchMode" class="mobile-batch-footer">
|
<TreeBatchActionBar
|
||||||
<span class="tree-sidebar-count">已勾选 {{ selectedFiles.length }} 个文件</span>
|
v-if="batchMode"
|
||||||
<div class="tree-sidebar-actions">
|
class="mobile-batch-footer"
|
||||||
<el-button type="primary" size="small" :disabled="selectedFiles.length === 0 || batchDownloading || treeExpanding || batchBrowserDownloadDisabled" :loading="batchDownloading" @click="batchBrowserDownload" :title="batchBrowserDownloadDisabled ? '所选文件需使用下载器下载' : ''">浏览器下载</el-button>
|
v-bind="treeBatchBarBind"
|
||||||
<el-button type="success" size="small" :disabled="selectedFiles.length === 0 || batchDownloading || treeExpanding" :loading="batchDownloading" @click="batchSendToDownloader">发送到下载器</el-button>
|
@browser-download="batchBrowserDownload"
|
||||||
<el-button size="small" @click="toggleBatchMode">取消</el-button>
|
@send-downloader="batchSendToDownloader"
|
||||||
</div>
|
@cancel="toggleBatchMode"
|
||||||
<div v-if="batchDownloading" class="batch-progress-info">
|
/>
|
||||||
<el-progress :percentage="batchProgressPercent" :status="batchProgressStatus" />
|
|
||||||
<p>{{ batchProgress.current }} / {{ batchProgress.total }}
|
|
||||||
<span v-if="batchProgress.failed > 0" style="color:#f56c6c;"> ({{ batchProgress.failed }} 失败)</span>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
@@ -453,6 +449,7 @@ import { Splitpanes, Pane } from 'splitpanes'
|
|||||||
import 'splitpanes/dist/splitpanes.css'
|
import 'splitpanes/dist/splitpanes.css'
|
||||||
import fileTypeUtils from '@/utils/fileTypeUtils'
|
import fileTypeUtils from '@/utils/fileTypeUtils'
|
||||||
import DownloadDialog from '@/components/DownloadDialog.vue'
|
import DownloadDialog from '@/components/DownloadDialog.vue'
|
||||||
|
import TreeBatchActionBar from '@/components/TreeBatchActionBar.vue'
|
||||||
import { testConnection, autoDetect, addDownload, batchAddDownload, getConfig, saveConfig } from '@/utils/downloaderService'
|
import { testConnection, autoDetect, addDownload, batchAddDownload, getConfig, saveConfig } from '@/utils/downloaderService'
|
||||||
import batchTreeCollect from '@/utils/batchTreeCollect'
|
import batchTreeCollect from '@/utils/batchTreeCollect'
|
||||||
|
|
||||||
@@ -466,7 +463,7 @@ const {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'DirectoryTree',
|
name: 'DirectoryTree',
|
||||||
components: { ElTree, Splitpanes, Pane, DownloadDialog },
|
components: { ElTree, Splitpanes, Pane, DownloadDialog, TreeBatchActionBar },
|
||||||
props: {
|
props: {
|
||||||
fileList: {
|
fileList: {
|
||||||
type: Array,
|
type: Array,
|
||||||
@@ -566,6 +563,19 @@ export default {
|
|||||||
effectiveBatchMaxDepth() {
|
effectiveBatchMaxDepth() {
|
||||||
const depth = Number(this.batchMaxDepth)
|
const depth = Number(this.batchMaxDepth)
|
||||||
return Number.isFinite(depth) && depth >= 0 ? depth : DEFAULT_BATCH_MAX_DEPTH
|
return Number.isFinite(depth) && depth >= 0 ? depth : DEFAULT_BATCH_MAX_DEPTH
|
||||||
|
},
|
||||||
|
treeBatchBarBind() {
|
||||||
|
return {
|
||||||
|
selectedCount: this.selectedFiles.length,
|
||||||
|
batchDownloading: this.batchDownloading,
|
||||||
|
treeExpanding: this.treeExpanding,
|
||||||
|
browserDisabled: this.batchBrowserDownloadDisabled,
|
||||||
|
progressPercent: this.batchProgressPercent,
|
||||||
|
progressStatus: this.batchProgressStatus,
|
||||||
|
progressCurrent: this.batchProgress.current,
|
||||||
|
progressTotal: this.batchProgress.total,
|
||||||
|
progressFailed: this.batchProgress.failed
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -1640,10 +1650,21 @@ html, body, #app, .main-container, .directory-tree, .content-card {
|
|||||||
.batch-progress-info {
|
.batch-progress-info {
|
||||||
margin-top: 12px;
|
margin-top: 12px;
|
||||||
}
|
}
|
||||||
.tree-batch-trigger {
|
.tree-content-footer-hint {
|
||||||
position: absolute;
|
font-size: 12px;
|
||||||
bottom: 12px;
|
color: #909399;
|
||||||
right: 12px;
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
.dark-theme .tree-content-footer-hint {
|
||||||
|
color: #bdc3c7;
|
||||||
|
}
|
||||||
|
.file-detail-empty-hint {
|
||||||
|
margin-top: 8px;
|
||||||
|
font-size: 13px;
|
||||||
|
color: #909399;
|
||||||
|
}
|
||||||
|
.dark-theme .file-detail-empty-hint {
|
||||||
|
color: #bdc3c7;
|
||||||
}
|
}
|
||||||
|
|
||||||
.stats {
|
.stats {
|
||||||
@@ -1714,8 +1735,7 @@ html, body, #app, .main-container, .directory-tree, .content-card {
|
|||||||
}
|
}
|
||||||
.tree-content {
|
.tree-content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 16px;
|
min-height: 0;
|
||||||
overflow-y: auto;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2008,12 +2028,48 @@ html, body, #app, .main-container, .directory-tree, .content-card {
|
|||||||
min-height: 0;
|
min-height: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
overflow: auto;
|
overflow: hidden;
|
||||||
padding: 24px 16px 16px 16px;
|
padding: 0;
|
||||||
align-items: center;
|
align-items: stretch;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tree-content-toolbar {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tree-content-body {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: auto;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
padding: 24px 16px 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tree-content-footer {
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-top: 1px solid #eaeaea;
|
||||||
|
background: #f8f9fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tree-content-footer.is-batch {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark-theme .tree-content-footer {
|
||||||
|
border-top-color: #404040;
|
||||||
|
background: #232323;
|
||||||
|
}
|
||||||
|
|
||||||
.file-detail-panel {
|
.file-detail-panel {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<span class="tree-sidebar-count">已勾选 {{ selectedCount }} 个文件</span>
|
||||||
|
<div class="tree-sidebar-actions">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
:disabled="selectedCount === 0 || batchDownloading || treeExpanding || browserDisabled"
|
||||||
|
:loading="batchDownloading"
|
||||||
|
:title="browserDisabled ? '所选文件需使用下载器下载' : ''"
|
||||||
|
@click="$emit('browser-download')"
|
||||||
|
>
|
||||||
|
浏览器下载
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
size="small"
|
||||||
|
:disabled="selectedCount === 0 || batchDownloading || treeExpanding"
|
||||||
|
:loading="batchDownloading"
|
||||||
|
@click="$emit('send-downloader')"
|
||||||
|
>
|
||||||
|
发送到下载器
|
||||||
|
</el-button>
|
||||||
|
<el-button size="small" @click="$emit('cancel')">取消</el-button>
|
||||||
|
</div>
|
||||||
|
<div v-if="batchDownloading" class="batch-progress-info">
|
||||||
|
<el-progress :percentage="progressPercent" :status="progressStatus" />
|
||||||
|
<p>{{ progressCurrent }} / {{ progressTotal }}
|
||||||
|
<span v-if="progressFailed > 0" style="color:#f56c6c;"> ({{ progressFailed }} 失败)</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'TreeBatchActionBar',
|
||||||
|
props: {
|
||||||
|
selectedCount: { type: Number, default: 0 },
|
||||||
|
batchDownloading: { type: Boolean, default: false },
|
||||||
|
treeExpanding: { type: Boolean, default: false },
|
||||||
|
browserDisabled: { type: Boolean, default: false },
|
||||||
|
progressPercent: { type: Number, default: 0 },
|
||||||
|
progressStatus: { type: String, default: '' },
|
||||||
|
progressCurrent: { type: Number, default: 0 },
|
||||||
|
progressTotal: { type: Number, default: 0 },
|
||||||
|
progressFailed: { type: Number, default: 0 }
|
||||||
|
},
|
||||||
|
emits: ['browser-download', 'send-downloader', 'cancel']
|
||||||
|
}
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user