Skip to content

Commit

Permalink
- 升级vertx到4.5.6
Browse files Browse the repository at this point in the history
- 添加Cloudreve
- 蓝奏云优享和小飞机规则修改
  • Loading branch information
qaiu committed Apr 9, 2024
1 parent d6de985 commit 068efd0
Show file tree
Hide file tree
Showing 16 changed files with 246 additions and 51 deletions.
73 changes: 45 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
云盘解析服务 (nfd云解析)
预览地址 https://lz.qaiu.top
注意: lz.qaiu.top因解析量过大IP已被123和小飞机禁止访问,
请不要过度依赖预览地址服务,建议本地搭建或者云服务器自行搭建
预览地址 https://lz.qaiu.top
**注意: 请不要过度依赖lz.qaiu.top预览地址服务,建议本地搭建或者云服务器自行搭建。
解析次数过多IP会被部分网盘厂商限制,不推荐做公共解析。**

[![Java CI with Maven](https://github.com/qaiu/netdisk-fast-download/actions/workflows/maven.yml/badge.svg)](https://github.com/qaiu/netdisk-fast-download/actions/workflows/maven.yml)
[![jdk](https://img.shields.io/badge/jdk-%3E%3D17-blue)](https://www.oracle.com/cn/java/technologies/downloads/)
[![vert.x](https://img.shields.io/badge/vert.x-4.5.0-blue)](https://vertx-china.github.io/)
[![vert.x](https://img.shields.io/badge/vert.x-4.5.6-blue)](https://vertx-china.github.io/)
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/qaiu/netdisk-fast-download)](https://github.com/qaiu/netdisk-fast-download/releases/tag/0.1.6-releases)

## 项目介绍
网盘直链解析工具能把网盘分享下载链接转化为直链,已支持蓝奏云/蓝奏云优享/奶牛快传/移动云云空间/小飞机盘/亿方云/123云盘等,支持私密分享
网盘直链解析工具能把网盘分享下载链接转化为直链,已支持蓝奏云/蓝奏云优享/奶牛快传/移动云云空间/小飞机盘/亿方云/123云盘/Cloudreve等,支持加密分享


*重要声明:本项目仅供学习参考;请不要将此项目用于任何商业用途,否则可能带来严重的后果。*
Expand All @@ -33,9 +33,6 @@
- [移动云空间 (ec)](https://www.ecpan.cn/web)
- [ ] 登录, 上传, 下载, 分享
- [X] 直链解析
- [UC网盘 (uc)似乎已经失效,需要登录](https://fast.uc.cn/)
- [ ] 登录, 上传, 下载, 分享
- [X] 直链解析
- [小飞机网盘 (fj)](https://www.feijipan.com/)
- [ ] 登录, 上传, 下载, 分享
- [X] 直链解析
Expand All @@ -45,42 +42,57 @@
- [123云盘 (ye)](https://www.123pan.com/)
- [ ] 登录, 上传, 下载, 分享
- [X] 直链解析
- [文叔叔 (ws) 开发中](https://www.wenshushu.cn/)
- [文叔叔 (ws)](https://www.wenshushu.cn/)
- [ ] 登录, 上传, 下载, 分享
- [X] 直链解析
- [QQ邮箱 (qq) 开发中](https://wx.mail.qq.com/)
- [Cloudreve自建网盘 (ce)](https://github.com/cloudreve/Cloudreve)
- [ ] 登录, 上传, 下载, 分享
- [X] 直链解析
- [QQ邮箱 (qq) 暂不可用-存在cookie问题](https://wx.mail.qq.com/)
- [ ] 登录, 上传, 下载, 分享
- [X] 直链解析(用户无法直接使用直链)
- [夸克网盘 (qk) 开发中](https://pan.quark.cn/)
- [夸克网盘 (qk) 寄了](https://pan.quark.cn/)
- [UC网盘 (uc) 寄了](https://fast.uc.cn/)

**TODO:**
- 登录接口, 文件上传/下载/分享后端接口
- 短地址服务
- 前端界面(建设中...)

**技术栈:**
Jdk17+Vert.x4.4.1
Core模块集成Vert.x实现类似spring的注解式路由API

API接口

### API接口说明
your_host指的是您的域名或者IP,实际使用时替换为实际域名或者IP。
解析方式分为两种类型直接跳转下载链接和获取下载链接(JSON),每一种都提供了两种接口形式parser和网盘标志/分享key拼接的短地址(标志短链),所有规则参考示例。
- 通用接口: `/parser?url=分享链接`,加密分享需要加上参数pwd=密码;
- 标志短链: `/网盘标识/分享key` 在分享Key后面加上@密码;
- 直链JSON: `通用接口``标志短链`前加上`/json` 加密分享的密码规则同上;
- 网盘标识参考上面网盘支持情况
- 括号内是可选内容: 表示当带有分享密码时需要加上密码参数
- 移动云空间,小飞机网盘的加密分享的密码可以忽略

规则示例:
```
网盘标识参考上面网盘支持情况, 括号内是可选内容: 表示当带有分享密码时需要加上密码参数
parser接口可以直接解析分享链接: 加密分享需要加上参数pwd=密码;
其他接口在分享Key后面加上@密码;
1. 解析并自动302跳转 :
http(s)://your_host/parser?url=分享链接(&pwd=xxx)
http(s)://your_host/网盘标识/分享key(@分享密码)
http://your_host/parser?url=分享链接(&pwd=xxx)
http://your_host/网盘标识/分享key(@分享密码)
2. 获取解析后的直链--JSON格式
http(s)://your_host/json/parser?url=分享链接(&pwd=xxx)
http(s)://your_host/json/网盘标识/分享key(@分享密码)
3. 特别注意的地方:
- 有些网盘的加密分享的密码可以忽略: 如移动云空间,小飞机网盘
- 移动云空间(ec)使用parser?url= 解析时因为分享链接比较特殊(链接带有参数且含有#符号)所以要么对#进行转义%23要么直接去掉# 或者URL直接是主机名+'/'跟一个data参数
http://your_host/json/parser?url=分享链接(&pwd=xxx)
http://your_host/json/网盘标识/分享key(@分享密码)
3. 需要特殊处理的网盘分享:
1. 移动云空间(ec)使用parser?url= 解析时因为分享链接比较特殊(链接带有参数且含有#符号)所以要么对#进行转义%23要么直接去掉# 或者URL直接是主机名+'/'跟一个data参数
比如 http://your_host/parser?url=https://www.ecpan.cn/web//yunpanProxy?path=%2F%23%2Fdrive%2Foutside&data=81027a5c99af5b11ca004966c945cce6W9Bf2&isShare=1
http://your_host/parser?url=https://www.ecpan.cn/web/%23/yunpanProxy?path=%2F%23%2Fdrive%2Foutside&data=81027a5c99af5b11ca004966c945cce6W9Bf2&isShare=1
http://your_host/parser?url=https://www.ecpan.cn/&data=81027a5c99af5b11ca004966c945cce6W9Bf2&isShare=1
2. Cloudreve自建网盘解析规则:
1. 标志短链: 根据网盘使用https和http选择 http://your_host/ce/https_网盘域名_s_wDz5TK 或 http://your_host/ce/http_网盘域名_s_wDz5TK
网盘域名指的是Cloudreve搭建网盘的主域名比如pan.huang1111.cn,如果存在子路径需要将/替换为_,是否存在子路径看分享链接格式是否是://网盘域名/子路径/s/xxx,一般不存在子路径:网盘域名/s/xxx,
比如: http://127.0.0.1:6400/ce/https_pan.huang1111.cn_s_wDz5TK
2. parser接口 -> http://your_host/parser?url=分享链接(&pwd=xxx)
比如: http://127.0.0.1:6400/parser?url=https://pan.huang1111.cn/s/wDz5TK
```
json返回数据格式示例:
```json
Expand Down Expand Up @@ -205,14 +217,19 @@ bash service-install.sh
- 直链缓存
- 日志优化


**技术栈:**
Jdk17+Vert.x4.4.1
Core模块集成Vert.x实现类似spring的注解式路由API


## Star History

[![Star History Chart](https://api.star-history.com/svg?repos=qaiu/netdisk-fast-download&type=Date)](https://star-history.com/#qaiu/netdisk-fast-download&Date)


## 支持该项目
本项目长期维护如果觉得有帮助, 可以请作者喝杯咖啡, 感谢支持
支付宝发大额红包了...就这几天, 不要错过哦
![image](https://github.com/qaiu/netdisk-fast-download/assets/29825328/54276aee-cc3f-4ebd-8973-2e15f6295819)

[手机端支付宝打赏跳转链接](https://qr.alipay.com/fkx01882dnoxxtjenhlxt53)
Expand Down
2 changes: 1 addition & 1 deletion core-database/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<slf4j.version>2.0.5</slf4j.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<vertx.version>4.5.0</vertx.version>
<vertx.version>4.5.6</vertx.version>
</properties>

<dependencies>
Expand Down
4 changes: 4 additions & 0 deletions parser/src/main/java/cn/qaiu/parser/IPanTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ static IPanTool typeMatching(String type, String key, String pwd) {
case "ws" -> new WsTool(key, pwd);
case "qq" -> new QQTool(key, pwd);
case "iz" -> new IzTool(key, pwd);
case "ce" -> new CeTool(key, pwd);
default -> {
throw new UnsupportedOperationException("未知分享类型");
}
Expand Down Expand Up @@ -50,6 +51,9 @@ static IPanTool shareURLPrefixMatching(String url, String pwd) {
return new WsTool(url, pwd);
} else if (url.contains(QQTool.SHARE_URL_PREFIX)) {
return new QQTool(url, pwd);
} else if (url.contains("/s/")) {
// Cloudreve 网盘通用解析
return new CeTool(url, pwd);
}

throw new UnsupportedOperationException("未知分享类型");
Expand Down
6 changes: 6 additions & 0 deletions parser/src/main/java/cn/qaiu/parser/PanBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.vertx.core.Promise;
import io.vertx.ext.web.client.WebClient;
import io.vertx.ext.web.client.WebClientOptions;
import io.vertx.ext.web.client.WebClientSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -23,6 +24,11 @@ public abstract class PanBase {
*/
protected WebClient client = WebClient.create(WebClientVertxInit.get());

/**
* Http client session (会话管理, 带cookie请求)
*/
protected WebClientSession clientSession = WebClientSession.create(client);

/**
* Http client 不自动跳转
*/
Expand Down
73 changes: 73 additions & 0 deletions parser/src/main/java/cn/qaiu/parser/impl/CeTool.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package cn.qaiu.parser.impl;

import cn.qaiu.parser.IPanTool;
import cn.qaiu.parser.PanBase;
import io.vertx.core.Future;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.client.HttpRequest;

import java.net.MalformedURLException;
import java.net.URL;

/**
* <a href="https://github.com/cloudreve/Cloudreve">Cloudreve网盘解析</a> <br>
* <a href="https://pan.xiaomuxi.cn">暮希云盘</a> <br>
* <a href="https://pan.huang1111.cn">huang1111</a> <br>
*/
public class CeTool extends PanBase implements IPanTool {

private static final String DOWNLOAD_API_PATH = "/api/v3/share/download/";

// api/v3/share/info/g31PcQ?password=qaiu
private static final String SHARE_API_PATH = "/api/v3/share/info/";

public CeTool(String key, String pwd) {
super(key, pwd);
}

public Future<String> parse() {
// https://pan.huang1111.cn/s/wDz5TK
// https://pan.huang1111.cn/s/y12bI6 -> https://pan.huang1111
// .cn/api/v3/share/download/y12bI6?path=undefined%2Fundefined;
// 类型解析 -> /ce/https_pan.huang1111.cn_s_wDz5TK
// parser接口 -> /parser?url=https://pan.huang1111.cn/s/wDz5TK
try {
if (key.startsWith("https_") || key.startsWith("http_")) {
key = key.replace("https_", "https://")
.replace("http_", "http://")
.replace("_", "/");
}
// 处理URL
URL url = new URL(key);
String path = url.getPath();
String shareKey = path.substring(3);
String downloadApiUrl = url.getProtocol() + "://" + url.getHost() + DOWNLOAD_API_PATH + shareKey + "?path" +
"=undefined/undefined;";
String shareApiUrl = url.getProtocol() + "://" + url.getHost() + SHARE_API_PATH + shareKey;

// 设置cookie
HttpRequest<Buffer> httpRequest = clientSession.getAbs(shareApiUrl);
if (pwd != null) {
httpRequest.addQueryParam("password", pwd);
}
// 获取下载链接
httpRequest.send().onSuccess(res -> getDownURL(downloadApiUrl)).onFailure(handleFail(shareApiUrl));
} catch (MalformedURLException e) {
fail(e, "URL解析错误");
}
return promise.future();
}

private void getDownURL(String apiUrl) {
clientSession.putAbs(apiUrl).send().onSuccess(res -> {
JsonObject jsonObject = res.bodyAsJsonObject();
System.out.println(jsonObject.encodePrettily());
if (jsonObject.containsKey("code") && jsonObject.getInteger("code") == 0) {
promise.complete(jsonObject.getString("data"));
} else {
fail("JSON解析失败: {}", jsonObject.encodePrettily());
}
}).onFailure(handleFail(apiUrl));
}
}
11 changes: 9 additions & 2 deletions parser/src/main/java/cn/qaiu/parser/impl/FjTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
public class FjTool extends PanBase implements IPanTool {

public static final String SHARE_URL_PREFIX = "https://www.feijix.com/s/";
public static final String SHARE_URL_PREFIX2 = "https://share.feijipan.com/s/";
public static final String REFERER_URL = "https://share.feijipan.com/";
public static final String SHARE_URL_PREFIX2 = REFERER_URL + "s/";
private static final String API_URL_PREFIX = "https://api.feijipan.com/ws/";

private static final String FIRST_REQUEST_URL = API_URL_PREFIX + "recommend/list?devType=6&devModel=Chrome&extra" +
Expand Down Expand Up @@ -57,15 +58,21 @@ public Future<String> parse() {
return;
}
// 文件Id
String fileId = resJson.getJsonArray("list").getJsonObject(0).getString("fileIds");
JsonObject fileInfo = resJson.getJsonArray("list").getJsonObject(0);
String fileId = fileInfo.getString("fileIds");
String userId = fileInfo.getString("userId");
// 其他参数
long nowTs = System.currentTimeMillis();
String tsEncode = AESUtils.encrypt2Hex(Long.toString(nowTs));
String uuid = UUID.randomUUID().toString();
String fidEncode = AESUtils.encrypt2Hex(fileId + "|");
String auth = AESUtils.encrypt2Hex(fileId + "|" + nowTs);

MultiMap headers0 = MultiMap.caseInsensitiveMultiMap();
headers0.set("referer", REFERER_URL);
// 第二次请求
client.getAbs(UriTemplate.of(SECOND_REQUEST_URL))
.putHeaders(headers0)
.setTemplateParam("fidEncode", fidEncode)
.setTemplateParam("uuid", uuid)
.setTemplateParam("ts", tsEncode)
Expand Down
10 changes: 6 additions & 4 deletions parser/src/main/java/cn/qaiu/parser/impl/IzTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
import java.util.UUID;

/**
* 小飞机网盘
* 蓝奏云优享
*
* @version V016_230609
*/
public class IzTool extends PanBase implements IPanTool {

Expand Down Expand Up @@ -51,12 +50,15 @@ public Future<String> parse() {
return;
}
// 文件Id
String fileId = resJson.getJsonArray("list").getJsonObject(0).getString("fileIds");
JsonObject fileInfo = resJson.getJsonArray("list").getJsonObject(0);
String fileId = fileInfo.getString("fileIds");
String userId = fileInfo.getString("userId");
// 其他参数
long nowTs = System.currentTimeMillis();
String tsEncode = AESUtils.encrypt2HexIz(Long.toString(nowTs));
String uuid = UUID.randomUUID().toString();
String fidEncode = AESUtils.encrypt2HexIz(fileId + "|");
// String fidEncode = AESUtils.encrypt2HexIz(fileId + "|");
String fidEncode = AESUtils.encrypt2HexIz(fileId + "|" + userId);
String auth = AESUtils.encrypt2HexIz(fileId + "|" + nowTs);
// 第二次请求
client.getAbs(UriTemplate.of(SECOND_REQUEST_URL))
Expand Down
6 changes: 6 additions & 0 deletions parser/src/main/java/cn/qaiu/util/CommonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

public class CommonUtils {

/**
* 获取分享key 比如: https://www.ilanzou.com/s/xxx -> xxx
* @param urlPrefix 不包含key的URL前缀
* @param url 完整URL
* @return 分享key
*/
public static String adaptShortPaths(String urlPrefix, String url) {
if (url.endsWith(".html")) {
url = url.substring(0, url.length() - 5);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<packageDirectory>${project.basedir}/web-service/target/package</packageDirectory>

<slf4j.version>2.0.5</slf4j.version>
<vertx.version>4.5.0</vertx.version>
<vertx.version>4.5.6</vertx.version>
<org.reflections.version>0.10.2</org.reflections.version>
<lombok.version>1.18.12</lombok.version>
<slf4j.version>2.0.5</slf4j.version>
Expand Down
26 changes: 13 additions & 13 deletions web-service/src/main/java/cn/qaiu/lz/web/http/ServerApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public Future<Void> parse(HttpServerResponse response, HttpServerRequest request
"&code=" + request.getParam("code") + "&k=" + request.getParam("k") +
"&fweb=" + request.getParam("fweb") + "&cl=" + request.getParam("cl");
}
IPanTool.shareURLPrefixMatching(url, pwd).parse().onSuccess(resUrl -> {
ResponseUtil.redirect(response, resUrl, promise);
}).onFailure(t -> promise.fail(t.fillInStackTrace()));
IPanTool.shareURLPrefixMatching(url, pwd).parse()
.onSuccess(resUrl -> ResponseUtil.redirect(response, resUrl, promise))
.onFailure(t -> promise.fail(t.fillInStackTrace()));
return promise.future();
}

Expand All @@ -52,6 +52,16 @@ public Future<String> parseJson(HttpServerRequest request, String url, String pw
return IPanTool.shareURLPrefixMatching(url, pwd).parse();
}

@RouteMapping(value = "/json/:type/:key", method = RouteMethod.GET, order = 2)
public Future<String> parseKeyJson(String type, String key) {
String code = "";
if (key.contains("@")) {
String[] keys = key.split("@");
key = keys[0];
code = keys[1];
}
return IPanTool.typeMatching(type, key, code).parse();
}

@RouteMapping(value = "/:type/:key", method = RouteMethod.GET, order = 1)
public Future<Void> parseKey(HttpServerResponse response, String type, String key) {
Expand All @@ -69,14 +79,4 @@ public Future<Void> parseKey(HttpServerResponse response, String type, String ke
return promise.future();
}

@RouteMapping(value = "/json/:type/:key", method = RouteMethod.GET, order = 2)
public Future<String> parseKeyJson(String type, String key) {
String code = "";
if (key.contains("@")) {
String[] keys = key.split("@");
key = keys[0];
code = keys[1];
}
return IPanTool.typeMatching(type, key, code).parse();
}
}
19 changes: 19 additions & 0 deletions web-service/src/main/resources/http-tools/pan-ce.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
###
https://5jmpj3-my.sharepoint.com/personal/pan2_xiaomuxi_cn/_layouts/15/download.aspx?UniqueId=cf123281-44cd-4745-b3c3-49a18934044d&Translate=false&tempauth=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTBmZjEtY2UwMC0wMDAwMDAwMDAwMDAvNWptcGozLW15LnNoYXJlcG9pbnQuY29tQGY4MTk4OWJiLWViNDAtNGZhYi05NzA5LTQ0ODFhMDM0ZjNiNCIsImlzcyI6IjAwMDAwMDAzLTAwMDAtMGZmMS1jZTAwLTAwMDAwMDAwMDAwMCIsIm5iZiI6IjE3MDY0MzIyNDciLCJleHAiOiIxNzA2NDM1ODQ3IiwiZW5kcG9pbnR1cmwiOiJNMWVwZ3VjamFKU081MXB4WW5IKzZ6bzZBQlVyc0N1T3MwOVRGbnZJVlRvPSIsImVuZHBvaW50dXJsTGVuZ3RoIjoiMTQ2IiwiaXNsb29wYmFjayI6IlRydWUiLCJjaWQiOiJKM0JzNzloTy8wYW1GZGh1WUFjTjR3PT0iLCJ2ZXIiOiJoYXNoZWRwcm9vZnRva2VuIiwic2l0ZWlkIjoiWkRkaVptRTBNRFl0TXpWall5MDBZamMxTFRsbU16TXRNRGc0TlRCbVkyRmlPVE0yIiwiYXBwX2Rpc3BsYXluYW1lIjoiMuWPt-WtmOWCqOehrOebmCIsImdpdmVuX25hbWUiOiIy5Y-3IiwiZmFtaWx5X25hbWUiOiLnvZHnm5giLCJhcHBpZCI6ImJkZDRjOTA5LTA0ZjItNDU4NS04MjZlLTY0MDQzNDljN2JiZiIsInRpZCI6ImY4MTk4OWJiLWViNDAtNGZhYi05NzA5LTQ0ODFhMDM0ZjNiNCIsInVwbiI6InBhbjJAeGlhb211eGkuY24iLCJwdWlkIjoiMTAwMzIwMDJBRTUyNDMwRCIsImNhY2hla2V5IjoiMGguZnxtZW1iZXJzaGlwfDEwMDMyMDAyYWU1MjQzMGRAbGl2ZS5jb20iLCJzY3AiOiJhbGxmaWxlcy53cml0ZSIsInR0IjoiMiIsImlwYWRkciI6IjIwLjE5MC4xNDQuMTcxIn0.WY--gv_Ac1pwhj3XTOdIddaj643CHoOqBeFFpdSa4-w&ApiVersion=2.0

###
#@no-redirect
PUT https://pan.xiaomuxi.cn/api/v3/share/download/Ag4Uy

###
PUT https://pan.huang1111.cn/api/v3/share/download/m1Mlt1


###
https://pan.huang1111.cn/api/v3/share/info/g31PcQ?password=qaiu

###
https://pan.huang1111.cn/api/v3/share/info/m1Mlt1?password=

###
PUT https://pan.huang1111.cn/api/v3/share/download/g31PcQ?path=undefined%2Fundefined
Loading

0 comments on commit 068efd0

Please sign in to comment.