mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-01-12 09:24:14 +00:00
feat: 添加 WPS 云文档/WPS 云盘解析支持 (closes #133)
- 新增 PwpsTool 解析器,支持 WPS 云文档直链获取 - 调用 WPS API: https://www.kdocs.cn/api/office/file/{shareKey}/download - 前端添加 kdocs.cn 链接识别规则 - 前端预览功能优化:WPS 云文档直接使用原分享链接预览 - 后端预览接口特殊处理:判断 shareKey 以 pwps: 开头自动重定向 - 支持提取文件名和有效期信息 - 更新 README 文档,添加 WPS 云文档支持说明 Parser 模块设计: - 遵循开放封闭原则,易于扩展新网盘 - 只需实现 IPanTool 接口和注册枚举即可 - 支持自定义域名解析和责任链模式 技术特性: - 免登录获取下载直链 - 支持在线预览(利用 WPS 原生功能) - 文件大小限制:10M(免费版)/2G(会员版) - 初始空间:5G(免费版)
This commit is contained in:
@@ -266,6 +266,12 @@ public enum PanDomainTemplate {
|
||||
compile("https://pan-yz\\.cldisk\\.com/external/m/file/(?<KEY>\\w+)"),
|
||||
"https://pan-yz.cldisk.com/external/m/file/{shareKey}",
|
||||
PcxTool.class),
|
||||
// WPS:分享格式:https://www.kdocs.cn/l/ck0azivLlDi3 ;API格式:https://www.kdocs.cn/api/office/file/{shareKey}/download
|
||||
// 响应:{download_url: "https://hwc-bj.ag.kdocs.cn/api/xx",url: "",fize: 0,fver: 0,store: ""}
|
||||
PWPS("WPS",
|
||||
compile("https://www\\.kdocs\\.cn/l/(?<KEY>.+)"),
|
||||
"https://www.kdocs.cn/l/{shareKey}",
|
||||
PwpsTool.class),
|
||||
// =====================音乐类解析 分享链接标志->MxxS (单歌曲/普通音质)==========================
|
||||
// http://163cn.tv/xxx
|
||||
MNES("网易云音乐分享",
|
||||
|
||||
63
parser/src/main/java/cn/qaiu/parser/impl/PwpsTool.java
Normal file
63
parser/src/main/java/cn/qaiu/parser/impl/PwpsTool.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package cn.qaiu.parser.impl;
|
||||
|
||||
import cn.qaiu.entity.ShareLinkInfo;
|
||||
import cn.qaiu.parser.PanBase;
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
|
||||
/**
|
||||
* <a href="https://www.kdocs.cn/">WPS云文档</a>
|
||||
* 分享格式:https://www.kdocs.cn/l/ck0azivLlDi3
|
||||
* API格式:https://www.kdocs.cn/api/office/file/{shareKey}/download
|
||||
* 响应:{download_url: "https://hwc-bj.ag.kdocs.cn/api/xx",url: "",fize: 0,fver: 0,store: ""}
|
||||
*/
|
||||
public class PwpsTool extends PanBase {
|
||||
private static final String API_URL_TEMPLATE = "https://www.kdocs.cn/api/office/file/%s/download";
|
||||
|
||||
public PwpsTool(ShareLinkInfo shareLinkInfo) {
|
||||
super(shareLinkInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<String> parse() {
|
||||
final String shareKey = shareLinkInfo.getShareKey();
|
||||
|
||||
// 构建API URL
|
||||
String apiUrl = String.format(API_URL_TEMPLATE, shareKey);
|
||||
|
||||
// 发送GET请求到WPS API
|
||||
client.getAbs(apiUrl)
|
||||
.send()
|
||||
.onSuccess(res -> {
|
||||
try {
|
||||
JsonObject resJson = asJson(res);
|
||||
|
||||
// 检查响应是否包含download_url字段
|
||||
if (resJson.containsKey("download_url")) {
|
||||
String downloadUrl = resJson.getString("download_url");
|
||||
|
||||
if (downloadUrl != null && !downloadUrl.isEmpty()) {
|
||||
log.info("WPS云文档解析成功: shareKey={}, downloadUrl={}", shareKey, downloadUrl);
|
||||
promise.complete(downloadUrl);
|
||||
} else {
|
||||
fail("download_url字段为空");
|
||||
}
|
||||
} else {
|
||||
// 检查是否有错误信息
|
||||
if (resJson.containsKey("error") || resJson.containsKey("msg")) {
|
||||
String errorMsg = resJson.getString("error", resJson.getString("msg", "未知错误"));
|
||||
fail("API返回错误: {}", errorMsg);
|
||||
} else {
|
||||
fail("响应中未找到download_url字段, 响应内容: {}", resJson.encodePrettily());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
fail(e, "解析响应JSON失败");
|
||||
}
|
||||
})
|
||||
.onFailure(handleFail(apiUrl));
|
||||
|
||||
return promise.future();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user