Compare commits

...

51 Commits

Author SHA1 Message Date
QAIU
4a3e734408 1. onedrive
常规测试
2024-12-18 11:46:06 +08:00
qaiu
54cc212753 Merge pull request #78 from xrgzs/add-ghcr
增加 ghcr.io 容器构建
2024-12-17 16:24:03 +08:00
xrgzs
f4ae1eaa51 PR时不更新依赖图 2024-12-17 16:15:59 +08:00
xrgzs
d2537282c9 增加 ghcr.io 容器构建 2024-12-17 15:47:05 +08:00
QAIU
87527688c3 1. 代理配置 2024-12-17 15:21:59 +08:00
qaiu
2be0b6505a 更新 P115Tool.java
UA问题说明
2024-12-17 09:37:48 +08:00
QAIU
672f100c7c 1. 动态UA 2024-12-16 19:01:55 +08:00
QAIU
5af402c0c5 1. 动态UA 2024-12-16 18:52:02 +08:00
QAIU
693a4f0f63 1. P115网盘解析BUG
2. 完善onedrive支持
2024-12-16 15:54:06 +08:00
QAIU
f8d2426ff6 API 2024-12-16 13:19:15 +08:00
QAIU
973a9bedcd 添加115网盘支持(测试中)#75 2024-12-16 13:15:53 +08:00
QAIU
a583733400 修复小飞机解析失败 2024-12-16 12:31:34 +08:00
QAIU
78eb51b3ca 处理编译失败问题 2024-11-29 11:50:44 +08:00
QAIU
a2606be9d8 修复蓝奏优享#71 2024-11-26 13:02:02 +08:00
qaiu
a4975c72ce Merge pull request #70 from qaiu/dependabot/npm_and_yarn/web-front/eslint/plugin-kit-0.2.3
Bump @eslint/plugin-kit from 0.2.2 to 0.2.3 in /web-front
2024-11-18 12:12:25 +08:00
dependabot[bot]
58f96822a4 Bump @eslint/plugin-kit from 0.2.2 to 0.2.3 in /web-front
Bumps [@eslint/plugin-kit](https://github.com/eslint/rewrite) from 0.2.2 to 0.2.3.
- [Release notes](https://github.com/eslint/rewrite/releases)
- [Changelog](https://github.com/eslint/rewrite/blob/main/release-please-config.json)
- [Commits](https://github.com/eslint/rewrite/compare/plugin-kit-v0.2.2...plugin-kit-v0.2.3)

---
updated-dependencies:
- dependency-name: "@eslint/plugin-kit"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-15 21:50:27 +00:00
qaiu
96b0d94986 Update README.md 2024-11-13 13:59:54 +08:00
QAIU
70b38db8c5 IP互助计划, 添加正向代理服务(TODO) 2024-11-12 19:05:43 +08:00
QAIU
b6a9c2d3a0 . 2024-11-07 18:37:08 +08:00
QAIU
a01df6c7db web file package config 2024-11-07 12:34:24 +08:00
QAIU
4455bee570 pod update 2024-11-05 18:42:32 +08:00
qaiu
cd0adef2ed Merge pull request #67 from qaiu/dependabot/npm_and_yarn/web-front/http-proxy-middleware-2.0.7
Bump http-proxy-middleware from 2.0.6 to 2.0.7 in /web-front
2024-11-04 19:13:24 +08:00
dependabot[bot]
4aa24a65fb Bump http-proxy-middleware from 2.0.6 to 2.0.7 in /web-front
Bumps [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware) from 2.0.6 to 2.0.7.
- [Release notes](https://github.com/chimurai/http-proxy-middleware/releases)
- [Changelog](https://github.com/chimurai/http-proxy-middleware/blob/v2.0.7/CHANGELOG.md)
- [Commits](https://github.com/chimurai/http-proxy-middleware/compare/v2.0.6...v2.0.7)

---
updated-dependencies:
- dependency-name: http-proxy-middleware
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-04 10:58:07 +00:00
QAIU
760dca8772 升级vue3 2024-11-04 18:56:49 +08:00
QAIU
8269673619 1. add iCloud解析 2024-11-04 14:18:56 +08:00
qaiu
82ec586554 手残 又不小心提交了 ads代码 2024-11-02 18:59:33 +08:00
qaiu
ca98cc8708 里程碑版本前奏: 1. 添加google云盘解析(需要联网), 2. web页面人工智障自动解析URL, 3. 优化一堆细节问题, 4: git换行配置(待验证), 5. 酷我解析可用 2024-11-02 18:58:15 +08:00
QAIU
f07800985d 1. 优化123pan日志, 2. 微博短链测试, 3. 分享类添加其他参数Map(Cookie支持准备) 2024-11-01 18:18:29 +08:00
qaiu
b042df93b7 更新 urltool.py 2024-10-29 18:59:23 +08:00
QAIU
ecf4441946 .. 2024-10-29 18:36:51 +08:00
QAIU
39b2612840 .. 2024-10-28 18:59:18 +08:00
QAIU
218f486e6b .. 2024-10-28 18:58:37 +08:00
QAIU
cfcc25f175 add onedrive 2024-10-28 18:57:26 +08:00
qaiu
155e88223c 0.0 前端优化,302标识短链添加/d前缀 2024-10-28 14:36:39 +08:00
QAIU
05039ece51 add 118, 微雨云 2024-10-26 16:04:49 +08:00
QAIU
1c673f2b46 idea run Main. 2024-10-25 18:18:42 +08:00
QAIU
2232a70228 Merge remote-tracking branch 'origin/main' 2024-10-25 18:18:34 +08:00
QAIU
e661b1d817 idea run Main. 2024-10-25 18:18:17 +08:00
qaiu
5a6a65f580 Update README.md 2024-10-25 14:54:19 +08:00
qaiu
5cdd3bcd30 Update README.md 2024-10-25 14:52:36 +08:00
qaiu
1233a885b8 Update README.md 2024-10-25 14:49:09 +08:00
QAIU
adf56cd768 add 酷狗音乐, 酷我音乐, 网易云音乐, QQ音乐 2024-10-25 14:38:57 +08:00
QAIU
cd4b208be9 一处SQL语法错误 2024-10-24 10:48:36 +08:00
QAIU
502de1a5d0 0..0 2024-10-23 18:08:10 +08:00
qaiu
4158f869a3 0.0 2024-10-23 18:04:34 +08:00
QAIU
ff569d339c 1. add music parser 2024-10-21 19:14:29 +08:00
QAIU
10eec323dd 1. add 网易云音乐解析 2024-10-20 18:16:51 +08:00
qaiu
0a3db51c7d 更新 app-dev.yml 蓝奏设置合理缓存时间 2024-10-11 08:15:10 +08:00
qaiu
229aee0b30 Update README.md 2024-10-09 15:38:29 +08:00
QAIU
44714aa981 1. add 城通网盘解析(慢速) https://www.ctfile.com
2. 优化解析接口的实现
2024-10-09 15:33:33 +08:00
qaiu
2b6138a889 前端打包说明 2024-10-08 03:01:29 +08:00
111 changed files with 9843 additions and 17955 deletions

8
.gitattributes vendored Normal file
View File

@@ -0,0 +1,8 @@
# 文本文件使用 LF 换行符,适用于 Linux 和 macOS
*.sh text eol=lf
*.service text eol=lf
# Windows 执行的文件使用 CRLF 换行符
*.bat text eol=crlf
*.cmd text eol=crlf
bin/nfd-service-template.xml text eol=crlf

View File

@@ -11,6 +11,7 @@ name: Java CI with Maven
# The API requires write permission on the repository to submit dependencies
permissions:
contents: write
packages: write
on:
push:
@@ -25,21 +26,56 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'yarn'
cache-dependency-path: 'web-front/yarn.lock'
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build Frontend
run: cd web-front && yarn install && yarn run build
- name: Build with Maven
run: mvn -B package --file pom.xml
# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
- name: Update dependency graph
uses: advanced-security/maven-dependency-submission-action@v3
if: github.event_name != 'pull_request'
with:
ignore-maven-wrapper: true
# - uses: release-drafter/release-drafter@v5
# env:
# GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
path: web-service/target/netdisk-fast-download-bin.zip
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ github.sha }}
ghcr.io/${{ github.repository }}:main

15
.run/AppMain.run.xml Normal file
View File

@@ -0,0 +1,15 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="AppMain" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="cn.qaiu.lz.AppMain" />
<module name="web-service" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="cn.qaiu.lz.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

14
Dockerfile Normal file
View File

@@ -0,0 +1,14 @@
FROM eclipse-temurin:17-alpine
WORKDIR /app
COPY ./web-service/target/netdisk-fast-download-bin.zip .
RUN unzip netdisk-fast-download-bin.zip && \
mv netdisk-fast-download/* ./ && \
rm netdisk-fast-download-bin.zip && \
chmod +x run.sh
EXPOSE 6400 6401
ENTRYPOINT ["sh", "run.sh"]

View File

@@ -11,7 +11,7 @@ main分支依赖JDK17, 提供了JDK11分支[main-jdk11](https://github.com/qaiu/
## 项目介绍
网盘直链解析工具能把网盘分享下载链接转化为直链,已支持蓝奏云/蓝奏云优享/奶牛快传/移动云云空间/小飞机盘/亿方云/123云盘/Cloudreve等支持加密分享。
**20240929 1k Star留念0.1.8版本json接口格式有调整尤其依赖lz.qaiu.top做下载服务的朋友们记得修改 参考json返回数据格式示例**
**0.1.8及以上版本json接口格式有调整尤其依赖lz.qaiu.top做下载服务的朋友们记得修改 参考json返回数据格式示例**
*重要声明:本项目仅供学习参考;请不要将此项目用于任何商业用途,否则可能带来严重的后果。转发/分享该项目请注明来源*
@@ -34,15 +34,15 @@ main分支依赖JDK17, 提供了JDK11分支[main-jdk11](https://github.com/qaiu/
- [联想乐云 (le)](https://lecloud.lenovo.com/)
- [QQ邮箱文件中转站 (qq)](https://mail.qq.com/)
- [超星网盘-开发中 (cx)](https://passport2.chaoxing.com/login?newversion=true&refer=https%3A%2F%2Fpan-yz.chaoxing.com%2F)
- [Cloudreve自建网盘--正在优化 (ce)](https://github.com/cloudreve/Cloudreve)
**TODO:**
- 登录接口, 文件上传/下载/分享后端接口
- 短地址服务
- 前端界面(建设中...)
- [城通网盘(ct)](https://www.ctfile.com)
- [网易云音乐(mne)](https://music.163.com)
- [Cloudreve自建网盘(ce)](https://github.com/cloudreve/Cloudreve)
### API接口说明
your_host指的是您的域名或者IP实际使用时替换为实际域名或者IP端口默认6400可以使用nginx代理来做域名访问。
解析方式分为两种类型直接跳转下载文件和获取下载链接,每一种都提供了两种接口形式parser和网盘标志/分享key拼接的短地址标志短链所有规则参考示例。
your_host指的是您的域名或者IP实际使用时替换为实际域名或者IP端口默认6400可以使用nginx代理来做域名访问。
解析方式分为两种类型直接跳转下载文件和获取下载链接,
每一种都提供了两种接口形式: `通用接口parser?url=``网盘标志/分享key拼接的短地址标志短链`,所有规则参考示例。
- 通用接口: `/parser?url=分享链接`加密分享需要加上参数pwd=密码;
- 标志短链: `/网盘标识/分享key` 在分享Key后面加上@密码;
- 直链JSON: `通用接口``标志短链`前加上`/json` 加密分享的密码规则同上;
@@ -62,7 +62,11 @@ API规则:
http://your_host/json/网盘标识/分享key@分享密码
```
json返回数据格式示例:
json返回数据格式示例:
`shareKey`: 全局分享key
`directLink`: 下载链接
`cacheHit`: 是否为缓存链接
`expires`: 缓存到期时间
```json
{
"code": 200,
@@ -149,6 +153,31 @@ mvn package
```
打包好的文件位于 web-service/target/netdisk-fast-download-bin.zip
## Linux服务部署
### Docker 部署Main分支
```shell
# 创建目录
mkdir -p netdisk-fast-download
cd netdisk-fast-download
# 拉取镜像
docker pull ghcr.io/qaiu/netdisk-fast-download:main
# 复制配置文件或下载仓库web-service\src\main\resources
docker create --name netdisk-fast-download ghcr.io/qaiu/netdisk-fast-download:main
docker cp netdisk-fast-download:/app/resources ./resources
docker rm netdisk-fast-download
# 启动容器
docker run -d -it --name netdisk-fast-download -p 6401:6401 --restart unless-stopped -e TZ=Asia/Shanghai -v ./resources:/app/resources -v ./db:/app/db -v ./logs:/app/logs ghcr.io/qaiu/netdisk-fast-download:main
# 反代6401端口
# 升级容器
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --cleanup --run-once netdisk-fast-download
```
### [宝塔安装参考](https://blog.qaiu.top/archives/netdisk-fast-download-bao-ta-an-zhuang-jiao-cheng)
> 注意: netdisk-fast-download.service中的ExecStart的路径改为实际路径
```shell
@@ -185,12 +214,20 @@ bash service-install.sh
如果不想使用服务运行可以直接运行run.bat
> 注意: 如果jdk环境变量的java版本不是17请修改nfd-service-template.xml中的java命令的路径改为实际路径
## 0.1.8 开发计划
- Docker部署
- 联想乐云解析 √
- 直链缓存 √
- 日志优化 √
## 相关配置说明
resources目录下包含服务端配置文件 配置文件自带说明,具体请查看配置文件内容,
app-dev.yml 可以配置解析服务相关信息, 包括端口,域名,缓存时长等
server-proxy.yml 可以配置代理服务运行的相关信息, 包括前端反向代理端口,路径等
## 0.1.9 开发计划
- 超星网盘解析 doing
- 带Referer头的js请求下载 doing
- 城通网盘解析 √
- 目录解析(专属版)
- 带cookie/token参数解析大文件(专属版)
- docker
**技术栈:**
Jdk17+Vert.x4.4.1
@@ -203,7 +240,8 @@ Core模块集成Vert.x实现类似spring的注解式路由API
## 支持该项目
开源不易,用爱发电,本项目长期维护如果觉得有帮助, 可以请作者喝杯咖啡, 感谢支持
开源不易,用爱发电,本项目长期维护如果觉得有帮助, 可以请作者喝杯咖啡, 感谢支持
赞助88元以上, 可以优先体验专享版--大文件解析,目录解析
![image](https://github.com/qaiu/netdisk-fast-download/assets/29825328/54276aee-cc3f-4ebd-8973-2e15f6295819)
[手机端支付宝打赏跳转链接](https://qr.alipay.com/fkx01882dnoxxtjenhlxt53)

View File

@@ -60,12 +60,6 @@
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.melloware/commons-beanutils2 -->
<dependency>
<groupId>com.melloware</groupId>
<artifactId>commons-beanutils2</artifactId>
<version>${commons-beanutils2.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
@@ -82,6 +76,12 @@
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -90,6 +90,13 @@
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<!-- 代码生成器 -->
<annotationProcessors>
<annotationProcessor>io.vertx.codegen.CodeGenProcessor</annotationProcessor>
</annotationProcessors>
<generatedSourcesDirectory>
${project.basedir}/src/main/generated
</generatedSourcesDirectory>
</configuration>
</plugin>
</plugins>

View File

@@ -1,11 +1,13 @@
package cn.qaiu.vx.core;
import cn.qaiu.vx.core.util.CommonUtil;
import cn.qaiu.vx.core.util.ConfigUtil;
import cn.qaiu.vx.core.util.VertxHolder;
import cn.qaiu.vx.core.verticle.ReverseProxyVerticle;
import cn.qaiu.vx.core.verticle.RouterVerticle;
import cn.qaiu.vx.core.verticle.ServiceVerticle;
import io.vertx.core.*;
import io.vertx.core.dns.AddressResolverOptions;
import io.vertx.core.impl.launcher.commands.VersionCommand;
import io.vertx.core.json.JsonObject;
import io.vertx.core.shareddata.LocalMap;
@@ -101,7 +103,7 @@ public final class Deploy {
""";
System.out.printf(logoTemplate,
conf.getString("version_app"),
CommonUtil.getAppVersion(),
VersionCommand.getVersion(),
conf.getString("copyright"),
year
@@ -121,6 +123,12 @@ public final class Deploy {
var vertxOptions = vertxConfigELPS == 0 ?
new VertxOptions() : new VertxOptions(vertxConfig);
vertxOptions.setAddressResolverOptions(
new AddressResolverOptions().
addServer("114.114.114.114").
addServer("114.114.115.115").
addServer("8.8.8.8").
addServer("8.8.4.4"));
LOGGER.info("vertxConfigEventLoopPoolSize: {}, eventLoopPoolSize: {}, workerPoolSize: {}", vertxConfigELPS,
vertxOptions.getEventLoopPoolSize(),
vertxOptions.getWorkerPoolSize());
@@ -185,7 +193,7 @@ public final class Deploy {
private DeploymentOptions getWorkDeploymentOptions(String name, int ins) {
return new DeploymentOptions()
.setWorkerPoolName(name)
.setWorker(true)
.setThreadingModel(ThreadingModel.WORKER)
.setInstances(ins);
}

View File

@@ -0,0 +1,7 @@
/**
* ModuleGen cn.qaiu.vx.core
*/
@ModuleGen(name = "vertx-http-proxy", groupPackage = "cn.qaiu.vx.core", useFutures = true)
package cn.qaiu.vx.core;
import io.vertx.codegen.annotations.ModuleGen;

View File

@@ -3,8 +3,6 @@ package cn.qaiu.vx.core.util;
import cn.qaiu.vx.core.annotaions.HandleSortFilter;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.JsonObject;
import org.apache.commons.beanutils2.ConvertUtils;
import org.apache.commons.beanutils2.Converter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -16,6 +14,7 @@ import java.net.URL;
import java.net.UnknownHostException;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.stream.Collectors;
@@ -99,23 +98,6 @@ public class CommonUtil {
return data;
}
/**
* 注册枚举转换器
*
* @param enums 枚举类
*/
@SafeVarargs
@SuppressWarnings({"unchecked", "rawtypes"})
public static void enumConvert(Class<? extends Enum>... enums) {
for (Class<? extends Enum> anEnum : enums) {
ConvertUtils.register(new Converter() {
public Object convert(Class type, Object value) {
return Enum.valueOf(anEnum, (String) value);
}
}, anEnum);
}
}
/**
* 处理其他配置
*
@@ -158,4 +140,21 @@ public class CommonUtil {
}
}).collect(Collectors.toSet());
}
private static String appVersion;
public static String getAppVersion() {
if (null == appVersion) {
Properties properties = new Properties();
try {
properties.load(CommonUtil.class.getClassLoader().getResourceAsStream("app.properties"));
if (!properties.isEmpty()) {
appVersion = properties.getProperty("app.version");
}
} catch (IOException e) {
e.printStackTrace();
}
}
return appVersion;
}
}

View File

@@ -7,6 +7,8 @@ public interface ConfigConstant {
String LOCAL = "local";
String SERVER = "server";
String CACHE = "cache";
String PROXY = "proxy";
String GLOBAL_CONFIG = "globalConfig";
String CUSTOM_CONFIG = "customConfig";
String ASYNC_SERVICE_INSTANCES = "asyncServiceInstances";

View File

@@ -0,0 +1,46 @@
package cn.qaiu.vx.core.util;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
import io.vertx.core.json.jackson.DatabindCodec;
import org.slf4j.LoggerFactory;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
/**
* @author <a href="https://qaiu.top">QAIU</a>
* @date 2023/10/14 9:07
*/
public class JacksonConfig {
static {
// 通过该方法对mapper对象进行设置所有序列化的对象都将按改规则进行系列化
// Include.Include.ALWAYS 默认
// Include.NON_DEFAULT 属性为默认值不序列化
// Include.NON_EMPTY 属性为 空("" 或者为 NULL 都不序列化则返回的json是没有这个字段的。这样对移动端会更省流量
// Include.NON_NULL 属性为NULL 不序列化,就是为null的字段不参加序列化
// objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
ObjectMapper objectMapper = DatabindCodec.mapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JavaTimeModule javaTimeModule = new JavaTimeModule();
javaTimeModule.addDeserializer(LocalDateTime.class,
new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
javaTimeModule.addDeserializer(LocalDate.class,
new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
javaTimeModule.addDeserializer(LocalTime.class,
new LocalTimeDeserializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
objectMapper.registerModule(javaTimeModule);
LoggerFactory.getLogger(JacksonConfig.class).info("Global JacksonConfig complete.");
}
public static void nothing() {}
}

View File

@@ -1,11 +1,10 @@
package cn.qaiu.vx.core.util;
import io.vertx.core.MultiMap;
import org.apache.commons.beanutils2.BeanUtils;
import io.vertx.core.json.JsonObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
@@ -18,29 +17,21 @@ import java.util.Map;
public final class ParamUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(ParamUtil.class);
public static Map<String, String> multiMapToMap(MultiMap multiMap) {
public static Map<String, Object> multiMapToMap(MultiMap multiMap) {
if (multiMap == null) return null;
Map<String, String> map = new HashMap<>();
Map<String, Object> map = new HashMap<>();
for (Map.Entry<String, String> entry : multiMap.entries()) {
map.put(entry.getKey(), entry.getValue());
}
return map;
}
public static <T> T multiMapToEntity(MultiMap multiMap, Class<T> tClass) throws NoSuchMethodException {
Map<String, String> map = multiMapToMap(multiMap);
T obj = null;
try {
obj = tClass.getDeclaredConstructor().newInstance();
BeanUtils.populate(obj, map);
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
LOGGER.error("实例化异常");
} catch (InvocationTargetException e2) {
e2.printStackTrace();
LOGGER.error("map2bean转换异常");
public static <T> T multiMapToEntity(MultiMap multiMap, Class<T> tClass) {
Map<String, Object> map = multiMapToMap(multiMap);
if (map == null) {
return null;
}
return obj;
return new JsonObject(map).mapTo(tClass);
}
public static MultiMap paramsToMap(String paramString) {

View File

@@ -0,0 +1,184 @@
package cn.qaiu.vx.core.verticle;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
import io.vertx.core.dns.AddressResolverOptions;
import io.vertx.core.http.*;
import io.vertx.core.net.NetClient;
import io.vertx.core.net.NetClientOptions;
import io.vertx.core.net.NetSocket;
import io.vertx.core.net.ProxyOptions;
import java.util.Base64;
/**
*
*/
public class HttpProxyVerticle extends AbstractVerticle {
private HttpClient httpClient;
private NetClient netClient;
@Override
public void start() {
ProxyOptions proxyOptions = new ProxyOptions().setHost("127.0.0.1").setPort(7890);
// 初始化 HTTP 客户端,用于向目标服务器发送 HTTP 请求
HttpClientOptions httpClientOptions = new HttpClientOptions();
httpClient = vertx.createHttpClient(httpClientOptions.setProxyOptions(proxyOptions));
// 创建并启动 HTTP 代理服务器,监听指定端口
HttpServer server = vertx.createHttpServer(new HttpServerOptions().setClientAuth(ClientAuth.REQUIRED));
server.requestHandler(this::handleClientRequest);
// 初始化 NetClient用于在 CONNECT 请求中建立 TCP 连接隧道
netClient = vertx.createNetClient(new NetClientOptions()
.setProxyOptions(proxyOptions)
.setConnectTimeout(15000)
.setTrustAll(true));
// 启动 HTTP 代理服务器
server.listen(7891, ar -> {
if (ar.succeeded()) {
System.out.println("HTTP Proxy server started on port 7891");
} else {
System.err.println("Failed to start HTTP Proxy server: " + ar.cause());
}
});
}
// 处理 HTTP CONNECT 请求,用于代理 HTTPS 流量
private void handleConnectRequest(HttpServerRequest clientRequest) {
String[] uriParts = clientRequest.uri().split(":");
if (uriParts.length != 2) {
clientRequest.response().setStatusCode(400).end("Bad Request: Invalid URI format");
return;
}
// 解析目标主机和端口
String targetHost = uriParts[0];
int targetPort;
try {
targetPort = Integer.parseInt(uriParts[1]);
} catch (NumberFormatException e) {
clientRequest.response().setStatusCode(400).end("Bad Request: Invalid port");
return;
}
clientRequest.pause();
// 通过 NetClient 连接目标服务器并创建隧道
netClient.connect(targetPort, targetHost, connectionAttempt -> {
if (connectionAttempt.succeeded()) {
NetSocket targetSocket = connectionAttempt.result();
// 升级客户端连接到 NetSocket 并实现双向数据流
clientRequest.toNetSocket().onComplete(clientSocketAttempt -> {
if (clientSocketAttempt.succeeded()) {
NetSocket clientSocket = clientSocketAttempt.result();
// 设置双向数据流转发
clientSocket.handler(targetSocket::write);
targetSocket.handler(clientSocket::write);
// 关闭其中一方时关闭另一方
clientSocket.closeHandler(v -> targetSocket.close());
targetSocket.closeHandler(v -> clientSocket.close());
} else {
System.err.println("Failed to upgrade client connection to socket: " + clientSocketAttempt.cause().getMessage());
targetSocket.close();
clientRequest.response().setStatusCode(500).end("Internal Server Error");
}
});
} else {
System.err.println("Failed to connect to target: " + connectionAttempt.cause().getMessage());
clientRequest.response().setStatusCode(502).end("Bad Gateway: Unable to connect to target");
}
});
}
// 处理客户端的 HTTP 请求
private void handleClientRequest(HttpServerRequest clientRequest) {
String s = clientRequest.headers().get("Proxy-Authorization");
if (s == null) {
clientRequest.response().setStatusCode(403).end();
return;
}
String[] split = new String(Base64.getDecoder().decode(s.replace("Basic ", ""))).split(":");
if (split.length > 1) {
System.out.println(split[0]);
System.out.println(split[1]);
// TODO
}
if (clientRequest.method() == HttpMethod.CONNECT) {
// 处理 CONNECT 请求
handleConnectRequest(clientRequest);
} else {
// 处理普通的 HTTP 请求
handleHttpRequest(clientRequest);
}
}
// 处理 HTTP 请求,转发至目标服务器并返回响应
private void handleHttpRequest(HttpServerRequest clientRequest) {
// 获取目标主机
String hostHeader = clientRequest.getHeader("Host");
if (hostHeader == null) {
clientRequest.response().setStatusCode(400).end("Host header is missing");
return;
}
String targetHost = hostHeader.split(":")[0];
int targetPort = 80; // 默认为 HTTP 的端口
clientRequest.pause(); // 暂停客户端请求的读取,避免数据丢失
httpClient.request(clientRequest.method(), targetPort, targetHost, clientRequest.uri())
.onSuccess(request -> {
clientRequest.resume(); // 恢复客户端请求的读取
// 逐个设置请求头
clientRequest.headers().forEach(header -> request.putHeader(header.getKey(), header.getValue()));
// 将客户端请求的 body 转发给目标服务器
clientRequest.bodyHandler(body -> request.send(body, ar -> {
if (ar.succeeded()) {
var response = ar.result();
clientRequest.response().setStatusCode(response.statusCode());
clientRequest.response().headers().setAll(response.headers());
response.body().onSuccess(b-> clientRequest.response().end(b));
} else {
clientRequest.response().setStatusCode(502).end("Bad Gateway: Unable to reach target");
}
}));
})
.onFailure(err -> {
err.printStackTrace();
clientRequest.response().setStatusCode(502).end("Bad Gateway: Request failed");
});
}
@Override
public void stop() {
// 停止 HTTP 客户端以释放资源
if (httpClient != null) {
httpClient.close();
}
}
/**
* TODO add Deploy
* @param args
*/
public static void main(String[] args) {
// 配置 DNS 解析器,使用多个 DNS 服务器来提升解析速度
Vertx vertx = Vertx.vertx(new VertxOptions()
.setAddressResolverOptions(new AddressResolverOptions()
.addServer("114.114.114.114")
.addServer("114.114.115.115")
.addServer("8.8.8.8")
.addServer("8.8.4.4")));
// 部署 Verticle 并启动动态 HTTP 代理服务器
vertx.deployVerticle(new HttpProxyVerticle());
}
}

View File

@@ -48,8 +48,9 @@ public class ReverseProxyVerticle extends AbstractVerticle {
@Override
public void start(Promise<Void> startPromise) throws Exception {
public void start(Promise<Void> startPromise) {
CONFIG.onSuccess(this::handleProxyConfList);
// createFileListener
startPromise.complete();
}
@@ -116,9 +117,7 @@ public class ReverseProxyVerticle extends AbstractVerticle {
}
// Send page404 page
proxyRouter.errorHandler(404, ctx -> {
ctx.response().sendFile(proxyConf.getString("page404"));
});
proxyRouter.errorHandler(404, ctx -> ctx.response().sendFile(proxyConf.getString("page404")));
HttpServer server = getHttpsServer(proxyConf);
server.requestHandler(proxyRouter);
@@ -212,7 +211,7 @@ public class ReverseProxyVerticle extends AbstractVerticle {
port = 80;
}
String originPath = url.getPath();
LOGGER.info("Conf(path, originPath, host, port) ----> {},{},{},{}", path, originPath, host, port);
LOGGER.info("path {}, originPath {}, to {}:{}", path, originPath, host, port);
// 注意这里不能origin多个代理地址, 一个实例只能代理一个origin
final HttpProxy httpProxy = HttpProxy.reverseProxy(httpClient);

View File

@@ -2,6 +2,7 @@ package cn.qaiu.vx.core.verticle;
import cn.qaiu.vx.core.handlerfactory.RouterHandlerFactory;
import cn.qaiu.vx.core.util.CommonUtil;
import cn.qaiu.vx.core.util.JacksonConfig;
import cn.qaiu.vx.core.util.SharedDataUtil;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;
@@ -30,6 +31,8 @@ public class RouterVerticle extends AbstractVerticle {
private HttpServer server;
static {
LOGGER.info(JacksonConfig.class.getSimpleName() + " >> ");
JacksonConfig.nothing();
LOGGER.info("To start listening to port {} ......", port);
}

View File

@@ -0,0 +1,89 @@
package cn.qaiu.vx.core.verticle.conf;
import io.vertx.codegen.annotations.DataObject;
import io.vertx.codegen.json.annotations.JsonGen;
import io.vertx.core.json.JsonObject;
import io.vertx.core.net.ProxyOptions;
import java.util.UUID;
@DataObject
@JsonGen(publicConverter = false)
public class HttpProxyConf {
public static final String DEFAULT_USERNAME = UUID.randomUUID().toString();
public static final String DEFAULT_PASSWORD = UUID.randomUUID().toString();
public static final Integer DEFAULT_PORT = 6402;
public static final Integer DEFAULT_TIMEOUT = 15000;
Integer timeout;
String username;
String password;
Integer port;
ProxyOptions preProxyOptions;
public HttpProxyConf() {
this.username = DEFAULT_USERNAME;
this.password = DEFAULT_PASSWORD;
this.timeout = DEFAULT_PORT;
this.timeout = DEFAULT_TIMEOUT;
this.preProxyOptions = new ProxyOptions();
}
public HttpProxyConf(JsonObject json) {
this();
}
public Integer getTimeout() {
return timeout;
}
public HttpProxyConf setTimeout(Integer timeout) {
this.timeout = timeout;
return this;
}
public String getUsername() {
return username;
}
public HttpProxyConf setUsername(String username) {
this.username = username;
return this;
}
public String getPassword() {
return password;
}
public HttpProxyConf setPassword(String password) {
this.password = password;
return this;
}
public Integer getPort() {
return port;
}
public HttpProxyConf setPort(Integer port) {
this.port = port;
return this;
}
public ProxyOptions getPreProxyOptions() {
return preProxyOptions;
}
public HttpProxyConf setPreProxyOptions(ProxyOptions preProxyOptions) {
this.preProxyOptions = preProxyOptions;
return this;
}
}

View File

@@ -0,0 +1 @@
app.version=${project.version}

View File

@@ -20,11 +20,11 @@ Cloudreve自建网盘 (ce) {origin}/s/{shareKey}
缓存key -> 下载URL
分享链接 -> add 网盘类型 pwd origin(私有化) -> 直链
https://f.ws59.cn/f/e3peohu6192
开源版 TODO
1. 缓存优化, 配置自动重载
2. 缓存删除接口(后台功能)
3. JS脚本引擎 自定义解析
专属版 功能设计
@@ -32,3 +32,35 @@ https://f.ws59.cn/f/e3peohu6192
2. 流量统计, 文件分享信息, 目录解析, 文件云下载
3. IP代理池
网页跳转 防盗链
可禁用parser接口
标志短链 鉴权后 生成混淆链接
短链算法:
1. 基于Hash映射 hash(type:key:pwd) = h/xxxxx
鉴权实现:
auth-jdbc
// 基于标准SQL语法
支持H2, MySQL
用户:
jwt鉴权用户
角色:
超级管理员
注册用户
定义操作(权限):
用户的创建/删除/查询/修改, 生成短链/删除短链/修改解析次数和有效期/查询短链信息(
文件信息: 文件/文件夹, 文件数量, 文件大小, 文件类型; 链接信息: 解析次数, 缓存次数等)
微服务设计:

View File

@@ -10,6 +10,11 @@
</parent>
<artifactId>parser</artifactId>
<packaging>jar</packaging>
<name>${project.groupId}:${project.artifactId}</name>
<description>NFD parser</description>
<url>https://qaiu.top</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@@ -46,10 +51,39 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<licenses>
<license>
<name>MIT License</name>
<url>https://opensource.org/license/mit</url>
</license>
</licenses>
<developers>
<developer>
<name>qaiu</name>
<email>qaiu00@gmail.com</email>
<organization>https://qaiu.top</organization>
</developer>
</developers>
<scm>
<connection>scm:git@github.com:qaiu/netdisk-fast-download.git</connection>
<developerConnection>scm:git@github.com:qaiu/netdisk-fast-download.git</developerConnection>
<url>git@github.com:qaiu/netdisk-fast-download.git</url>
</scm>
<distributionManagement>
<snapshotRepository>
<id>sonatype</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>sonatype</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<build>
<plugins>
@@ -62,6 +96,49 @@
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<id>attach-sources</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<!-- Gpg Signature -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.6.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
<autoPublish>true</autoPublish>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,146 @@
package cn.qaiu.entity;
import java.util.Map;
public class FileInfo {
/**
* 文件名
*/
String fileName;
/**
* 文件ID
*/
String fileId;
/**
* 文件大小(byte)
*/
Long size;
/**
* MIME类型
*/
String fileMIME;
/**
* 文件路径
*/
String filePath;
/**
* 创建(上传)时间 yyyy-MM-dd HH:mm:ss格式
*/
String createTime;
/**
* 创建者
*/
String createBy;
/**
* 文件描述
*/
String description;
/**
* 下载次数
*/
Integer downloadCount;
/**
* 扩展参数
*/
Map<String, Object> extParameters;
public String getFileName() {
return fileName;
}
public FileInfo setFileName(String fileName) {
this.fileName = fileName;
return this;
}
public String getFileId() {
return fileId;
}
public FileInfo setFileId(String fileId) {
this.fileId = fileId;
return this;
}
public Long getSize() {
return size;
}
public FileInfo setSize(Long size) {
this.size = size;
return this;
}
public String getFileMIME() {
return fileMIME;
}
public FileInfo setFileMIME(String fileMIME) {
this.fileMIME = fileMIME;
return this;
}
public String getFilePath() {
return filePath;
}
public FileInfo setFilePath(String filePath) {
this.filePath = filePath;
return this;
}
public String getCreateTime() {
return createTime;
}
public FileInfo setCreateTime(String createTime) {
this.createTime = createTime;
return this;
}
public String getCreateBy() {
return createBy;
}
public FileInfo setCreateBy(String createBy) {
this.createBy = createBy;
return this;
}
public String getDescription() {
return description;
}
public FileInfo setDescription(String description) {
this.description = description;
return this;
}
public Integer getDownloadCount() {
return downloadCount;
}
public FileInfo setDownloadCount(Integer downloadCount) {
this.downloadCount = downloadCount;
return this;
}
public Map<String, Object> getExtParameters() {
return extParameters;
}
public FileInfo setExtParameters(Map<String, Object> extParameters) {
this.extParameters = extParameters;
return this;
}
}

View File

@@ -1,5 +1,8 @@
package cn.qaiu.entity;
import java.util.HashMap;
import java.util.Map;
public class ShareLinkInfo {
private String shareKey; // 分享键
@@ -10,6 +13,8 @@ public class ShareLinkInfo {
private String shareUrl; // 原始分享链接
private String standardUrl; // 规范化的标准链接
private Map<String, Object> otherParam; // 其他参数
private ShareLinkInfo(Builder builder) {
this.shareKey = builder.shareKey;
this.panName = builder.panName;
@@ -17,6 +22,7 @@ public class ShareLinkInfo {
this.sharePassword = builder.sharePassword;
this.shareUrl = builder.shareUrl;
this.standardUrl = builder.standardUrl;
this.otherParam = builder.otherParam;
}
// Getter和Setter方法
@@ -71,9 +77,21 @@ public class ShareLinkInfo {
public String getCacheKey() {
// 将type和shareKey组合成一个字符串作为缓存key
return type + ":" + shareKey;
String key = type + ":" + shareKey;
if (type.equals("p115")) {
key += ("_" + otherParam.get("UA").toString().hashCode());
}
return key;
}
public ShareLinkInfo setOtherParam(Map<String, Object> otherParam) {
this.otherParam = otherParam;
return this;
}
public Map<String, Object> getOtherParam() {
return otherParam;
}
// 静态方法创建建造者对象
public static ShareLinkInfo.Builder newBuilder() {
@@ -88,6 +106,7 @@ public class ShareLinkInfo {
private String sharePassword = ""; // 分享密码(如果存在)
private String shareUrl; // 原始分享链接
private String standardUrl; // 规范化的标准链接
private Map<String, Object> otherParam = new HashMap<>(); // 其他参数
public Builder shareKey(String shareKey) {
this.shareKey = shareKey;
@@ -119,6 +138,11 @@ public class ShareLinkInfo {
return this;
}
public Builder otherParam(Map<String, Object> otherParam) {
this.otherParam = otherParam;
return this;
}
public ShareLinkInfo build() {
return new ShareLinkInfo(this);
}
@@ -133,6 +157,7 @@ public class ShareLinkInfo {
", sharePassword='" + sharePassword + '\'' +
", shareUrl='" + shareUrl + '\'' +
", standardUrl='" + standardUrl + '\'' +
", otherParam='" + otherParam + '\'' +
'}';
}
}

View File

@@ -4,4 +4,8 @@ import io.vertx.core.Future;
public interface IPanTool {
Future<String> parse();
default String parseSync() {
return parse().toCompletionStage().toCompletableFuture().join();
}
}

View File

@@ -2,22 +2,32 @@ package cn.qaiu.parser;
import cn.qaiu.WebClientVertxInit;
import cn.qaiu.entity.ShareLinkInfo;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.Promise;
import io.vertx.core.json.DecodeException;
import io.vertx.core.json.JsonObject;
import io.vertx.core.net.ProxyOptions;
import io.vertx.core.net.ProxyType;
import io.vertx.ext.web.client.HttpResponse;
import io.vertx.ext.web.client.WebClient;
import io.vertx.ext.web.client.WebClientOptions;
import io.vertx.ext.web.client.WebClientSession;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.Iterator;
/**
* 解析器抽象类包含promise, HTTP Client, 默认失败方法等;
* 新增网盘解析器需要继承该类.
* 新增网盘解析器需要继承该类. <br>
* <h2>实现类命名规则: </h2>
* <p>{网盘标识}Tool, 网盘标识不超过5个字符, 可以取网盘名称首字母缩写或拼音首字母, <br>
* 音乐类型的解析以M开头, 例如网易云音乐Mne</p>
*/
public abstract class PanBase {
public abstract class PanBase implements IPanTool {
protected Logger log = LoggerFactory.getLogger(this.getClass());
protected Promise<String> promise = Promise.promise();
@@ -25,7 +35,8 @@ public abstract class PanBase {
/**
* Http client
*/
protected WebClient client = WebClient.create(WebClientVertxInit.get());
protected WebClient client = WebClient.create(WebClientVertxInit.get(),
new WebClientOptions());
/**
* Http client session (会话管理, 带cookie请求)
@@ -49,11 +60,39 @@ public abstract class PanBase {
* }
* </pre></blockquote>
*
* @param shareLinkInfo 分享链接信息
*/
public PanBase(ShareLinkInfo shareLinkInfo) {
this.shareLinkInfo = shareLinkInfo;
if (shareLinkInfo.getOtherParam().containsKey("proxy")) {
JsonObject proxy = (JsonObject) shareLinkInfo.getOtherParam().get("proxy");
ProxyOptions proxyOptions = new ProxyOptions()
.setType(ProxyType.valueOf(proxy.getString("type").toUpperCase()))
.setHost(proxy.getString("host"))
.setPort(proxy.getInteger("port"));
if (StringUtils.isNotEmpty(proxy.getString("username"))) {
proxyOptions.setUsername(proxy.getString("username"));
}
if (StringUtils.isNotEmpty(proxy.getString("password"))) {
proxyOptions.setPassword(proxy.getString("password"));
}
this.client = WebClient.create(WebClientVertxInit.get(),
new WebClientOptions()
.setUserAgentEnabled(false)
.setProxyOptions(proxyOptions));
this.clientSession = WebClientSession.create(client);
this.clientNoRedirects = WebClient.create(WebClientVertxInit.get(),
new WebClientOptions().setFollowRedirects(false)
.setUserAgentEnabled(false)
.setProxyOptions(proxyOptions));
}
}
protected PanBase() {
}
/**
* 失败时生成异常消息
*
@@ -65,11 +104,11 @@ public abstract class PanBase {
try {
String s = String.format(errorMsg.replaceAll("\\{}", "%s"), args);
log.error("解析异常: " + s, t.fillInStackTrace());
promise.fail(this.getClass().getSimpleName() + ": 解析异常: " + s + " -> " + t);
promise.fail(shareLinkInfo.getPanName() + "-" + shareLinkInfo.getType() + ": 解析异常: " + s + " -> " + t);
} catch (Exception e) {
log.error("ErrorMsg format fail. The parameter has been discarded", e);
log.error("解析异常: " + errorMsg, t.fillInStackTrace());
promise.fail(this.getClass().getSimpleName() + ": 解析异常: " + errorMsg + " -> " + t);
promise.fail(shareLinkInfo.getPanName() + "-" + shareLinkInfo.getType() + ": 解析异常: " + errorMsg + " -> " + t);
}
}
@@ -82,15 +121,17 @@ public abstract class PanBase {
protected void fail(String errorMsg, Object... args) {
try {
String s = String.format(errorMsg.replaceAll("\\{}", "%s"), args);
log.error("解析异常: " + s);
promise.fail(this.getClass().getSimpleName() + " - 解析异常: " + s);
promise.fail(shareLinkInfo.getPanName() + "-" + shareLinkInfo.getType() + " - 解析异常: " + s);
} catch (Exception e) {
log.error("ErrorMsg format fail. The parameter has been discarded", e);
log.error("解析异常: " + errorMsg);
promise.fail(this.getClass().getSimpleName() + " - 解析异常: " + errorMsg);
promise.fail(shareLinkInfo.getPanName() + "-" + shareLinkInfo.getType() + " - 解析异常: " + errorMsg);
}
}
protected void fail() {
fail("");
}
/**
* 生成失败Future的处理器
*
@@ -98,7 +139,11 @@ public abstract class PanBase {
* @return Handler
*/
protected Handler<Throwable> handleFail(String errorMsg) {
return t -> fail(this.getClass().getSimpleName() + " - 请求异常 {}: -> {}", errorMsg, t.fillInStackTrace());
return t -> fail(shareLinkInfo.getPanName() + "-" + shareLinkInfo.getType() + " - 请求异常 {}: -> {}", errorMsg, t.fillInStackTrace());
}
protected Handler<Throwable> handleFail() {
return handleFail("");
}
@@ -116,4 +161,34 @@ public abstract class PanBase {
}
}
protected void complete(String url) {
promise.complete(url);
}
protected Future<String> future() {
return promise.future();
}
/**
* 调用下一个解析器, 通用域名解析
*/
protected void nextParser() {
Iterator<PanDomainTemplate> iterator = Arrays.asList(PanDomainTemplate.values()).iterator();
while (iterator.hasNext()) {
if (iterator.next().name().equalsIgnoreCase(shareLinkInfo.getType())) {
if (iterator.hasNext()) {
PanDomainTemplate next = iterator.next();
log.debug("规则不匹配, 处理解析器转发: {} -> {}", shareLinkInfo.getPanName(), next.getDisplayName());
ParserCreate.fromType(next.name())
.fromAnyShareUrl(shareLinkInfo.getShareUrl())
.createTool()
.parse()
.onComplete(promise);
} else {
fail("error: 没有下一个解析处理器");
}
}
}
}
}

View File

@@ -2,6 +2,12 @@ package cn.qaiu.parser;
import cn.qaiu.parser.impl.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.regex.Pattern;
import static java.util.regex.Pattern.compile;
/**
* 枚举类 PanDomainTemplate 定义了不同网盘服务的模板信息,包括:
* <ul>
@@ -16,95 +22,225 @@ import cn.qaiu.parser.impl.*;
*/
public enum PanDomainTemplate {
// 网盘定义
LZ("蓝奏云",
"https://([a-z0-9-]+)?\\.?lanzou[a-z]\\.com/(.+/)?(.+)",
compile("https://(?:[a-zA-Z\\d-]+\\.)?lanzou[a-z]\\.com/(.+/)?(?<KEY>.+)"),
"https://lanzoux.com/{shareKey}",
LzTool.class),
// https://www.feijix.com/s/
// https://share.feijipan.com/s/
FJ("小飞机网盘",
"https://(share\\.feijipan\\.com|www\\.feijix\\.com)/s/(.+)",
compile("https://(share\\.feijipan\\.com|www\\.feijix\\.com)/s/(?<KEY>.+)"),
"https://www.feijix.com/s/{shareKey}",
FjTool.class),
// https://lecloud.lenovo.com/share/
LE("联想乐云",
"https://lecloud?\\.lenovo\\.com/share/(.+)",
compile("https://lecloud?\\.lenovo\\.com/share/(?<KEY>.+)"),
"https://lecloud.lenovo.com/share/{shareKey}",
LeTool.class),
// https://v2.fangcloud.com/s/
FC("亿方云",
"https://v2\\.fangcloud\\.(com|cn)/(s|sharing)/([^/]+)",
compile("https://v2\\.fangcloud\\.(com|cn)/(s|sharing)/(?<KEY>.+)"),
"https://v2.fangcloud.com/s/{shareKey}",
"https://www.fangcloud.com/",
FcTool.class),
// https://www.ilanzou.com/s/
IZ("蓝奏云优享",
"https://www\\.ilanzou\\.com/s/(.+)",
compile("https://www\\.ilanzou\\.com/s/(?<KEY>.+)"),
"https://www.ilanzou.com/s/{shareKey}",
IzTool.class),
// https://wx.mail.qq.com/ftn/download?
QQ("QQ邮箱中转站",
"https://i?wx\\.mail\\.qq\\.com/ftn/download\\?(.+)",
compile("https://i?wx\\.mail\\.qq\\.com/ftn/download\\?(?<KEY>.+)"),
"https://iwx.mail.qq.com/ftn/download/{shareKey}",
"https://mail.qq.com",
QQTool.class),
// https://f.ws59.cn/f/或者https://www.wenshushu.cn/f/
WS("文叔叔",
"https://(f\\.ws([0-9]{2})\\.cn|www\\.wenshushu\\.cn)/f/(.+)",
compile("https://(f\\.ws(\\d{2})\\.cn|www\\.wenshushu\\.cn)/f/(?<KEY>.+)"),
"https://www.wenshushu.cn/f/{shareKey}",
WsTool.class),
// https://www.123pan.com/s/
YE("123网盘",
"https://www\\.(123pan|123865|123684)\\.com/s/(.+)",
compile("https://www\\.(123pan|123865|123684)\\.com/s/(?<KEY>.+)(.html)?"),
"https://www.123pan.com/s/{shareKey}",
YeTool.class),
// https://www.ecpan.cn/web/#/yunpanProxy?path=%2F%23%2Fdrive%2Foutside&data={code}&isShare=1
EC("移动云空间",
"https://www\\.ecpan\\.cn/web(/%23|/#)?/yunpanProxy\\?path=.*&data=" +
"([^&]+)&isShare=1",
compile("https://www\\.ecpan\\.cn/web(/%23|/#)?/yunpanProxy\\?path=.*&data=" +
"(?<KEY>[^&]+)&isShare=1"),
"https://www.ecpan.cn/web/#/yunpanProxy?path=%2F%23%2Fdrive%2Foutside&data={shareKey}&isShare=1",
EcTool.class),
// https://cowtransfer.com/s/
COW("奶牛快传",
"https://(.*)cowtransfer\\.com/s/(.+)",
compile("https://(.*)cowtransfer\\.com/s/(?<KEY>.+)"),
"https://cowtransfer.com/s/{shareKey}",
CowTool.class),
// https://pan.huang1111.cn/s/xxx
// 通用域名([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}
CE("Cloudreve",
"https://([a-z0-9]+(-[a-z0-9]+)*\\.)+[a-z]{2,}/s/(.+)",
"https://{CloudreveDomainName}/s/{shareKey}",
CeTool.class);
CT("城通网盘",
compile("https://(?:[a-zA-Z\\d-]+\\.)?(ctfile|545c|u062|ghpym|474b)\\.com/file/(?<KEY>.+)"),
"https://474b.com/file/{shareKey}",
CtTool.class),
// https://xxx.118pan.com/bxxx
P118("118网盘",
compile("https://(?:[a-zA-Z\\d-]+\\.)?118pan\\.com/b(?<KEY>.+)"),
"https://qaiu.118pan.com/b{shareKey}",
P118Tool.class),
// https://www.vyuyun.com/s/QMa6ie?password=I4KG7H
// https://www.vyuyun.com/s/QMa6ie/file?password=I4KG7H
PVYY("微雨云存储",
compile("https://www\\.vyuyun\\.com/s/(?<KEY>[a-zA-Z\\d-]+)(/file)?(\\?password=(?<PWD>\\w+))?"),
"https://www.vyuyun.com/s/{shareKey}?password={pwd}",
PvyyTool.class),
// https://1drv.ms/w/s!Alg0feQmCv2rnRFd60DQOmMa-Oh_?e=buaRtp
POD("OneDrive",
compile("https://1drv\\.ms/(?<KEY>.+)"),
"https://1drv\\.ms/{shareKey}",
"https://onedrive.live.com/",
PodTool.class),
// 404网盘 https://drive.google.com/file/d/xxx/view?usp=sharing
PGD("GoogleDrive",
compile("https://drive\\.google\\.com/file/d/(?<KEY>.+)/view(\\?usp=(sharing|drive_link))?"),
"https://drive.google.com/file/d/{shareKey}/view?usp=sharing",
PgdTool.class),
// iCloud https://www.icloud.com.cn/iclouddrive/xxx#fonts
PIC("iCloud",
compile("https://www\\.icloud\\.com\\.cn/iclouddrive/(?<KEY>[a-z_A-Z\\d-=]+)(#(.+))?"),
"https://www.icloud.com.cn/iclouddrive/{shareKey}",
PicTool.class),
// https://www.dropbox.com/scl/fi/cwnbms1yn8u6rcatzyta7/emqx-5.0.26-el7-amd64.tar.gz?rlkey=3uoi4bxz5mv93jmlaws0nlol1&e=8&st=fe0lclc2&dl=0
PDB("dropbox",
compile("https://www.dropbox.com/scl/fi/(?<KEY>\\w+)/.+?rlkey=(?<PWD>\\w+).*"),
"https://www.dropbox.com/scl/fi/{shareKey}/?rlkey={pwd}&dl=0",
PdbTool.class),
P115("115网盘",
compile("https://(115|anxia).com/s/(?<KEY>\\w+)(\\?password=(?<PWD>\\w+))?"),
"https://115.com/s/{shareKey}?password={pwd}",
P115Tool.class),
// =====================音乐类解析 分享链接标志->MxxS (单歌曲/普通音质)==========================
// http://163cn.tv/xxx
MNES("网易云音乐分享",
compile("http(s)?://163cn\\.tv/(?<KEY>.+)"),
"http://163cn.tv/{shareKey}",
MnesTool.class),
// https://music.163.com/#/song?id=xxx
MNE("网易云音乐歌曲详情",
compile("https://music\\.163\\.com/(#/)?song\\?id=(?<KEY>.+)"),
"https://music.163.com/#/song?id={shareKey}",
MnesTool.MneTool.class),
// https://c6.y.qq.com/base/fcgi-bin/u?__=xxx
MQQS("QQ音乐分享",
compile("https://(?:[a-zA-Z\\d-]+\\.)?y\\.qq\\.com/base/fcgi-bin/u\\?__=(?<KEY>.+)"),
"https://c6.y.qq.com/base/fcgi-bin/u?__={shareKey}",
MqqsTool.class),
// https://y.qq.com/n/ryqq/songDetail/000XjcLg0fbRjv?songtype=0
MQQ("QQ音乐歌曲详情",
compile("https://y\\.qq\\.com/n/ryqq/songDetail/(?<KEY>.+)(\\?.*)?"),
"https://y.qq.com/n/ryqq/songDetail/{shareKey}",
MqqsTool.MqqTool.class),
// https://t1.kugou.com/song.html?id=xxx
MKGS("酷狗音乐分享",
compile("https://(?:[a-zA-Z\\d-]+\\.)?kugou\\.com/song\\.html\\?id=(?<KEY>.+)"),
"https://t1.kugou.com/song.html?id={shareKey}",
MkgsTool.class),
// https://www.kugou.com/share/2bi8Fe9CSV3.html?id=2bi8Fe9CSV3#6ed9gna4"
MKGS2("酷狗音乐分享2",
compile("https://(?:[a-zA-Z\\d-]+\\.)?kugou\\.com/share/(?<KEY>.+).html.*"),
"https://www.kugou.com/share/{shareKey}.html",
MkgsTool.Mkgs2Tool.class),
// https://www.kugou.com/mixsong/2bi8Fe9CSV3
MKG("酷狗音乐歌曲详情",
compile("https://(?:[a-zA-Z\\d-]+\\.)?kugou\\.com/mixsong/(?<KEY>.+)\\.html.*"),
"https://www.kugou.com/mixsong/{shareKey}.html",
MkgsTool.MkgTool.class),
// https://kuwo.cn/play_detail/395500809
// https://m.kuwo.cn/newh5app/play_detail/318448522
MKWS("酷我音乐分享*",
compile("https://(m\\.)?kuwo\\.cn/(newh5app/)?play_detail/(?<KEY>.+)"),
"https://kuwo.cn/play_detail/{shareKey}",
MkwTool.class),
// https://music.migu.cn/v3/music/song/6326951FKBJ?channelId=001002H
MMGS("咪咕音乐分享",
compile("https://music\\.migu\\.cn/v3/music/song/(?<KEY>.+)(\\?.*)?"),
"https://music.migu.cn/v3/music/song/{shareKey}",
MkwTool.class),
// =====================私有盘解析==========================
// Cloudreve自定义域名解析, 解析器CeTool兜底策略, 即任意域名如果匹配不到对应的规则, 则由CeTool统一处理,
// 如果不属于Cloudreve盘 则调用下一个自定义域名解析器, 若都处理不了则抛出异常, 这种匹配模式类似责任链
// https://pan.huang1111.cn/s/xxx
// 通用域名([a-z\\d]+(-[a-z\\d]+)*\.)+[a-z]{2,}
CE("Cloudreve",
compile("http(s)?://([a-zA-Z\\d]+(-[a-zA-Z\\d]+)*\\.)+[a-zA-Z]{2,}(/s)?/(?<KEY>.+)"),
"https://{any}/s/{shareKey}",
"https://cloudreve.org/",
CeTool.class),
// 可道云自定义域名解析
KD("可道云",
compile("http(s)?://([a-zA-Z\\d]+(-[a-zA-Z\\d]+)*\\.)+[a-zA-Z]{2,}(/#s)?/(?<KEY>.+)"),
"https://{any}/#s/{shareKey}",
"https://kodcloud.com/",
KdTool.class),
// 其他自定义域名解析
OTHER("其他网盘",
compile("http(s)?://([a-zA-Z\\d]+(-[a-zA-Z\\d]+)*\\.)+[a-zA-Z]{2,}/(?<KEY>.+)"),
"https://{any}/{shareKey}",
OtherTool.class);
public static final String KEY = "KEY";
public static final String PWD = "PWD";
// 网盘的显示名称,用于用户界面显示
private final String displayName;
// 用于匹配和解析分享链接的正则表达式保证最后一个捕捉组能匹配到分享key
private final String regexPattern;
private final Pattern pattern;
private final String regex;
// 网盘的标准链接模板,不含占位符,用于规范化分享链接
private final String standardUrlTemplate;
// 网盘的域名, 如果在分享链接里能提取到, 则可不写
private String panDomain;
// 指向解析工具IPanTool实现类
private final Class<? extends IPanTool> toolClass;
PanDomainTemplate(String displayName, String regexPattern, String standardUrlTemplate,
PanDomainTemplate(String displayName, Pattern pattern, String standardUrlTemplate,
Class<? extends IPanTool> toolClass) {
this.displayName = displayName;
this.regexPattern = regexPattern;
this.pattern = pattern;
this.regex = pattern.pattern();
this.standardUrlTemplate = standardUrlTemplate;
this.toolClass = toolClass;
}
PanDomainTemplate(String displayName, Pattern pattern, String standardUrlTemplate, String panDomain,
Class<? extends IPanTool> toolClass) {
this.displayName = displayName;
this.pattern = pattern;
this.regex = pattern.pattern();
this.standardUrlTemplate = standardUrlTemplate;
this.panDomain = panDomain;
this.toolClass = toolClass;
}
public String getDisplayName() {
return displayName;
}
public String getRegexPattern() {
return regexPattern;
public Pattern getPattern() {
return pattern;
}
public String getRegex() {
return regex;
}
public String getStandardUrlTemplate() {
@@ -114,4 +250,18 @@ public enum PanDomainTemplate {
public Class<? extends IPanTool> getToolClass() {
return toolClass;
}
public String getPanDomain() {
if (panDomain == null) {
String url = standardUrlTemplate
.replace("{shareKey}", "");
URL panDomainUrl = null;
try {
panDomainUrl = new URL(url);
} catch (MalformedURLException ignored) {}
return panDomainUrl != null ? (panDomainUrl.getProtocol() + "://" + panDomainUrl.getHost()) : "";
}
return panDomain;
}
}

View File

@@ -1,13 +0,0 @@
package cn.qaiu.parser;
/**
* @author <a href="https://qaiu.top">QAIU</a>
* @date 2023/6/13 4:26
*/
public enum PanType {
LZ("lz"),
COW("cow");
PanType(String type) {
}
}

View File

@@ -4,7 +4,9 @@ import cn.qaiu.entity.ShareLinkInfo;
import org.apache.commons.lang3.StringUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static cn.qaiu.parser.PanDomainTemplate.KEY;
import static cn.qaiu.parser.PanDomainTemplate.PWD;
/**
@@ -34,15 +36,24 @@ public class ParserCreate {
if (StringUtils.isEmpty(shareUrl)) {
throw new IllegalArgumentException("ShareLinkInfo shareUrl is empty");
}
Pattern pattern = Pattern.compile(this.panDomainTemplate.getRegexPattern());
Matcher matcher = pattern.matcher(shareUrl);
Matcher matcher = this.panDomainTemplate.getPattern().matcher(shareUrl);
if (matcher.find()) {
String shareKey = matcher.group(matcher.groupCount());
String shareKey = matcher.group(KEY);
// 返回规范化的标准链接
String standardUrl = getStandardUrlTemplate().replace("{shareKey}", shareKey);
String standardUrl = getStandardUrlTemplate()
.replace("{shareKey}", shareKey);
try {
String pwd = matcher.group(PWD);
if (StringUtils.isNotEmpty(pwd)) {
shareLinkInfo.setSharePassword(pwd);
}
standardUrl = standardUrl .replace("{pwd}", pwd);
} catch (Exception ignored) {}
shareLinkInfo.setShareUrl(shareUrl);
shareLinkInfo.setShareKey(shareKey);
if (!(panDomainTemplate == PanDomainTemplate.CE)) {
if (!(panDomainTemplate.ordinal() >= PanDomainTemplate.CE.ordinal())) {
shareLinkInfo.setStandardUrl(standardUrl);
}
return this;
@@ -68,7 +79,7 @@ public class ParserCreate {
// set share key
public ParserCreate shareKey(String shareKey) {
if (panDomainTemplate == PanDomainTemplate.CE) {
if (panDomainTemplate.ordinal() >= PanDomainTemplate.CE.ordinal()) {
// 处理Cloudreve(ce)类: pan.huang1111.cn_s_wDz5TK _ -> /
String[] s = shareKey.split("_");
String standardUrl = "https://" + String.join("/", s);
@@ -82,6 +93,13 @@ public class ParserCreate {
return this;
}
// set any share url
public ParserCreate fromAnyShareUrl(String url) {
shareLinkInfo.setStandardUrl(url);
shareLinkInfo.setShareUrl(url);
return this;
}
public String getStandardUrlTemplate() {
return this.panDomainTemplate.getStandardUrlTemplate();
}
@@ -91,19 +109,21 @@ public class ParserCreate {
}
public ParserCreate setShareLinkInfoPwd(String pwd) {
shareLinkInfo.setSharePassword(pwd);
if (pwd != null) {
shareLinkInfo.setSharePassword(pwd);
}
return this;
}
// 根据分享链接获取PanDomainTemplate实例
public synchronized static ParserCreate fromShareUrl(String shareUrl) {
for (PanDomainTemplate panDomainTemplate : PanDomainTemplate.values()) {
if (shareUrl.matches(panDomainTemplate.getRegexPattern())) {
if (panDomainTemplate.getPattern().matcher(shareUrl).matches()) {
ShareLinkInfo shareLinkInfo = ShareLinkInfo.newBuilder()
.type(panDomainTemplate.name().toLowerCase())
.panName(panDomainTemplate.getDisplayName())
.shareUrl(shareUrl).build();
if (panDomainTemplate == PanDomainTemplate.CE) {
if (panDomainTemplate.ordinal() >= PanDomainTemplate.CE.ordinal()) {
shareLinkInfo.setStandardUrl(shareUrl);
}
ParserCreate parserCreate = new ParserCreate(panDomainTemplate, shareLinkInfo);
@@ -119,6 +139,7 @@ public class ParserCreate {
PanDomainTemplate panDomainTemplate = Enum.valueOf(PanDomainTemplate.class, type.toUpperCase());
ShareLinkInfo shareLinkInfo = ShareLinkInfo.newBuilder()
.type(type.toLowerCase()).build();
shareLinkInfo.setPanName(panDomainTemplate.getDisplayName());
return new ParserCreate(panDomainTemplate, shareLinkInfo);
} catch (IllegalArgumentException ignore) {
// 如果没有找到对应的枚举实例,抛出异常
@@ -130,7 +151,7 @@ public class ParserCreate {
public String genPathSuffix() {
String path;
if (panDomainTemplate == PanDomainTemplate.CE) {
if (panDomainTemplate.ordinal() >= PanDomainTemplate.CE.ordinal()) {
// 处理Cloudreve(ce)类: pan.huang1111.cn_s_wDz5TK _ -> /
path = this.shareLinkInfo.getType() + "/"
+ this.shareLinkInfo.getShareUrl()

View File

@@ -1,14 +1,17 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.IPanTool;
import cn.qaiu.parser.PanBase;
import cn.qaiu.parser.PanDomainTemplate;
import cn.qaiu.parser.ParserCreate;
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.URL;
import java.util.Arrays;
import java.util.Iterator;
/**
* <a href="https://github.com/cloudreve/Cloudreve">Cloudreve自建网盘解析</a> <br>
@@ -17,7 +20,7 @@ import java.net.URL;
* <a href="https://pan.seeoss.com">看见存储</a> <br>
* <a href="https://dav.yiandrive.com">亿安云盘</a> <br>
*/
public class CeTool extends PanBase implements IPanTool {
public class CeTool extends PanBase {
private static final String DOWNLOAD_API_PATH = "/api/v3/share/download/";
@@ -43,22 +46,32 @@ public class CeTool extends PanBase implements IPanTool {
String downloadApiUrl = url.getProtocol() + "://" + url.getHost() + DOWNLOAD_API_PATH + key + "?path" +
"=undefined/undefined;";
String shareApiUrl = url.getProtocol() + "://" + url.getHost() + SHARE_API_PATH + key;
// 设置cookie
HttpRequest<Buffer> httpRequest = clientSession.getAbs(shareApiUrl);
if (pwd != null) {
httpRequest.addQueryParam("password", pwd);
}
// 获取下载链接
httpRequest.send().onSuccess(res -> getDownURL(downloadApiUrl)).onFailure(handleFail(shareApiUrl));
httpRequest.send().onSuccess(res -> {
try {
if (res.statusCode() == 200 && res.bodyAsJsonObject().containsKey("code")) {
getDownURL(downloadApiUrl);
} else {
nextParser();
}
} catch (Exception e) {
nextParser();
}
}).onFailure(handleFail(shareApiUrl));
} catch (Exception e) {
fail(e, "URL解析错误");
}
return promise.future();
}
private void getDownURL(String apiUrl) {
clientSession.putAbs(apiUrl).send().onSuccess(res -> {
private void getDownURL(String shareApiUrl) {
clientSession.putAbs(shareApiUrl).send().onSuccess(res -> {
JsonObject jsonObject = asJson(res);
System.out.println(jsonObject.encodePrettily());
if (jsonObject.containsKey("code") && jsonObject.getInteger("code") == 0) {
@@ -66,6 +79,6 @@ public class CeTool extends PanBase implements IPanTool {
} else {
fail("JSON解析失败: {}", jsonObject.encodePrettily());
}
}).onFailure(handleFail(apiUrl));
}).onFailure(handleFail(shareApiUrl));
}
}

View File

@@ -1,7 +1,6 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.IPanTool;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.PanBase;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
@@ -13,7 +12,7 @@ import org.apache.commons.lang3.StringUtils;
* @author <a href="https://qaiu.top">QAIU</a>
* @date 2023/4/21 21:19
*/
public class CowTool extends PanBase implements IPanTool {
public class CowTool extends PanBase {
private static final String API_REQUEST_URL = "https://cowtransfer.com/core/api/transfer/share";

View File

@@ -0,0 +1,90 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.PanBase;
import cn.qaiu.util.RandomStringGenerator;
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 io.vertx.uritemplate.UriTemplate;
/**
* <a href="https://www.ctfile.com">诚通网盘</a>
*/
public class CtTool extends PanBase {
private static final String API_URL_PREFIX = "https://webapi.ctfile.com";
private static final String API1 = API_URL_PREFIX + "/getfile.php?path=file" +
"&f={shareKey}&passcode={pwd}&token={token}&r={rand}&ref=";
private static final String API2 = API_URL_PREFIX + "/get_file_url.php?" +
"uid={uid}&fid={fid}&folder_id=0&file_chk={file_chk}&mb=0&token={token}&app=0&acheck=0&verifycode=" +
"&rd={rand}";
/**
* 子类重写此构造方法不需要添加额外逻辑
* 如:
* <blockquote><pre>
* public XxTool(String key, String pwd) {
* super(key, pwd);
* }
* </pre></blockquote>
*
* @param shareLinkInfo 分享链接信息
*/
public CtTool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
@Override
public Future<String> parse() {
final String shareKey = shareLinkInfo.getShareKey();
if (shareKey.indexOf('-') == -1) {
fail("shareKey格式不正确找不到'-': {}", shareKey);
return promise.future();
}
String[] split = shareKey.split("-");
String uid = split[0], fid = split[1];
String token = RandomStringGenerator.generateRandomString();
HttpRequest<Buffer> bufferHttpRequest1 = clientSession.getAbs(UriTemplate.of(API1))
.setTemplateParam("shareKey", shareKey)
.setTemplateParam("pwd", shareLinkInfo.getSharePassword())
.setTemplateParam("token", token)
.setTemplateParam("r", Math.random() + "");
bufferHttpRequest1
.send().onSuccess(res -> {
var resJson = asJson(res);
if (resJson.containsKey("file")) {
var fileJson = resJson.getJsonObject("file");
if (fileJson.containsKey("file_chk")) {
var file_chk = fileJson.getString("file_chk");
HttpRequest<Buffer> bufferHttpRequest2 = clientSession.getAbs(UriTemplate.of(API2))
.setTemplateParam("uid", uid)
.setTemplateParam("fid", fid)
.setTemplateParam("file_chk", file_chk)
.setTemplateParam("token", token)
.setTemplateParam("rd", Math.random() + "");
bufferHttpRequest2
.send().onSuccess(res2 -> {
JsonObject resJson2 = asJson(res2);
if (resJson2.containsKey("downurl")) {
promise.complete(resJson2.getString("downurl"));
} else {
fail("解析失败, 可能分享已失效: json: {} 字段 {} 不存在", resJson2, "downurl");
}
}).onFailure(handleFail(bufferHttpRequest1.queryParams().toString()));
} else {
fail("解析失败, 可能分享已失效: json: {} 字段 {} 不存在", resJson, "file_chk");
}
} else {
fail("解析失败, 可能分享已失效: json: {} 字段 {} 不存在", resJson, "file");
}
}).onFailure(handleFail(bufferHttpRequest1.queryParams().toString()));
return promise.future();
}
}

View File

@@ -1,7 +1,6 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.IPanTool;
import cn.qaiu.parser.PanBase;
import io.vertx.core.Future;
import io.vertx.core.json.JsonArray;
@@ -11,7 +10,7 @@ import io.vertx.uritemplate.UriTemplate;
/**
* 移动云空间解析
*/
public class EcTool extends PanBase implements IPanTool {
public class EcTool extends PanBase {
// https://www.ecpan.cn/web/#/yunpanProxy?path=%2F%23%2Fdrive%2Foutside&data=4b3d786755688b85c6eb0c04b9124f4dalzdaJpXHx&isShare=1
private static final String FIRST_REQUEST_URL = "https://www.ecpan.cn/drive/fileextoverrid" +
".do?extractionCode={extractionCode}&chainUrlTemplate=https:%2F%2Fwww.ecpan" +

View File

@@ -1,7 +1,6 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.IPanTool;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.PanBase;
import io.vertx.core.Future;
import io.vertx.core.MultiMap;
@@ -19,7 +18,7 @@ import java.util.regex.Pattern;
/**
* 360亿方云
*/
public class FcTool extends PanBase implements IPanTool {
public class FcTool extends PanBase {
public static final String SHARE_URL_PREFIX = "https://v2.fangcloud.com/sharing/";
public static final String SHARE_URL_PREFIX2 = "https://v2.fangcloud.cn/sharing/";

View File

@@ -1,7 +1,6 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.IPanTool;
import cn.qaiu.parser.PanBase;
import cn.qaiu.util.AESUtils;
import cn.qaiu.util.UUIDUtil;
@@ -12,19 +11,27 @@ import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.client.HttpRequest;
import io.vertx.uritemplate.UriTemplate;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.zip.GZIPInputStream;
/**
* 小飞机网盘
*
* @version V016_230609
*/
public class FjTool extends PanBase implements IPanTool {
public class FjTool extends PanBase {
public static final String REFERER_URL = "https://share.feijipan.com/";
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" +
"&uuid={uuid}&extra=2&timestamp={ts}&shareId={shareId}&type=0&offset=1&limit=60";
/// recommend/list?devType=6&devModel=Chrome&uuid={uuid}&extra=2&timestamp={ts}&shareId={shareId}&type=0&offset=1
// &limit=60
/// recommend/list?devType=6&devModel=Chrome&uuid={uuid}&extra=2&timestamp={ts}&shareId={shareId}&type=0&offset=1&limit=60
// recommend/list?devType=6&devModel=Chrome&uuid={uuid}&extra=2&timestamp={ts}&shareId=JoUTkZYj&type=0&offset=1&limit=60
private static final String SECOND_REQUEST_URL = API_URL_PREFIX + "file/redirect?downloadId={fidEncode}&enable=1" +
"&devType=6&uuid={uuid}&timestamp={ts}&auth={auth}&shareId={dataKey}";
@@ -35,6 +42,30 @@ public class FjTool extends PanBase implements IPanTool {
"={uuid}&extra=2&timestamp={ts}";
// https://api.feijipan.com/ws/buy/vip/list?devType=6&devModel=Chrome&uuid=WQAl5yBy1naGudJEILBvE&extra=2&timestamp=E2C53155F6D09417A27981561134CB73
private static final MultiMap header;
static {
header = MultiMap.caseInsensitiveMultiMap();
header.set("Accept", "application/json, text/plain, */*");
header.set("Accept-Encoding", "gzip, deflate, br, zstd");
header.set("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8");
header.set("Cache-Control", "no-cache");
header.set("Connection", "keep-alive");
header.set("Content-Length", "0");
header.set("DNT", "1");
header.set("Host", "api.feijipan.com");
header.set("Origin", "https://www.feijix.com");
header.set("Pragma", "no-cache");
header.set("Referer", "https://www.feijix.com/");
header.set("Sec-Fetch-Dest", "empty");
header.set("Sec-Fetch-Mode", "cors");
header.set("Sec-Fetch-Site", "cross-site");
header.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36");
header.set("sec-ch-ua", "\"Google Chrome\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\"");
header.set("sec-ch-ua-mobile", "?0");
header.set("sec-ch-ua-platform", "\"Windows\"");
}
public FjTool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
@@ -59,11 +90,38 @@ public class FjTool extends PanBase implements IPanTool {
// 第一次请求 获取文件信息
// POST https://api.feijipan.com/ws/recommend/list?devType=6&devModel=Chrome&extra=2&shareId=146731&type=0&offset=1&limit=60
client.postAbs(UriTemplate.of(FIRST_REQUEST_URL))
.putHeaders(header)
.setTemplateParam("shareId", shareId)
.setTemplateParam("uuid", uuid)
.setTemplateParam("ts", tsEncode0)
.setTemplateParam("ts", tsEncode)
.send().onSuccess(res -> {
JsonObject resJson = asJson(res);
// 处理GZ压缩
// 使用GZIPInputStream来解压数据
String decompressedString;
try (ByteArrayInputStream bais = new ByteArrayInputStream(res.body().getBytes());
GZIPInputStream gzis = new GZIPInputStream(bais);
BufferedReader reader = new BufferedReader(new InputStreamReader(gzis, StandardCharsets.UTF_8))) {
// 用于存储解压后的字符串
StringBuilder decompressedData = new StringBuilder();
// 逐行读取解压后的数据
String line;
while ((line = reader.readLine()) != null) {
decompressedData.append(line);
}
// 此时decompressedData.toString()包含了解压后的字符串
decompressedString = decompressedData.toString();
} catch (IOException e) {
// 处理可能的IO异常
fail(FIRST_REQUEST_URL + " 响应异常");
return;
}
// 处理GZ压缩结束
JsonObject resJson = new JsonObject(decompressedString);
if (resJson.getInteger("code") != 200) {
fail(FIRST_REQUEST_URL + " 返回异常: " + resJson);
return;
@@ -82,12 +140,10 @@ public class FjTool extends PanBase implements IPanTool {
String fidEncode = AESUtils.encrypt2Hex(fileId + "|" + userId);
String auth = AESUtils.encrypt2Hex(fileId + "|" + nowTs2);
MultiMap headers0 = MultiMap.caseInsensitiveMultiMap();
headers0.set("referer", REFERER_URL);
// 第二次请求
HttpRequest<Buffer> httpRequest =
clientNoRedirects.getAbs(UriTemplate.of(SECOND_REQUEST_URL))
.putHeaders(headers0)
.putHeaders(header)
.setTemplateParam("fidEncode", fidEncode)
.setTemplateParam("uuid", uuid)
.setTemplateParam("ts", tsEncode2)

View File

@@ -0,0 +1,132 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.PanBase;
import io.netty.handler.codec.http.cookie.Cookie;
import io.netty.handler.codec.http.cookie.DefaultCookie;
import io.vertx.core.Future;
import io.vertx.core.MultiMap;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.impl.headers.HeadersMultiMap;
import io.vertx.core.json.JsonObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* t.cn 短链生成 //
*/
public class GenShortUrl extends PanBase {
private static final Logger log = LoggerFactory.getLogger(GenShortUrl.class);
private static final String COMMENT_URL = "https://www.weibo.com/aj/v6/comment/add";
private static final String DELETE_COMMENT_URL = "https://www.weibo.com/aj/comment/del";
private static final String WRAPPER_URL = "https://www.so.com/link?m=ewgUSYiFWXIoTybC3fJH8YoJy8y10iRquo6cazgINwWjTn3HvVJ92TrCJu0PmMUR0RMDfOAucP3wa4G8j64SrhNH9Z0Cr0PEyn9ASuvpkUGmAjjUEGJkO5%2BIDGWVrEkPHsL7UsoKO6%2BlT%2BD6r&ccc=";
private static final String MID = "5095144728824883"; // 微博的mid
private static final MultiMap HEADER = HeadersMultiMap.headers()
.add("Content-Type", "application/x-www-form-urlencoded")
.add("Referer", "https://www.weibo.com")
.add("Content-Type", "application/x-www-form-urlencoded")
.add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36");
Cookie cookie = new DefaultCookie("SUB", "_2A25KJE5vDeRhGeRJ6lsR9SjJzDuIHXVpWM-nrDV8PUJbkNAbLVPlkW1NUmJm3GjYtRHBsHdMUKafkdTL_YheMEmu");
public GenShortUrl(ShareLinkInfo build) {
super(build);
}
@Override
public Future<String> parse() {
String longUrl = shareLinkInfo.getShareUrl();
String url = WRAPPER_URL + Base64.getEncoder().encodeToString(longUrl.getBytes());
String payload = "mid=" + MID + "&content=" + URLEncoder.encode(url, StandardCharsets.UTF_8);
clientSession.cookieStore().put(cookie);
clientSession.postAbs(COMMENT_URL)
.putHeaders(HEADER)
.sendBuffer(Buffer.buffer(payload))
.onSuccess(res -> {
JsonObject data = asJson(res).getJsonObject("data");
if (data.isEmpty()) {
fail(asJson(res).getString("msg"));
return;
}
String comment = data.getString("comment");
String shortUrl = extractShortUrl(comment);
if (shortUrl != null) {
log.info("生成的短链:{}", shortUrl);
String commentId = extractCommentId(comment);
if (commentId != null) {
deleteComment(commentId);
} else {
promise.fail("未能提取评论ID");
}
} else {
promise.fail("未能生成短链");
}
})
.onFailure(err -> {
log.error("添加评论失败", err);
promise.fail(err);
});
return promise.future();
}
private void deleteComment(String commentId) {
String payload = "mid=" + MID + "&cid=" + commentId;
clientSession.postAbs(DELETE_COMMENT_URL)
.putHeaders(HEADER)
.sendBuffer(Buffer.buffer(payload))
.onSuccess(res -> {
JsonObject responseJson = res.bodyAsJsonObject();
if (responseJson.getString("code").equals("100000")) {
log.info("评论已删除: {}", commentId);
} else {
log.error("删除评论失败: {}", responseJson.encode());
}
})
.onFailure(err -> {
log.error("删除评论失败", err);
});
}
private String extractShortUrl(String comment) {
Pattern pattern = Pattern.compile("(https?)://t.cn/\\w+");
Matcher matcher = pattern.matcher(comment);
if (matcher.find()) {
return matcher.group(0);
}
return null;
}
private String extractCommentId(String comment) {
Pattern pattern = Pattern.compile("comment_id=\"(\\d+)\"");
Matcher matcher = pattern.matcher(comment);
if (matcher.find()) {
return matcher.group(1);
}
return null;
}
public static void main(String[] args) {
// http://t.cn/A6nfZn86
// http://t.cn/A6nfZn86
new GenShortUrl(ShareLinkInfo.newBuilder().shareUrl("https://qaiu.top/sdfsdf").build()).parse().onSuccess(
System.out::println
);
}
}

View File

@@ -1,7 +1,6 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.IPanTool;
import cn.qaiu.parser.PanBase;
import cn.qaiu.util.AESUtils;
import io.vertx.core.Future;
@@ -15,16 +14,17 @@ import java.util.UUID;
* 蓝奏云优享
*
*/
public class IzTool extends PanBase implements IPanTool {
public class IzTool extends PanBase {
public static final String SHARE_URL_PREFIX = "https://www.ilanzou.com/s/";
private static final String API_URL_PREFIX = "https://api.ilanzou.com/unproved/";
private static final String FIRST_REQUEST_URL = API_URL_PREFIX + "recommend/list?devType=6&devModel=Chrome&extra" +
"=2&shareId={shareId}&type=0&offset=1&limit=60";
private static final String FIRST_REQUEST_URL = API_URL_PREFIX +
"recommend/list?devModel=Chrome&extra=2&shareId={shareId}&type=0&offset=1&limit=60";
private static final String SECOND_REQUEST_URL = API_URL_PREFIX + "file/redirect?downloadId={fidEncode}&enable=1" +
"&devType=6&uuid={uuid}&timestamp={ts}&auth={auth}";
private static final String SECOND_REQUEST_URL = API_URL_PREFIX +
"file/redirect?downloadId={fidEncode}&enable=1&devType=6&uuid={uuid}&timestamp={ts}&auth={auth}&shareId={shareId}";
// downloadId=x&enable=1&devType=6&uuid=x&timestamp=x&auth=x&shareId=lGFndCM
public IzTool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
@@ -56,7 +56,7 @@ public class IzTool extends PanBase implements IPanTool {
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);
// 第二次请求
@@ -64,7 +64,8 @@ public class IzTool extends PanBase implements IPanTool {
.setTemplateParam("fidEncode", fidEncode)
.setTemplateParam("uuid", uuid)
.setTemplateParam("ts", tsEncode)
.setTemplateParam("auth", auth).send().onSuccess(res2 -> {
.setTemplateParam("auth", auth)
.setTemplateParam("shareId", dataKey).send().onSuccess(res2 -> {
MultiMap headers = res2.headers();
if (!headers.contains("Location")) {
fail(SECOND_REQUEST_URL + " 未找到重定向URL: \n" + res.headers());

View File

@@ -0,0 +1,26 @@
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.JsonArray;
import io.vertx.core.json.JsonObject;
import java.util.UUID;
/**
* <a href="https://kodcloud.com/">可道云</a>
*/
public class KdTool extends PanBase {
private static final String API_URL_PREFIX = "";
public KdTool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
public Future<String> parse() {
nextParser();
// TODO
return future();
}
}

View File

@@ -1,7 +1,6 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.IPanTool;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.PanBase;
import io.vertx.core.Future;
import io.vertx.core.json.JsonArray;
@@ -12,7 +11,7 @@ import java.util.UUID;
/**
* <a href="https://lecloud.lenovo.com/">联想乐云</a>
*/
public class LeTool extends PanBase implements IPanTool {
public class LeTool extends PanBase {
private static final String API_URL_PREFIX = "https://lecloud.lenovo.com/share/api/clouddiskapi/share/public/v1/";
public LeTool(ShareLinkInfo shareLinkInfo) {

View File

@@ -1,7 +1,6 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.IPanTool;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.PanBase;
import cn.qaiu.util.JsExecUtils;
import io.vertx.core.Future;
@@ -20,7 +19,7 @@ import java.util.regex.Pattern;
*
* @author QAIU
*/
public class LzTool extends PanBase implements IPanTool {
public class LzTool extends PanBase {
public static final String SHARE_URL_PREFIX = "https://wwwa.lanzoux.com";

View File

@@ -0,0 +1,125 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.PanBase;
import io.vertx.core.Future;
import io.vertx.core.MultiMap;
import io.vertx.core.json.JsonObject;
import io.vertx.uritemplate.UriTemplate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 酷狗音乐分享
* <a href="https://t1.kugou.com/song.html?id=2bi8Fe9CSV3">分享链接1</a>
* <a href="https://www.kugou.com/share/2bi8Fe9CSV3.html?id=2bi8Fe9CSV3#6ed9gna4">分享链接2</a>
* <a href="https://www.kugou.com/share/2bi8Fe9CSV3.html">分享链接3</a>
* <a href="https://www.kugou.com/mixsong/8odv4ef8.html">歌曲链接1</a>
*/
public class MkgsTool extends PanBase {
public static final String API_URL = "https://m.kugou.com/app/i/getSongInfo.php?cmd=playInfo&hash={hash}";
private static final MultiMap headers = MultiMap.caseInsensitiveMultiMap();
static {
// 设置 User-Agent
headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0");
// 设置 Accept
headers.set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7");
// 设置 If-Modified-Since
headers.set("If-Modified-Since", "Mon, 21 Oct 2024 08:45:50 GMT");
// 设置 Priority
headers.set("Priority", "u=0, i");
// 设置 Sec-CH-UA
headers.set("Sec-CH-UA", "\"Microsoft Edge\";v=\"129\", \"Not=A?Brand\";v=\"8\", \"Chromium\";v=\"129\"");
// 设置 Sec-CH-UA-Mobile
headers.set("Sec-CH-UA-Mobile", "?0");
// 设置 Sec-CH-UA-Platform
headers.set("Sec-CH-UA-Platform", "\"Windows\"");
// 设置 Sec-Fetch-Dest
headers.set("Sec-Fetch-Dest", "document");
// 设置 Sec-Fetch-Mode
headers.set("Sec-Fetch-Mode", "navigate");
// 设置 Sec-Fetch-Site
headers.set("Sec-Fetch-Site", "none");
// 设置 Sec-Fetch-User
headers.set("Sec-Fetch-User", "?1");
// 设置 Upgrade-Insecure-Requests
headers.set("Upgrade-Insecure-Requests", "1");
};
public MkgsTool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
public Future<String> parse() {
String shareUrl = shareLinkInfo.getStandardUrl();
// String shareUrl = "https://t1.kugou.com/song.html?id=2bi8Fe9CSV3";
clientNoRedirects.getAbs(shareUrl).send().onSuccess(res -> {
String locationURL = res.headers().get("Location");
downUrl(locationURL);
}).onFailure(handleFail(shareUrl));
return promise.future();
}
protected void downUrl(String locationURL) {
client.getAbs(locationURL).putHeaders(headers).send().onSuccess(res2->{
String body = res2.bodyAsString();
// 正则表达式匹配 hash 字段
String regex = "\"hash\"\s*:\s*\"([A-F0-9]+)\"";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(body);
// 查找并输出 hash 字段的值
if (matcher.find()) {
String hashValue = matcher.group(1); // 获取第一个捕获组
System.out.println(hashValue);
client.getAbs(UriTemplate.of(API_URL)).setTemplateParam("hash", hashValue).send().onSuccess(res3 -> {
JsonObject jsonObject = asJson(res3);
System.out.println(jsonObject.encodePrettily());
if (jsonObject.containsKey("url")) {
promise.complete(jsonObject.getString("url"));
} else {
fail("下载链接不存在");
}
}).onFailure(handleFail(API_URL.replace("{hash}", hashValue)));
} else {
fail("歌曲hash匹配失败, 可能分享已失效");
}
}).onFailure(handleFail(locationURL));
}
public static class MkgTool extends MkgsTool {
public MkgTool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
@Override
public Future<String> parse() {
downUrl(shareLinkInfo.getStandardUrl());
return promise.future();
}
;
}
public static class Mkgs2Tool extends MkgTool {
public Mkgs2Tool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
}
}

View File

@@ -0,0 +1,68 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.PanBase;
import cn.qaiu.util.JsExecUtils;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
import io.vertx.uritemplate.UriTemplate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 酷我音乐分享
* <a href="https://kuwo.cn/play_detail/395500809">分享示例</a>
* <a href="https://m.kuwo.cn/newh5app/play_detail/318448522">分享示例</a>
*/
public class MkwTool extends PanBase {
public static final String API_URL = "https://www.kuwo.cn/api/v1/www/music/playUrl?mid={mid}&type=music&httpsStatus=1&reqId=&plat=web_www&from=";
public MkwTool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
public Future<String> parse() {
String shareUrl = shareLinkInfo.getStandardUrl();
clientSession.getAbs(shareUrl).send().onSuccess(result -> {
String cookie = result.headers().get("set-cookie");
if (!cookie.isEmpty()) {
String regex = "([A-Za-z0-9_]+)=([A-Za-z0-9]+)";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(cookie);
if (matcher.find()) {
System.out.println(matcher.group(1));
System.out.println(matcher.group(2));
var key = matcher.group(1);
var token = matcher.group(2);
String sign = JsExecUtils.getKwSign(token, key);
System.out.println(sign);
clientSession.getAbs(UriTemplate.of(API_URL)).setTemplateParam("mid", shareLinkInfo.getShareKey())
.putHeader("Secret", sign).send().onSuccess(res -> {
JsonObject json = asJson(res);
log.debug(json.encodePrettily());
try {
if (json.getInteger("code") == 200) {
complete(json.getJsonObject("data").getString("url"));
} else {
fail("链接已失效/需要VIP");
}
} catch (Exception e) {
e.printStackTrace();
fail("解析失败");
}
});
}
}
});
return promise.future();
}
}

View File

@@ -0,0 +1,26 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.PanBase;
import io.vertx.core.Future;
/**
* 咪咕音乐分享
*/
public class MmgTool extends PanBase {
public static final String API_URL = "";
public MmgTool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
public Future<String> parse() {
String shareUrl = shareLinkInfo.getStandardUrl();
// TODO
promise.complete("暂未实现, 敬请期待");
return promise.future();
}
}

View File

@@ -0,0 +1,59 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.PanBase;
import cn.qaiu.util.URLUtil;
import io.vertx.core.Future;
import io.vertx.uritemplate.UriTemplate;
/**
* 网易云音乐, 单歌曲直链解析
* <a href="http://163cn.tv/ykLZJJT">示例分享1</a>
* <a href="https://music.163.com/#/song?id=472194327">示例分享2</a>
*/
public class MnesTool extends PanBase {
public static final String API_URL = "https://music.163.com/song/media/outer/url?id={id}";
public MnesTool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
public Future<String> parse() {
String shareUrl = shareLinkInfo.getStandardUrl();
clientNoRedirects.getAbs(shareUrl).send().onSuccess(res -> {
String locationURL = res.headers().get("Location");
downUrl(locationURL);
}).onFailure(handleFail(shareUrl));
return promise.future();
}
protected void downUrl(String locationURL) {
String id = URLUtil.from(locationURL).getParam("id");
clientNoRedirects.getAbs(UriTemplate.of(API_URL)).setTemplateParam("id", id).send()
.onSuccess(res2 -> {
String location = res2.headers().get("Location");
if (location.endsWith("/404")) {
fail("链接已失效: id={}", id);
} else {
promise.complete(location);
}
}).onFailure(handleFail(API_URL.replace("{id}", id)));
}
public static class MneTool extends MnesTool{
public MneTool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
@Override
public Future<String> parse() {
downUrl(shareLinkInfo.getStandardUrl());
return promise.future();
}
}
}

View File

@@ -0,0 +1,78 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.PanBase;
import cn.qaiu.util.URLUtil;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
import io.vertx.uritemplate.UriTemplate;
/**
*
* QQ音乐分享解析
* <a href="https://c6.y.qq.com/base/fcgi-bin/u?__=w3lqEpOHACLO">分享示例</a>
* <a href="https://y.qq.com/n/ryqq/songDetail/000XjcLg0fbRjv?songtype=0">详情页</a>
*/
public class MqqsTool extends PanBase {
public static final String API_URL = "https://u.y.qq.com/cgi-bin/musicu" +
".fcg?-=getplaysongvkey2682247447678878&g_tk=5381&loginUin=956581739&hostUin=0&format=json&inCharset=utf8" +
"&outCharset=utf-8&notice=0&platform=yqq.json&needNewCode=0&data=%7B%22req_0%22%3A%7B%22module%22%3A" +
"%22vkey.GetVkeyServer%22%2C%22method%22%3A%22CgiGetVkey%22%2C%22param%22%3A%7B%22guid%22%3A%222796982635" +
"%22%2C%22songmid%22%3A%5B%22{songmid}%22%5D%2C%22songtype%22%3A%5B1%5D%2C%22uin%22%3A%22956581739%22" +
"%2C%22loginflag%22%3A1%2C%22platform%22%3A%2220%22%7D%7D%2C%22comm%22%3A%7B%22uin%22%3A956581739%2C" +
"%22format%22%3A%22json%22%2C%22ct%22%3A24%2C%22cv%22%3A0%7D%7D";
public MqqsTool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
public Future<String> parse() {
String shareUrl = shareLinkInfo.getStandardUrl();
// https://c6.y.qq.com/base/fcgi-bin/u?__=uXXtsB
// String shareUrl = "https://c6.y.qq.com/base/fcgi-bin/u?__=k8gafY6HAQ5Y";
clientNoRedirects.getAbs(shareUrl).send().onSuccess(res -> {
String locationURL = res.headers().get("Location");
String id = URLUtil.from(locationURL).getParam("songmid");
downUrl(id);
}).onFailure(handleFail(shareUrl));
return promise.future();
}
protected void downUrl(String id) {
clientNoRedirects.getAbs(UriTemplate.of(API_URL)).setTemplateParam("songmid", id).send().onSuccess(res2 -> {
JsonObject jsonObject = asJson(res2);
log.debug(jsonObject.encodePrettily());
try {
JsonObject data = jsonObject.getJsonObject("req_0").getJsonObject("data");
String path = data.getJsonArray("midurlinfo").getJsonObject(0).getString("purl");
if (path.isEmpty()) {
fail("暂不支持VIP音乐");
return;
}
String downURL = data.getJsonArray("sip").getString(0)
.replace("http://", "https://") + path;
promise.complete(downURL);
} catch (Exception e) {
fail("获取失败");
}
}).onFailure(handleFail(API_URL.replace("{id}", id)));
}
public static class MqqTool extends MqqsTool{
public MqqTool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
@Override
public Future<String> parse() {
downUrl(shareLinkInfo.getShareKey());
return promise.future();
}
}
}

View File

@@ -0,0 +1,22 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.PanBase;
import io.vertx.core.Future;
/**
* 其他网盘解析
*/
public class OtherTool extends PanBase {
private static final String API_URL_PREFIX = "";
public OtherTool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
public Future<String> parse() {
// TODO
fail("暂未实现, 敬请期待");
return future();
}
}

View File

@@ -0,0 +1,90 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.PanBase;
import io.vertx.core.Future;
import io.vertx.core.MultiMap;
import io.vertx.core.json.JsonObject;
import io.vertx.uritemplate.UriTemplate;
/**
* 115网盘
*
* 需要请求API的UA和请求下载链接的UA保持一致安卓Chrome需要访问电脑版才能下载
*/
public class P115Tool extends PanBase {
private static final String API_URL_PREFIX = "https://anxia.com/webapi/";
private static final String FIRST_REQUEST_URL = API_URL_PREFIX + "share/snap?share_code={dataKey}&offset=0" +
"&limit=20&receive_code={dataPwd}&cid=";
private static final String SECOND_REQUEST_URL = API_URL_PREFIX + "share/skip_login_downurl";
private static final MultiMap header;
static {
header = MultiMap.caseInsensitiveMultiMap();
header.set("Accept", "application/json, text/plain, */*");
header.set("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8");
header.set("Cache-Control", "no-cache");
header.set("Connection", "keep-alive");
header.set("Content-Length", "0");
header.set("DNT", "1");
header.set("Host", "anxia.com");
header.set("Origin", "https://anxia.com");
header.set("Pragma", "no-cache");
header.set("Referer", "https://anxia.com");
header.set("Sec-Fetch-Dest", "empty");
header.set("Sec-Fetch-Mode", "cors");
header.set("Sec-Fetch-Site", "cross-site");
header.set("sec-ch-ua", "\"Google Chrome\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\"");
header.set("sec-ch-ua-mobile", "?0");
header.set("sec-ch-ua-platform", "\"Windows\"");
}
public P115Tool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
public Future<String> parse() {
// 第一次请求 获取文件信息
client.getAbs(UriTemplate.of(FIRST_REQUEST_URL))
.putHeaders(header)
.putHeader("User-Agent", shareLinkInfo.getOtherParam().get("UA").toString())
.setTemplateParam("dataKey", shareLinkInfo.getShareKey())
.setTemplateParam("dataPwd", shareLinkInfo.getSharePassword())
.send().onSuccess(res -> {
JsonObject resJson = asJson(res);
if (!resJson.getBoolean("state")) {
fail(FIRST_REQUEST_URL + " 解析错误: " + resJson);
return;
}
// 文件Id: data.list[0].fid
JsonObject fileInfo = resJson.getJsonObject("data").getJsonArray("list").getJsonObject(0);
String fileId = fileInfo.getString("fid");
// 第二次请求
// share_code={dataKey}&receive_code={dataPwd}&file_id={file_id}
client.postAbs(SECOND_REQUEST_URL)
.putHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
.putHeader("User-Agent", shareLinkInfo.getOtherParam().get("UA").toString())
.sendForm(MultiMap.caseInsensitiveMultiMap()
.set("share_code", shareLinkInfo.getShareKey())
.set("receive_code", shareLinkInfo.getSharePassword())
.set("file_id", fileId))
.onSuccess(res2 -> {
JsonObject resJson2 = asJson(res2);
if (!resJson.getBoolean("state")) {
fail(FIRST_REQUEST_URL + " 解析错误: " + resJson);
return;
}
// data.url.url
promise.complete(resJson2.getJsonObject("data").getJsonObject("url").getString("url"));
}).onFailure(handleFail(SECOND_REQUEST_URL));
}).onFailure(handleFail(FIRST_REQUEST_URL));
return promise.future();
}
}

View File

@@ -0,0 +1,48 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.PanBase;
import io.vertx.core.Future;
import io.vertx.core.buffer.Buffer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 118网盘解析
*/
public class P118Tool extends PanBase {
private static final String API_URL_PREFIX = "https://qaiu.118pan.com/ajax.php";
// private static final String
public P118Tool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
public Future<String> parse() {
client.postAbs(API_URL_PREFIX)
.putHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
.sendBuffer(Buffer.buffer("action=load_down_addr1&file_id=" + shareLinkInfo.getShareKey()))
.onSuccess(res -> {
System.out.println(res.headers());
Pattern compile = Pattern.compile("href=\"([^\"]+)\"");
Matcher matcher = compile.matcher(res.bodyAsString());
if (matcher.find()) {
System.out.println(matcher.group(1));
complete(matcher.group(1));
} else {
fail();
}
}).onFailure(handleFail(""));
return future();
}
// public static void main(String[] args) {
// String s = new P118Tool(ShareLinkInfo.newBuilder().shareUrl("https://xiguage.118pan.com/b11848261").shareKey(
// "11848261").build()).parseSync();
// System.out.println(s);
// }
}

View File

@@ -0,0 +1,95 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.IPanTool;
import cn.qaiu.parser.PanBase;
import cn.qaiu.util.URLUtil;
import io.vertx.core.Future;
import io.vertx.core.MultiMap;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.net.ProxyOptions;
import io.vertx.ext.web.client.HttpRequest;
import io.vertx.ext.web.client.HttpResponse;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* <a href="https://www.dropbox.com/">dropbox</a>
* Dropbox网盘--不支持大陆地区
*/
public class PdbTool extends PanBase implements IPanTool {
private static final String API_URL =
"https://www.dropbox.com/sharing/fetch_user_content_link";
static final String COOKIE_KEY = "__Host-js_csrf=";
public PdbTool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
@Override
public Future<String> parse() {
// https://www.dropbox.com/scl/fi/cwnbms1yn8u6rcatzyta7/emqx-5.0.26-el7-amd64.tar.gz?rlkey=3uoi4bxz5mv93jmlaws0nlol1&e=8&st=fe0lclc2&dl=0
// https://www.dropbox.com/scl/fi/()/Get-Started-with-Dropbox.pdf?rlkey=yrddd6s9gxsq967pmbgtzvfl3&st=2trcc1f3&dl=0
//
clientSession.getAbs(shareLinkInfo.getShareUrl())
.send()
.onSuccess(res->{
List<String> collect =
res.cookies().stream().filter(key -> key.contains(COOKIE_KEY)).toList();
if (collect.isEmpty()) {
fail("cookie未找到");
return;
}
Matcher matcher = Pattern.compile(COOKIE_KEY + "([\\w-]+);").matcher(collect.get(0));
String _t;
if (matcher.find()) {
_t = matcher.group(1);
} else {
fail("cookie未找到");
return;
}
MultiMap headers = MultiMap.caseInsensitiveMultiMap();
headers.set("accept", "*/*");
headers.set("accept-language", "zh-CN,zh;q=0.9");
headers.set("cache-control", "no-cache");
headers.set("dnt", "1");
headers.set("origin", "https://www.dropbox.com");
headers.set("pragma", "no-cache");
headers.set("priority", "u=1, i");
headers.set("referer", shareLinkInfo.getShareUrl());
headers.set("sec-ch-ua", "\"Chromium\";v=\"130\", \"Microsoft Edge\";v=\"130\", \"Not?A_Brand\";v=\"99\"");
headers.set("sec-ch-ua-mobile", "?0");
headers.set("sec-ch-ua-platform", "\"Windows\"");
headers.set("sec-fetch-dest", "empty");
headers.set("sec-fetch-mode", "cors");
headers.set("sec-fetch-site", "same-origin");
headers.set("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0");
headers.set("x-dropbox-client-yaps-attribution", "edison_atlasservlet.file_viewer-edison:prod");
headers.set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
try {
URL url = new URL(shareLinkInfo.getShareUrl());
// https://www.dropbox.com/scl/fi/cwnbms1yn8u6rcatzyta7/xxx?rlkey=xx&dl=0
String u0 = URLEncoder.encode((url.getProtocol() + "://" + url.getHost() + url.getPath() + "?rlkey=%s&dl=0")
.formatted(URLUtil.from(shareLinkInfo.getShareUrl()).getParam("rlkey")), StandardCharsets.UTF_8);
clientSession.postAbs(API_URL)
.sendBuffer(Buffer.buffer("is_xhr=true&t=%s&url=%s&origin=PREVIEW_PAGE".formatted(_t, u0)))
.onSuccess(res2 -> {
complete(res2.bodyAsString());
})
.onFailure(handleFail());
} catch (Exception e) {
e.printStackTrace();
}
})
.onFailure(handleFail("请求下载链接失败"));
return future();
}
}

View File

@@ -0,0 +1,98 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
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.net.ProxyOptions;
import io.vertx.ext.web.client.HttpRequest;
import io.vertx.ext.web.client.HttpResponse;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* <a href="https://drive.google.com/">GoogleDrive</a>
* Google Drive文件解析工具.
*/
public class PgdTool extends PanBase implements IPanTool {
private static final String DOWN_URL_TEMPLATE =
"https://drive.usercontent.google.com/download";
private String downloadUrl;
public PgdTool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
@Override
public Future<String> parse() {
downloadUrl = DOWN_URL_TEMPLATE + "?id=" + shareLinkInfo.getShareKey() + "&export=download";
if (shareLinkInfo.getOtherParam().containsKey("proxy")) {
// if (shareLinkInfo.getOtherParam().containsKey("bypassCheck")
// && "true".equalsIgnoreCase(shareLinkInfo.getOtherParam().get("bypassCheck").toString())) {
// 发起请求但不真正下载文件, 只检查响应头
client.headAbs(downloadUrl).send()
.onSuccess(this::handleResponse)
.onFailure(handleFail("请求下载链接失败"));
return future();
}
complete(downloadUrl);
return future();
}
/**
* 处理下载链接的响应.
*/
private void handleResponse(HttpResponse<Buffer> response) {
String contentType = response.getHeader("Content-Type");
if (contentType != null && !contentType.contains("text/html")) {
complete(downloadUrl);
} else {
// 如果不是文件流类型,从 HTML 中解析出真实下载链接
client.getAbs(downloadUrl)
.send()
.onSuccess(res0 -> {
parseHtmlForRealLink(res0.bodyAsString());
})
.onFailure(handleFail("请求下载链接失败"));
}
}
/**
* 从HTML内容中解析真实下载链接.
*/
private void parseHtmlForRealLink(String html) {
// 使用正则表达式匹配 id、export、confirm、uuid、at 等参数
String id = extractHiddenInputValue(html, "id");
String confirm = extractHiddenInputValue(html, "confirm");
String uuid = extractHiddenInputValue(html, "uuid");
String at = extractHiddenInputValue(html, "at");
if (id != null && confirm != null && uuid != null) {
String realDownloadLink = DOWN_URL_TEMPLATE +
"?id=" + id +
"&export=download" +
"&confirm=" + confirm +
"&uuid=" + uuid;
if (at != null) {
realDownloadLink += ( "&at=" + at);
}
complete(realDownloadLink);
} else {
fail("无法找到完整的下载链接参数");
}
}
/**
* 辅助方法: 从HTML中提取指定name的input隐藏字段的value
*/
private String extractHiddenInputValue(String html, String name) {
Pattern pattern = Pattern.compile("<input[^>]*name=\"" + name + "\"[^>]*value=\"([^\"]*)\"");
Matcher matcher = pattern.matcher(html);
return matcher.find() ? matcher.group(1) : null;
}
}

View File

@@ -0,0 +1,58 @@
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.icloud.com.cn/">iCloud云盘(pic)</a>
*/
public class PicTool extends PanBase {
private static final String api = "https://ckdatabasews.icloud.com.cn/database/1/com.apple.cloudkit/production/public/records/resolve";
public PicTool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
public Future<String> parse() {
// {"shortGUIDs":[{"value":"xxx"}]}
JsonObject jsonObject =
new JsonObject("{\"shortGUIDs\":[{\"value\":\"%s\"}]}".formatted(shareLinkInfo.getShareKey()));
client.postAbs(api).sendJsonObject(jsonObject).onSuccess(res -> {
// results->rootRecord->fields->fileContent->value->downloadURL // ${f}->fileName
// fileName: results->share->fields->cloudkit.title->value + "." + results->rootRecord->fields->extension->value
JsonObject json = asJson(res);
try {
JsonObject result = json.getJsonArray("results").getJsonObject(0);
JsonObject fileInfo = result
.getJsonObject("rootRecord")
.getJsonObject("fields");
String downURL = fileInfo
.getJsonObject("fileContent")
.getJsonObject("value")
.getString("downloadURL");
String extension = fileInfo
.getJsonObject("extension")
.getString("value");
String fileTitle = result
.getJsonObject("share")
.getJsonObject("fields")
.getJsonObject("cloudkit.title")
.getString("value");
complete(downURL.replace("${f}", fileTitle + "." + extension));
} catch (Exception e) {
fail(e, "json解析失败");
}
}).onFailure(handleFail());
return promise.future();
}
}

View File

@@ -0,0 +1,231 @@
package cn.qaiu.parser.impl;
import cn.qaiu.WebClientVertxInit;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.PanBase;
import io.vertx.core.Future;
import io.vertx.core.Promise;
import io.vertx.core.WorkerExecutor;
import io.vertx.core.json.JsonObject;
import io.vertx.uritemplate.UriTemplate;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* <a href="https://onedrive.live.com/">onedrive分享(od)</a>
*/
public class PodTool extends PanBase {
/*
* https://1drv.ms/w/s!Alg0feQmCv2rnRFd60DQOmMa-Oh_?e=buaRtp --302->
* https://api.onedrive.com/v1.0/drives/abfd0a26e47d3458/items/ABFD0A26E47D3458!3729?authkey=!AF3rQNA6Yxr46H8
* https://onedrive.live.com/redir?resid=(?<cid>)!(?<cid2>)&authkey=(?<authkey>)&e=hV98W1
* cid: abfd0a26e47d3458, cid2: ABFD0A26E47D3458!3729 authkey: !AF3rQNA6Yxr46H8
* -> @content.downloadUrl
*/
// https://onedrive.live.com/redir?resid=ABFD0A26E47D3458!4699&e=OggA4s&migratedtospo=true&redeem=aHR0cHM6Ly8xZHJ2Lm1zL3UvcyFBbGcwZmVRbUN2MnJwRnZ1NDQ0aGc1eVZxRGNLP2U9T2dnQTRz
private static final String API_TEMPLATE = "https://onedrive.live.com/embed" +
"?id={resid}&resid={resid1}" +
"&cid={cid}" +
"&redeem={redeem}" +
"&migratedtospo=true&embed=1";
private static final String TOKEN_API = "https://api-badgerp.svc.ms/v1.0/token";
private static final Pattern redirectUrlRegex =
Pattern.compile("resid=(?<cid1>[^!]+)!(?<cid2>[^&]+).+&redeem=(?<redeem>.+).*");
public PodTool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
public Future<String> parse() {
/*
* POST https://api-badgerp.svc.ms/v1.0/token
* Content-Type: application/json
*
* {
* "appid": "00000000-0000-0000-0000-0000481710a4"
* }
*/
// https://my.microsoftpersonalcontent.com/_api/v2.0/shares/u!aHR0cHM6Ly8xZHJ2Lm1zL3UvcyFBbGcwZmVRbUN2MnJwRnZ1NDQ0aGc1eVZxRGNLP2U9T2dnQTRz/driveitem?%24select=*%2Cocr%2CwebDavUrl
// https://onedrive.live.com/embed?id=ABFD0A26E47D3458!4698&resid=ABFD0A26E47D3458!4698&cid=abfd0a26e47d3458&redeem=aHR0cHM6Ly8xZHJ2Lm1zL3UvYy9hYmZkMGEyNmU0N2QzNDU4L0lRUllOSDNrSmdyOUlJQ3JXaElBQUFBQUFTWGlubWZ2WmNxYUQyMXJUQjIxVmg4&migratedtospo=true&embed=1
clientNoRedirects.getAbs(shareLinkInfo.getShareUrl() == null ? shareLinkInfo.getStandardUrl() :
shareLinkInfo.getShareUrl()).send().onSuccess(r0 -> {
String location = r0.getHeader("Location");
Matcher matcher = redirectUrlRegex.matcher(location);
if (!matcher.find()) {
fail("Location格式错误");
return;
}
String redeem = matcher.group("redeem");
String cid1 = matcher.group("cid1");
String cid2 = cid1 + "!" + matcher.group("cid2");
clientNoRedirects.getAbs(UriTemplate.of(API_TEMPLATE))
.setTemplateParam("resid", cid2)
.setTemplateParam("resid1", cid2)
.setTemplateParam("cid", cid1.toLowerCase())
.setTemplateParam("redeem", redeem)
.send()
.onSuccess(r1 -> {
String auth =
r1.cookies().stream().filter(c -> c.startsWith("BadgerAuth=")).findFirst().orElse("");
if (auth.isEmpty()) {
fail("Error BadgerAuth not fount");
return;
}
String token = auth.split(";")[0].split("=")[1];
try {
String url = matcherUrl(r1.bodyAsString());
sendHttpRequest(url, token).onSuccess(body -> {
Matcher matcher1 =
Pattern.compile("\"downloadUrl\":\"(?<url>https?://[^\s\"]+)").matcher(body);
if (matcher1.find()) {
complete(matcher1.group("url"));
} else {
fail();
}
}).onFailure(handleFail());
} catch (Exception ignored) {
sendHttpRequest2(token, redeem).onSuccess(res -> {
try {
complete(new JsonObject(res).getString("@content.downloadUrl"));
} catch (Exception ignored1) {
fail();
}
}).onFailure(handleFail());
}
}).onFailure(handleFail());
}).onFailure(handleFail());
return promise.future();
}
private String matcherUrl(String html) {
// 正则表达式来匹配 URL
String urlRegex = "'action'.+(?<url>https://.+)'\\)";
Pattern urlPattern = Pattern.compile(urlRegex);
Matcher urlMatcher = urlPattern.matcher(html);
if (urlMatcher.find()) {
String url = urlMatcher.group("url");
System.out.println("URL: " + url);
return url;
}
throw new RuntimeException("URL匹配失败");
}
private String matcherToken(String html) {
// 正则表达式来匹配 inputElem.value 中的 Token
String tokenRegex = "inputElem\\.value\\s*=\\s*'([^']+)'";
Pattern tokenPattern = Pattern.compile(tokenRegex);
Matcher tokenMatcher = tokenPattern.matcher(html);
if (tokenMatcher.find()) {
String token = tokenMatcher.group(1);
System.out.println("Token: " + token);
return token;
}
throw new RuntimeException("token匹配失败");
}
public Future<String> sendHttpRequest2(String token, String redeem) {
Promise<String> promise = Promise.promise();
// 构造 HttpClient
HttpClient client = HttpClient.newHttpClient();
// 构造请求的 URI 和头部信息
// https://onedrive.live.com/redir?cid=abfd0a26e47d3458&resid=ABFD0A26E47D3458!4465&ithint=file%2cxlsx&e=Ao2uSU&migratedtospo=true&redeem=aHR0cHM6Ly8xZHJ2Lm1zL3gvYy9hYmZkMGEyNmU0N2QzNDU4L0VWZzBmZVFtQ3YwZ2dLdHhFUUFBQUFBQlRQRWVDMTZfZk1EYk5FTjhEdTRta1E_ZT1BbzJ1U1U
String url = ("https://my.microsoftpersonalcontent.com/_api/v2.0/shares/u!%s/driveItem?$select=content" +
".downloadUrl").formatted(redeem);
String authorizationHeader = "Badger " + token;
// 构建请求
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", authorizationHeader)
.build();
// 发送请求并处理响应
client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
.thenApply(response -> {
System.out.println("Response Status Code: " + response.statusCode());
System.out.println("Response Body: " + response.body());
promise.complete(response.body());
return null;
});
return promise.future();
}
public Future<String> sendHttpRequest(String url, String token) {
// 创建一个 WorkerExecutor 用于异步执行阻塞的 HTTP 请求
WorkerExecutor executor = WebClientVertxInit.get().createSharedWorkerExecutor("http-client-worker");
Promise<String> promise = Promise.promise();
executor.executeBlocking(() -> {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = null;
try {
// 构造请求
request = HttpRequest.newBuilder()
.uri(new URI(url))
.header("accept", "text/html,application/xhtml+xml,application/xml;q=0.9," +
"image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;" +
"v=b3;q=0.7")
.header("accept-language", "zh-CN,zh;q=0.9")
.header("cache-control", "no-cache")
.header("content-type", "application/x-www-form-urlencoded")
.header("dnt", "1")
.header("origin", "https://onedrive.live.com")
.header("pragma", "no-cache")
.header("priority", "u=0, i")
.header("referer", "https://onedrive.live.com/")
.header("sec-ch-ua", "\"Chromium\";v=\"130\", \"Google Chrome\";v=\"130\", " +
"\"Not?A_Brand\";v=\"99\"")
.header("sec-ch-ua-mobile", "?0")
.header("sec-ch-ua-platform", "\"Windows\"")
.header("sec-fetch-dest", "iframe")
.header("sec-fetch-mode", "navigate")
.header("sec-fetch-site", "cross-site")
.header("upgrade-insecure-requests", "1")
.header("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537" +
".36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36")
.POST(HttpRequest.BodyPublishers.ofString("badger_token=" + token))
.build();
// 发起请求并获取响应
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
// 返回响应体
promise.complete(response.body());
return null;
} catch (URISyntaxException | IOException | InterruptedException e) {
throw new RuntimeException(e);
}
});
return promise.future();
}
}

View File

@@ -0,0 +1,51 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.PanBase;
import io.vertx.core.Future;
import io.vertx.uritemplate.UriTemplate;
/**
* 微雨云
*/
public class PvyyTool extends PanBase {
private static final String API_URL_PREFIX1 = "https://www.vyuyun.com/apiv1/share/file/{key}?password={pwd}";
private static final String API_URL_PREFIX2 = "https://www.vyuyun.com/apiv1/share/getShareDownUrl/{key}/{id}?password={pwd}";
public PvyyTool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);
}
public Future<String> parse() {
//
client.getAbs(UriTemplate.of(API_URL_PREFIX1))
.setTemplateParam("key", shareLinkInfo.getShareKey())
.setTemplateParam("pwd", shareLinkInfo.getSharePassword())
.putHeader("referer", "https://www.vyuyun.com")
.send().onSuccess(res -> {
try {
String id = asJson(res).getJsonObject("data").getJsonObject("data").getString("id");
client.getAbs(UriTemplate.of(API_URL_PREFIX2))
.setTemplateParam("key", shareLinkInfo.getShareKey())
.setTemplateParam("pwd", shareLinkInfo.getSharePassword())
.setTemplateParam("id", id)
.putHeader("referer", "https://www.vyuyun.com")
.send().onSuccess(res2 -> {
try {
// data->downInfo->url
String url =
asJson(res2).getJsonObject("data").getJsonObject("downInfo").getString("url");
complete(url);
} catch (Exception ignored) {
fail(asJson(res2).encodePrettily());
}
});
} catch (Exception ignored) {
fail(asJson(res).encodePrettily());
}
});
return future();
}
}

View File

@@ -1,7 +1,6 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.IPanTool;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.PanBase;
import cn.qaiu.util.StringUtils;
import io.netty.handler.codec.http.QueryStringDecoder;
@@ -15,7 +14,7 @@ import java.util.Map;
/**
* <a href="https://wx.mail.qq.com/">QQ邮箱</a>
*/
public class QQTool extends PanBase implements IPanTool {
public class QQTool extends PanBase {
public static final String REDIRECT_URL_TEMP = "https://iwx.mail.qq.com/ftn/download?func=4&key={key}&code={code}";

View File

@@ -1,14 +1,13 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.IPanTool;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.PanBase;
import io.vertx.core.Future;
import java.util.concurrent.TimeUnit;
import java.util.stream.IntStream;
public class QkTool extends PanBase implements IPanTool {
public class QkTool extends PanBase {
public QkTool(ShareLinkInfo shareLinkInfo) {
super(shareLinkInfo);

View File

@@ -1,7 +1,6 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.IPanTool;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.PanBase;
import io.vertx.core.Future;
import io.vertx.core.MultiMap;
@@ -15,7 +14,7 @@ import java.nio.charset.StandardCharsets;
/**
* <a href="https://www.wenshushu.cn/">文叔叔</a>
*/
public class WsTool extends PanBase implements IPanTool {
public class WsTool extends PanBase {
public static final String SHARE_URL_PREFIX = "www.wenshushu.cn/f/";
public static final String SHARE_URL_API = "https://www.wenshushu.cn/ap/";

View File

@@ -1,7 +1,6 @@
package cn.qaiu.parser.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.IPanTool;
import cn.qaiu.parser.PanBase;
import cn.qaiu.util.CommonUtils;
import cn.qaiu.util.JsExecUtils;
@@ -21,7 +20,7 @@ import java.util.regex.Pattern;
/**
* 123网盘
*/
public class YeTool extends PanBase implements IPanTool {
public class YeTool extends PanBase {
public static final String SHARE_URL_PREFIX = "https://www.123pan.com/s/";
public static final String FIRST_REQUEST_URL = SHARE_URL_PREFIX + "{key}.html";
@@ -43,11 +42,17 @@ public class YeTool extends PanBase implements IPanTool {
client.getAbs(UriTemplate.of(FIRST_REQUEST_URL)).setTemplateParam("key", dataKey).send().onSuccess(res -> {
String html = res.bodyAsString();
// 判断分享是否已经失效
if (html.contains("分享链接已失效")) {
fail("该分享已失效({})已失效", shareLinkInfo.getShareUrl());
return;
}
Pattern compile = Pattern.compile("window.g_initialProps\\s*=\\s*(.*);");
Matcher matcher = compile.matcher(html);
if (!matcher.find()) {
fail(html + "\n Ye: " + dataKey + " 正则匹配失败");
fail("该分享({})文件信息找不到, 可能分享已失效", shareLinkInfo.getShareUrl());
return;
}
String fileInfoString = matcher.group(1);
@@ -60,6 +65,7 @@ public class YeTool extends PanBase implements IPanTool {
return;
}
String shareKey = resJson.getJsonObject("data").getString("ShareKey");
if (resListJson == null || resListJson.getInteger("code") != 0) {
// 加密分享
if (StringUtils.isNotEmpty(pwd)) {

View File

@@ -1,19 +1,22 @@
package cn.qaiu.util;
import io.vertx.core.net.impl.URIDecoder;
import org.apache.commons.lang3.StringUtils;
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
import java.math.BigInteger;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.*;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
import java.util.Date;
import java.util.HexFormat;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* AES加解密工具类
@@ -39,6 +42,12 @@ public class AESUtils {
public static final String CIPHER_AES0;
public static final String CIPHER_AES0_IZ;
public static final String MG_PKEY2 = "D8jg+H2iNX94zvHhRLnSM3oy59dH2QQjxQ0GgKJSL+mJclbCcItjV3AmkPY6WcbV4hNQk5+hN2J1eTrxPQqF4p28e3FTsGRCXVN80CLS+XqpFNY/9xuyf2bvbeq5JJU1IBCXgSZmEo8zu0/VGS3YNeDsHtjg92QSrRY8i4A+shihZBSz0/0KOL1VPd/K4tAYvsI9YjVFOI7z9mJJ8Ek8rVUplurJyGkjevRfvReN7xQ67PR+yZovk72yTZKlHDz5jVpLGLOy2iwTTSTbTvtnOi9TSE6sSPtRHv16cxZYZQY=";
public static final String MG_PKEY;
public static final String MG_KEY = "4ea5c508a6566e76240543f8feb06fd457777be39549c4016436afda65d2330e";
/**
* 秘钥长度
*/
@@ -63,6 +72,7 @@ public class AESUtils {
try {
CIPHER_AES0 = decryptByBase64AES(CIPHER_AES2, CIPHER_AES);
CIPHER_AES0_IZ = decryptByBase64AES(CIPHER_AES2_IZ, CIPHER_AES);
MG_PKEY = decryptByBase64AES(MG_PKEY2, CIPHER_AES2);
} catch (IllegalBlockSizeException | BadPaddingException | NoSuchPaddingException | NoSuchAlgorithmException |
InvalidKeyException e) {
throw new RuntimeException(e);
@@ -329,4 +339,73 @@ public class AESUtils {
return _0x53928f + "-" + _0x430930 + "-" + _0x49ec94;
}
public static String encrypt(String str, String pwd) {
if (pwd == null || pwd.length() <= 0) {
throw new IllegalArgumentException("Please enter a password with which to encrypt the message.");
}
// 生成 prand 值
StringBuilder prand = new StringBuilder();
for (int i = 0; i < pwd.length(); i++) {
prand.append((int) pwd.charAt(i));
}
// 计算 sPos, mult, incr, modu
int sPos = prand.length() / 5;
long mult = Long.parseLong(prand.substring(sPos, sPos + 1) +
prand.substring(sPos * 2, sPos * 2 + 1) +
prand.substring(sPos * 3, sPos * 3 + 1) +
prand.substring(sPos * 4, sPos * 4 + 1) +
prand.substring(sPos * 5, sPos * 5 + 1));
int incr = (int) Math.ceil(pwd.length() / 2.0);
long modu = (long) Math.pow(2, 31) - 1;
if (mult < 2) {
throw new IllegalArgumentException("Algorithm cannot find a suitable hash. Please choose a different password.");
}
// 生成 salt 并加到 prand 上
long salt = Math.round(Math.random() * 1000000000) % 100000000;
prand.append(salt);
// 使用 BigInteger 处理超过 Long 范围的 prand 值
BigInteger prandValue = new BigInteger(prand.toString());
while (prandValue.toString().length() > 10) {
prandValue = prandValue.divide(BigInteger.TEN).add(prandValue.remainder(BigInteger.TEN));
}
// 将 prand 转换为 long 进行后续处理
prandValue = prandValue.multiply(BigInteger.valueOf(mult)).add(BigInteger.valueOf(incr)).mod(BigInteger.valueOf(modu));
// 加密过程
StringBuilder encStr = new StringBuilder();
for (int i = 0; i < str.length(); i++) {
// 将字符和异或的结果强制转换为 int
int encChr = (int) (str.charAt(i) ^ (int) ((prandValue.doubleValue() / modu) * 255));
String hexStr = Integer.toHexString(encChr);
if (hexStr.length() < 2) {
encStr.append("0");
}
encStr.append(hexStr);
prandValue = prandValue.multiply(BigInteger.valueOf(mult)).add(BigInteger.valueOf(incr)).mod(BigInteger.valueOf(modu));
}
// 将 salt 转换为 16 进制并追加到加密结果
String saltHex = Long.toHexString(salt);
while (saltHex.length() < 8) {
saltHex = "0" + saltHex;
}
encStr.append(saltHex);
return encStr.toString();
}
public static void main(String[] args) {
// 示例
String encrypted = encrypt("HelloWorld", "password123");
System.out.println("Encrypted String: " + encrypted);
}
}

View File

@@ -149,4 +149,909 @@ public interface JsContent {
""";
String kwSignString = """
function encrypt(str, pwd) {
if (pwd == null || pwd.length <= 0) {
return null;
}
var prand = "";
for (var i = 0; i < pwd.length; i++) {
prand += pwd.charCodeAt(i).toString();
}
var sPos = Math.floor(prand.length / 5);
var mult = parseInt(prand.charAt(sPos) + prand.charAt(sPos * 2) + prand.charAt(sPos * 3) + prand.charAt(sPos * 4) + prand.charAt(sPos * 5));
var incr = Math.ceil(pwd.length / 2);
var modu = Math.pow(2, 31) - 1;
if (mult < 2) {
return null;
}
var salt = Math.round(Math.random() * 1000000000) % 100000000;
prand += salt;
var flag = 1;
while (prand.length > 10) {
prand = (parseInt(prand.substring(0, 10)) + (flag ?parseFloat(prand.substring(10, prand.length)) : parseInt(prand.substring(10, prand.length)) )).toString();
flag = 0;
}
prand = (mult * prand + incr) % modu;
var enc_chr = "";
var enc_str = "";
for (var i = 0; i < str.length; i++) {
enc_chr = parseInt(str.charCodeAt(i) ^ Math.floor((prand / modu) * 255));
if (enc_chr < 16) {
enc_str += "0" + enc_chr.toString(16);
} else enc_str += enc_chr.toString(16);
prand = (mult * prand + incr) % modu;
}
salt = salt.toString(16);
while (salt.length < 8) salt = "0" + salt;
enc_str += salt;
return enc_str;
}
""";
String mgJS = """
var XO, qO = {
exports: {}
}, JO = {
exports: {}
};
var qb = globalThis = this
JO.exports = (XO = XO || function (e, t) {
var n;
if ("undefined" != typeof window && window.crypto && (n = window.crypto),
"undefined" != typeof self && self.crypto && (n = self.crypto),
"undefined" != typeof globalThis && globalThis.crypto && (n = globalThis.crypto),
!n && "undefined" != typeof window && window.msCrypto && (n = window.msCrypto),
!n && void 0 !== qb && qb.crypto && (n = qb.crypto),
!n)
try {
n = require("crypto")
} catch (g) {
}
var r = function () {
return Math.floor(Math.random() * 0xFFFFFFFF + 0)
}
, o = Object.create || function () {
function e() {
}
return function (t) {
var n;
return e.prototype = t,
n = new e,
e.prototype = null,
n
}
}()
, a = {}
, i = a.lib = {}
, l = i.Base = {
extend: function (e) {
var t = o(this);
return e && t.mixIn(e),
t.hasOwnProperty("init") && this.init !== t.init || (t.init = function () {
t.$super.init.apply(this, arguments)
}
),
t.init.prototype = t,
t.$super = this,
t
},
create: function () {
var e = this.extend();
return e.init.apply(e, arguments),
e
},
init: function () {
},
mixIn: function (e) {
for (var t in e)
e.hasOwnProperty(t) && (this[t] = e[t]);
e.hasOwnProperty("toString") && (this.toString = e.toString)
},
clone: function () {
return this.init.prototype.extend(this)
}
}
, s = i.WordArray = l.extend({
init: function (e, n) {
e = this.words = e || [],
this.sigBytes = n != t ? n : 4 * e.length
},
toString: function (e) {
return (e || c).stringify(this)
},
concat: function (e) {
var t = this.words
, n = e.words
, r = this.sigBytes
, o = e.sigBytes;
if (this.clamp(),
r % 4)
for (var a = 0; a < o; a++) {
var i = n[a >>> 2] >>> 24 - a % 4 * 8 & 255;
t[r + a >>> 2] |= i << 24 - (r + a) % 4 * 8
}
else
for (var l = 0; l < o; l += 4)
t[r + l >>> 2] = n[l >>> 2];
return this.sigBytes += o,
this
},
clamp: function () {
var t = this.words
, n = this.sigBytes;
t[n >>> 2] &= 4294967295 << 32 - n % 4 * 8,
t.length = e.ceil(n / 4)
},
clone: function () {
var e = l.clone.call(this);
return e.words = this.words.slice(0),
e
},
random: function (e) {
for (var t = [], n = 0; n < e; n += 4)
t.push(r());
return new s.init(t, e)
}
})
, u = a.enc = {}
, c = u.Hex = {
stringify: function (e) {
for (var t = e.words, n = e.sigBytes, r = [], o = 0; o < n; o++) {
var a = t[o >>> 2] >>> 24 - o % 4 * 8 & 255;
r.push((a >>> 4).toString(16)),
r.push((15 & a).toString(16))
}
return r.join("")
},
parse: function (e) {
for (var t = e.length, n = [], r = 0; r < t; r += 2)
n[r >>> 3] |= parseInt(e.substr(r, 2), 16) << 24 - r % 8 * 4;
return new s.init(n, t / 2)
}
}
, d = u.Latin1 = {
stringify: function (e) {
for (var t = e.words, n = e.sigBytes, r = [], o = 0; o < n; o++) {
var a = t[o >>> 2] >>> 24 - o % 4 * 8 & 255;
r.push(String.fromCharCode(a))
}
return r.join("")
},
parse: function (e) {
for (var t = e.length, n = [], r = 0; r < t; r++)
n[r >>> 2] |= (255 & e.charCodeAt(r)) << 24 - r % 4 * 8;
return new s.init(n, t)
}
}
, p = u.Utf8 = {
stringify: function (e) {
try {
return decodeURIComponent(escape(d.stringify(e)))
} catch (RE) {
throw new Error("Malformed UTF-8 data")
}
},
parse: function (e) {
return d.parse(unescape(encodeURIComponent(e)))
}
}
, f = i.BufferedBlockAlgorithm = l.extend({
reset: function () {
this._data = new s.init,
this._nDataBytes = 0
},
_append: function (e) {
"string" == typeof e && (e = p.parse(e)),
this._data.concat(e),
this._nDataBytes += e.sigBytes
},
_process: function (t) {
var n, r = this._data, o = r.words, a = r.sigBytes, i = this.blockSize, l = a / (4 * i),
u = (l = t ? e.ceil(l) : e.max((0 | l) - this._minBufferSize, 0)) * i, c = e.min(4 * u, a);
if (u) {
for (var d = 0; d < u; d += i)
this._doProcessBlock(o, d);
n = o.splice(0, u),
r.sigBytes -= c
}
return new s.init(n, c)
},
clone: function () {
var e = l.clone.call(this);
return e._data = this._data.clone(),
e
},
_minBufferSize: 0
});
i.Hasher = f.extend({
cfg: l.extend(),
init: function (e) {
this.cfg = this.cfg.extend(e),
this.reset()
},
reset: function () {
f.reset.call(this),
this._doReset()
},
update: function (e) {
return this._append(e),
this._process(),
this
},
finalize: function (e) {
return e && this._append(e),
this._doFinalize()
},
blockSize: 16,
_createHelper: function (e) {
return function (t, n) {
return new e.init(n).finalize(t)
}
},
_createHmacHelper: function (e) {
return function (t, n) {
return new h.HMAC.init(e, n).finalize(t)
}
}
});
var h = a.algo = {};
return a
}(Math), XO);
var QO = {
exports: {}
};
QO.exports = function (e) {
return r = (n = e).lib,
o = r.Base,
a = r.WordArray,
(i = n.x64 = {}).Word = o.extend({
init: function (e, t) {
this.high = e,
this.low = t
}
}),
i.WordArray = o.extend({
init: function (e, n) {
e = this.words = e || [],
this.sigBytes = n != t ? n : 8 * e.length
},
toX32: function () {
for (var e = this.words, t = e.length, n = [], r = 0; r < t; r++) {
var o = e[r];
n.push(o.high),
n.push(o.low)
}
return a.create(n, this.sigBytes)
},
clone: function () {
for (var e = o.clone.call(this), t = e.words = this.words.slice(0), n = t.length, r = 0; r < n; r++)
t[r] = t[r].clone();
return e
}
}),
e;
var t, n, r, o, a, i
}(JO.exports);
var nM = {
exports: {}
};
nM.exports = function (e) {
return function () {
var t = e
, n = t.lib.WordArray;
function r(e, t, r) {
for (var o = [], a = 0, i = 0; i < t; i++)
if (i % 4) {
var l = r[e.charCodeAt(i - 1)] << i % 4 * 2 | r[e.charCodeAt(i)] >>> 6 - i % 4 * 2;
o[a >>> 2] |= l << 24 - a % 4 * 8,
a++
}
return n.create(o, a)
}
t.enc.Base64 = {
stringify: function (e) {
var t = e.words
, n = e.sigBytes
, r = this._map;
e.clamp();
for (var o = [], a = 0; a < n; a += 3)
for (var i = (t[a >>> 2] >>> 24 - a % 4 * 8 & 255) << 16 | (t[a + 1 >>> 2] >>> 24 - (a + 1) % 4 * 8 & 255) << 8 | t[a + 2 >>> 2] >>> 24 - (a + 2) % 4 * 8 & 255, l = 0; l < 4 && a + .75 * l < n; l++)
o.push(r.charAt(i >>> 6 * (3 - l) & 63));
var s = r.charAt(64);
if (s)
for (; o.length % 4;)
o.push(s);
return o.join("")
},
parse: function (e) {
var t = e.length
, n = this._map
, o = this._reverseMap;
if (!o) {
o = this._reverseMap = [];
for (var a = 0; a < n.length; a++)
o[n.charCodeAt(a)] = a
}
var i = n.charAt(64);
if (i) {
var l = e.indexOf(i);
-1 !== l && (t = l)
}
return r(e, t, o)
},
_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
}
}(),
e.enc.Base64
}(JO.exports);
var oM = {
exports: {}
};
oM.exports = function (e) {
return function (t) {
var n = e
, r = n.lib
, o = r.WordArray
, a = r.Hasher
, i = n.algo
, l = [];
!function () {
for (var e = 0; e < 64; e++)
l[e] = 4294967296 * t.abs(t.sin(e + 1)) | 0
}();
var s = i.MD5 = a.extend({
_doReset: function () {
this._hash = new o.init([1732584193, 4023233417, 2562383102, 271733878])
},
_doProcessBlock: function (e, t) {
for (var n = 0; n < 16; n++) {
var r = t + n
, o = e[r];
e[r] = 16711935 & (o << 8 | o >>> 24) | 4278255360 & (o << 24 | o >>> 8)
}
var a = this._hash.words
, i = e[t + 0]
, s = e[t + 1]
, f = e[t + 2]
, h = e[t + 3]
, g = e[t + 4]
, v = e[t + 5]
, m = e[t + 6]
, y = e[t + 7]
, b = e[t + 8]
, C = e[t + 9]
, _ = e[t + 10]
, E = e[t + 11]
, F = e[t + 12]
, A = e[t + 13]
, w = e[t + 14]
, D = e[t + 15]
, x = a[0]
, S = a[1]
, B = a[2]
, k = a[3];
x = u(x, S, B, k, i, 7, l[0]),
k = u(k, x, S, B, s, 12, l[1]),
B = u(B, k, x, S, f, 17, l[2]),
S = u(S, B, k, x, h, 22, l[3]),
x = u(x, S, B, k, g, 7, l[4]),
k = u(k, x, S, B, v, 12, l[5]),
B = u(B, k, x, S, m, 17, l[6]),
S = u(S, B, k, x, y, 22, l[7]),
x = u(x, S, B, k, b, 7, l[8]),
k = u(k, x, S, B, C, 12, l[9]),
B = u(B, k, x, S, _, 17, l[10]),
S = u(S, B, k, x, E, 22, l[11]),
x = u(x, S, B, k, F, 7, l[12]),
k = u(k, x, S, B, A, 12, l[13]),
B = u(B, k, x, S, w, 17, l[14]),
x = c(x, S = u(S, B, k, x, D, 22, l[15]), B, k, s, 5, l[16]),
k = c(k, x, S, B, m, 9, l[17]),
B = c(B, k, x, S, E, 14, l[18]),
S = c(S, B, k, x, i, 20, l[19]),
x = c(x, S, B, k, v, 5, l[20]),
k = c(k, x, S, B, _, 9, l[21]),
B = c(B, k, x, S, D, 14, l[22]),
S = c(S, B, k, x, g, 20, l[23]),
x = c(x, S, B, k, C, 5, l[24]),
k = c(k, x, S, B, w, 9, l[25]),
B = c(B, k, x, S, h, 14, l[26]),
S = c(S, B, k, x, b, 20, l[27]),
x = c(x, S, B, k, A, 5, l[28]),
k = c(k, x, S, B, f, 9, l[29]),
B = c(B, k, x, S, y, 14, l[30]),
x = d(x, S = c(S, B, k, x, F, 20, l[31]), B, k, v, 4, l[32]),
k = d(k, x, S, B, b, 11, l[33]),
B = d(B, k, x, S, E, 16, l[34]),
S = d(S, B, k, x, w, 23, l[35]),
x = d(x, S, B, k, s, 4, l[36]),
k = d(k, x, S, B, g, 11, l[37]),
B = d(B, k, x, S, y, 16, l[38]),
S = d(S, B, k, x, _, 23, l[39]),
x = d(x, S, B, k, A, 4, l[40]),
k = d(k, x, S, B, i, 11, l[41]),
B = d(B, k, x, S, h, 16, l[42]),
S = d(S, B, k, x, m, 23, l[43]),
x = d(x, S, B, k, C, 4, l[44]),
k = d(k, x, S, B, F, 11, l[45]),
B = d(B, k, x, S, D, 16, l[46]),
x = p(x, S = d(S, B, k, x, f, 23, l[47]), B, k, i, 6, l[48]),
k = p(k, x, S, B, y, 10, l[49]),
B = p(B, k, x, S, w, 15, l[50]),
S = p(S, B, k, x, v, 21, l[51]),
x = p(x, S, B, k, F, 6, l[52]),
k = p(k, x, S, B, h, 10, l[53]),
B = p(B, k, x, S, _, 15, l[54]),
S = p(S, B, k, x, s, 21, l[55]),
x = p(x, S, B, k, b, 6, l[56]),
k = p(k, x, S, B, D, 10, l[57]),
B = p(B, k, x, S, m, 15, l[58]),
S = p(S, B, k, x, A, 21, l[59]),
x = p(x, S, B, k, g, 6, l[60]),
k = p(k, x, S, B, E, 10, l[61]),
B = p(B, k, x, S, f, 15, l[62]),
S = p(S, B, k, x, C, 21, l[63]),
a[0] = a[0] + x | 0,
a[1] = a[1] + S | 0,
a[2] = a[2] + B | 0,
a[3] = a[3] + k | 0
},
_doFinalize: function () {
var e = this._data
, n = e.words
, r = 8 * this._nDataBytes
, o = 8 * e.sigBytes;
n[o >>> 5] |= 128 << 24 - o % 32;
var a = t.floor(r / 4294967296)
, i = r;
n[15 + (o + 64 >>> 9 << 4)] = 16711935 & (a << 8 | a >>> 24) | 4278255360 & (a << 24 | a >>> 8),
n[14 + (o + 64 >>> 9 << 4)] = 16711935 & (i << 8 | i >>> 24) | 4278255360 & (i << 24 | i >>> 8),
e.sigBytes = 4 * (n.length + 1),
this._process();
for (var l = this._hash, s = l.words, u = 0; u < 4; u++) {
var c = s[u];
s[u] = 16711935 & (c << 8 | c >>> 24) | 4278255360 & (c << 24 | c >>> 8)
}
return l
},
clone: function () {
var e = a.clone.call(this);
return e._hash = this._hash.clone(),
e
}
});
function u(e, t, n, r, o, a, i) {
var l = e + (t & n | ~t & r) + o + i;
return (l << a | l >>> 32 - a) + t
}
function c(e, t, n, r, o, a, i) {
var l = e + (t & r | n & ~r) + o + i;
return (l << a | l >>> 32 - a) + t
}
function d(e, t, n, r, o, a, i) {
var l = e + (t ^ n ^ r) + o + i;
return (l << a | l >>> 32 - a) + t
}
function p(e, t, n, r, o, a, i) {
var l = e + (n ^ (t | ~r)) + o + i;
return (l << a | l >>> 32 - a) + t
}
n.MD5 = a._createHelper(s),
n.HmacMD5 = a._createHmacHelper(s)
}(Math),
e.MD5
}(JO.exports);
var hM = {
exports: {}
};
hM.exports = function (e) {
return n = (t = e).lib,
r = n.Base,
o = n.WordArray,
a = t.algo,
i = a.MD5,
l = a.EvpKDF = r.extend({
cfg: r.extend({
keySize: 4,
hasher: i,
iterations: 1
}),
init: function (e) {
this.cfg = this.cfg.extend(e)
},
compute: function (e, t) {
for (var n, r = this.cfg, a = r.hasher.create(), i = o.create(), l = i.words, s = r.keySize, u = r.iterations; l.length < s;) {
n && a.update(n),
n = a.update(e).finalize(t),
a.reset();
for (var c = 1; c < u; c++)
n = a.finalize(n),
a.reset();
i.concat(n)
}
return i.sigBytes = 4 * s,
i
}
}),
t.EvpKDF = function (e, t, n) {
return l.create(n).compute(e, t)
}
,
e.EvpKDF;
var t, n, r, o, a, i, l
}(JO.exports);
var gM = {
exports: {}
};
gM.exports = function (e) {
e.lib.Cipher || function (t) {
var n = e
, r = n.lib
, o = r.Base
, a = r.WordArray
, i = r.BufferedBlockAlgorithm
, l = n.enc;
l.Utf8;
var s = l.Base64
, u = n.algo.EvpKDF
, c = r.Cipher = i.extend({
cfg: o.extend(),
createEncryptor: function (e, t) {
return this.create(this._ENC_XFORM_MODE, e, t)
},
createDecryptor: function (e, t) {
return this.create(this._DEC_XFORM_MODE, e, t)
},
init: function (e, t, n) {
this.cfg = this.cfg.extend(n),
this._xformMode = e,
this._key = t,
this.reset()
},
reset: function () {
i.reset.call(this),
this._doReset()
},
process: function (e) {
return this._append(e),
this._process()
},
finalize: function (e) {
return e && this._append(e),
this._doFinalize()
},
keySize: 4,
ivSize: 4,
_ENC_XFORM_MODE: 1,
_DEC_XFORM_MODE: 2,
_createHelper: function () {
function e(e) {
return "string" == typeof e ? b : m
}
return function (t) {
return {
encrypt: function (n, r, o) {
return e(r).encrypt(t, n, r, o)
},
decrypt: function (n, r, o) {
return e(r).decrypt(t, n, r, o)
}
}
}
}()
});
r.StreamCipher = c.extend({
_doFinalize: function () {
return this._process(!0)
},
blockSize: 1
});
var d = n.mode = {}
, p = r.BlockCipherMode = o.extend({
createEncryptor: function (e, t) {
return this.Encryptor.create(e, t)
},
createDecryptor: function (e, t) {
return this.Decryptor.create(e, t)
},
init: function (e, t) {
this._cipher = e,
this._iv = t
}
})
, f = d.CBC = function () {
var e = p.extend();
function n(e, n, r) {
var o, a = this._iv;
a ? (o = a,
this._iv = t) : o = this._prevBlock;
for (var i = 0; i < r; i++)
e[n + i] ^= o[i]
}
return e.Encryptor = e.extend({
processBlock: function (e, t) {
var r = this._cipher
, o = r.blockSize;
n.call(this, e, t, o),
r.encryptBlock(e, t),
this._prevBlock = e.slice(t, t + o)
}
}),
e.Decryptor = e.extend({
processBlock: function (e, t) {
var r = this._cipher
, o = r.blockSize
, a = e.slice(t, t + o);
r.decryptBlock(e, t),
n.call(this, e, t, o),
this._prevBlock = a
}
}),
e
}()
, h = (n.pad = {}).Pkcs7 = {
pad: function (e, t) {
for (var n = 4 * t, r = n - e.sigBytes % n, o = r << 24 | r << 16 | r << 8 | r, i = [], l = 0; l < r; l += 4)
i.push(o);
var s = a.create(i, r);
e.concat(s)
},
unpad: function (e) {
var t = 255 & e.words[e.sigBytes - 1 >>> 2];
e.sigBytes -= t
}
};
r.BlockCipher = c.extend({
cfg: c.cfg.extend({
mode: f,
padding: h
}),
reset: function () {
var e;
c.reset.call(this);
var t = this.cfg
, n = t.iv
, r = t.mode;
this._xformMode == this._ENC_XFORM_MODE ? e = r.createEncryptor : (e = r.createDecryptor,
this._minBufferSize = 1),
this._mode && this._mode.__creator == e ? this._mode.init(this, n && n.words) : (this._mode = e.call(r, this, n && n.words),
this._mode.__creator = e)
},
_doProcessBlock: function (e, t) {
this._mode.processBlock(e, t)
},
_doFinalize: function () {
var e, t = this.cfg.padding;
return this._xformMode == this._ENC_XFORM_MODE ? (t.pad(this._data, this.blockSize),
e = this._process(!0)) : (e = this._process(!0),
t.unpad(e)),
e
},
blockSize: 4
});
var g = r.CipherParams = o.extend({
init: function (e) {
this.mixIn(e)
},
toString: function (e) {
return (e || this.formatter).stringify(this)
}
})
, v = (n.format = {}).OpenSSL = {
stringify: function (e) {
var t = e.ciphertext
, n = e.salt;
return (n ? a.create([1398893684, 1701076831]).concat(n).concat(t) : t).toString(s)
},
parse: function (e) {
var t, n = s.parse(e), r = n.words;
return 1398893684 == r[0] && 1701076831 == r[1] && (t = a.create(r.slice(2, 4)),
r.splice(0, 4),
n.sigBytes -= 16),
g.create({
ciphertext: n,
salt: t
})
}
}
, m = r.SerializableCipher = o.extend({
cfg: o.extend({
format: v
}),
encrypt: function (e, t, n, r) {
r = this.cfg.extend(r);
var o = e.createEncryptor(n, r)
, a = o.finalize(t)
, i = o.cfg;
return g.create({
ciphertext: a,
key: n,
iv: i.iv,
algorithm: e,
mode: i.mode,
padding: i.padding,
blockSize: e.blockSize,
formatter: r.format
})
},
decrypt: function (e, t, n, r) {
return r = this.cfg.extend(r),
t = this._parse(t, r.format),
e.createDecryptor(n, r).finalize(t.ciphertext)
},
_parse: function (e, t) {
return "string" == typeof e ? t.parse(e, this) : e
}
})
, y = (n.kdf = {}).OpenSSL = {
execute: function (e, t, n, r) {
r || (r = a.random(8));
var o = u.create({
keySize: t + n
}).compute(e, r)
, i = a.create(o.words.slice(t), 4 * n);
return o.sigBytes = 4 * t,
g.create({
key: o,
iv: i,
salt: r
})
}
}
, b = r.PasswordBasedCipher = m.extend({
cfg: m.cfg.extend({
kdf: y
}),
encrypt: function (e, t, n, r) {
var o = (r = this.cfg.extend(r)).kdf.execute(n, e.keySize, e.ivSize);
r.iv = o.iv;
var a = m.encrypt.call(this, e, t, o.key, r);
return a.mixIn(o),
a
},
decrypt: function (e, t, n, r) {
r = this.cfg.extend(r),
t = this._parse(t, r.format);
var o = r.kdf.execute(n, e.keySize, e.ivSize, t.salt);
return r.iv = o.iv,
m.decrypt.call(this, e, t, o.key, r)
}
})
}()
}(JO.exports);
var xM = {
exports: {}
};
xM.exports = function (e) {
return function () {
var t = e
, n = t.lib.BlockCipher
, r = t.algo
, o = []
, a = []
, i = []
, l = []
, s = []
, u = []
, c = []
, d = []
, p = []
, f = [];
!function () {
for (var e = [], t = 0; t < 256; t++)
e[t] = t < 128 ? t << 1 : t << 1 ^ 283;
var n = 0
, r = 0;
for (t = 0; t < 256; t++) {
var h = r ^ r << 1 ^ r << 2 ^ r << 3 ^ r << 4;
h = h >>> 8 ^ 255 & h ^ 99,
o[n] = h,
a[h] = n;
var g = e[n]
, v = e[g]
, m = e[v]
, y = 257 * e[h] ^ 16843008 * h;
i[n] = y << 24 | y >>> 8,
l[n] = y << 16 | y >>> 16,
s[n] = y << 8 | y >>> 24,
u[n] = y,
y = 16843009 * m ^ 65537 * v ^ 257 * g ^ 16843008 * n,
c[h] = y << 24 | y >>> 8,
d[h] = y << 16 | y >>> 16,
p[h] = y << 8 | y >>> 24,
f[h] = y,
n ? (n = g ^ e[e[e[m ^ g]]],
r ^= e[e[r]]) : n = r = 1
}
}();
var h = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54]
, g = r.AES = n.extend({
_doReset: function () {
if (!this._nRounds || this._keyPriorReset !== this._key) {
for (var e = this._keyPriorReset = this._key, t = e.words, n = e.sigBytes / 4, r = 4 * ((this._nRounds = n + 6) + 1), a = this._keySchedule = [], i = 0; i < r; i++)
i < n ? a[i] = t[i] : (u = a[i - 1],
i % n ? n > 6 && i % n == 4 && (u = o[u >>> 24] << 24 | o[u >>> 16 & 255] << 16 | o[u >>> 8 & 255] << 8 | o[255 & u]) : (u = o[(u = u << 8 | u >>> 24) >>> 24] << 24 | o[u >>> 16 & 255] << 16 | o[u >>> 8 & 255] << 8 | o[255 & u],
u ^= h[i / n | 0] << 24),
a[i] = a[i - n] ^ u);
for (var l = this._invKeySchedule = [], s = 0; s < r; s++) {
if (i = r - s,
s % 4)
var u = a[i];
else
u = a[i - 4];
l[s] = s < 4 || i <= 4 ? u : c[o[u >>> 24]] ^ d[o[u >>> 16 & 255]] ^ p[o[u >>> 8 & 255]] ^ f[o[255 & u]]
}
}
},
encryptBlock: function (e, t) {
this._doCryptBlock(e, t, this._keySchedule, i, l, s, u, o)
},
decryptBlock: function (e, t) {
var n = e[t + 1];
e[t + 1] = e[t + 3],
e[t + 3] = n,
this._doCryptBlock(e, t, this._invKeySchedule, c, d, p, f, a),
n = e[t + 1],
e[t + 1] = e[t + 3],
e[t + 3] = n
},
_doCryptBlock: function (e, t, n, r, o, a, i, l) {
for (var s = this._nRounds, u = e[t] ^ n[0], c = e[t + 1] ^ n[1], d = e[t + 2] ^ n[2], p = e[t + 3] ^ n[3], f = 4, h = 1; h < s; h++) {
var g = r[u >>> 24] ^ o[c >>> 16 & 255] ^ a[d >>> 8 & 255] ^ i[255 & p] ^ n[f++]
, v = r[c >>> 24] ^ o[d >>> 16 & 255] ^ a[p >>> 8 & 255] ^ i[255 & u] ^ n[f++]
, m = r[d >>> 24] ^ o[p >>> 16 & 255] ^ a[u >>> 8 & 255] ^ i[255 & c] ^ n[f++]
, y = r[p >>> 24] ^ o[u >>> 16 & 255] ^ a[c >>> 8 & 255] ^ i[255 & d] ^ n[f++];
u = g,
c = v,
d = m,
p = y
}
g = (l[u >>> 24] << 24 | l[c >>> 16 & 255] << 16 | l[d >>> 8 & 255] << 8 | l[255 & p]) ^ n[f++],
v = (l[c >>> 24] << 24 | l[d >>> 16 & 255] << 16 | l[p >>> 8 & 255] << 8 | l[255 & u]) ^ n[f++],
m = (l[d >>> 24] << 24 | l[p >>> 16 & 255] << 16 | l[u >>> 8 & 255] << 8 | l[255 & c]) ^ n[f++],
y = (l[p >>> 24] << 24 | l[u >>> 16 & 255] << 16 | l[c >>> 8 & 255] << 8 | l[255 & d]) ^ n[f++],
e[t] = g,
e[t + 1] = v,
e[t + 2] = m,
e[t + 3] = y
},
keySize: 8
});
t.AES = n._createHelper(g)
}(),
e.AES
}(JO.exports);
var OM = qO.exports = JO.exports;
function enc(data, key) {
return OM.AES.encrypt(data, key).toString()
}
""";
}

View File

@@ -8,6 +8,11 @@ import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import static cn.qaiu.util.AESUtils.encrypt;
/**
* 执行Js脚本
*
@@ -57,4 +62,49 @@ public class JsExecUtils {
}
/**
* 调用执行蓝奏云js文件
*/
public static Object executeOtherJs(String jsText, String funName, Object ... args) throws ScriptException,
NoSuchMethodException {
ScriptEngineManager engineManager = new ScriptEngineManager();
ScriptEngine engine = engineManager.getEngineByName("JavaScript"); // 得到脚本引擎
engine.eval(jsText);
Invocable inv = (Invocable) engine;
//调用js中的函数
if (StringUtils.isNotEmpty(funName)) {
return inv.invokeFunction(funName, args);
}
throw new ScriptException("funName is null");
}
public static String getKwSign(String s, String pwd) {
try {
return executeOtherJs(JsContent.kwSignString, "encrypt", s, pwd).toString();
} catch (ScriptException | NoSuchMethodException e) {
throw new RuntimeException(e);
}
}
public static String mgEncData(String data, String key) {
try {
return executeOtherJs(JsContent.mgJS, "enc", data, key).toString();
} catch (ScriptException | NoSuchMethodException e) {
throw new RuntimeException(e);
}
}
// return OM.AES.encrypt('{"copyrightId":"6326951FKBL","type":1,"auditionsFlag":0}',
// '4ea5c508a6566e76240543f8feb06fd457777be39549c4016436afda65d2330e').toString()
//
public static void main(String[] args) {
System.out.println(URLEncoder
.encode(mgEncData("{\"copyrightId\":\"6326951FKBL\",\"type\":1,\"auditionsFlag\":0}", AESUtils.MG_KEY), StandardCharsets.UTF_8));
// U2FsdGVkX1/UiZC91ImQvQY7qDBSEbTykAcVoARiquibPCZhWSs3kWQw3j2PNme5wNLqt2oau498ni1hgjGFuxwORnkk6x9rzk/X0arElUo=
}
}

View File

@@ -0,0 +1,22 @@
package cn.qaiu.util;
import java.security.SecureRandom;
public class RandomStringGenerator {
private static final String CHARACTERS = "abcdefghijklmnopqrstuvwxyz0123456789";
private static final int LENGTH = 13; // 每段长度为13
public static String generateRandomString() {
SecureRandom random = new SecureRandom();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 2; i++) { // 生成两段
for (int j = 0; j < LENGTH; j++) {
int index = random.nextInt(CHARACTERS.length());
sb.append(CHARACTERS.charAt(index));
}
}
return sb.toString();
}
}

View File

@@ -0,0 +1,47 @@
package cn.qaiu.util;
import org.apache.commons.lang3.StringUtils;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
public class URLUtil {
private final Map<String, String> queryParams = new HashMap<>();
// 构造函数传入URL并解析参数
private URLUtil(String url) {
try {
URL parsedUrl = new URL(url);
String ref = parsedUrl.getRef();
if (StringUtils.isNotEmpty(ref)) {
parsedUrl = new URL(parsedUrl.getProtocol() + "://" + parsedUrl.getHost() + ref);
}
String query = parsedUrl.getQuery();
if (query != null) {
String[] pairs = query.split("&");
for (String pair : pairs) {
String[] keyValue = pair.split("=");
String key = URLDecoder.decode(keyValue[0], StandardCharsets.UTF_8);
String value = keyValue.length > 1 ? URLDecoder.decode(keyValue[1], StandardCharsets.UTF_8) : "";
queryParams.put(key, value);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
// 静态方法用于创建UrlUtil实例
public static URLUtil from(String url) {
return new URLUtil(url);
}
// 获取参数的方法
public String getParam(String param) {
return queryParams.get(param);
}
}

View File

@@ -0,0 +1,64 @@
import requests
import urllib.parse
import re
import base64
"""
https://github.com/chenhal/short_url
"""
headers = {
'Cookie': 'SUB=',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
'Referer': 'https://www.weibo.com',
'Content-Type': 'application/x-www-form-urlencoded'
}
def get_short_url(long_url):
url = "https://www.weibo.com/aj/v6/comment/add"
payload = urllib.parse.urlencode({
'mid': '5094736413852129',
'content': long_url
})
response = requests.post(url, headers=headers, data=payload)
try:
# print(response.json())
data = response.json()['data']['comment']
short_url = re.search(r'(https?)://t.cn/\w+', data).group(0)
comment_id = re.findall(r'comment_id="(.+\d)"', data)[-1] # 评论id
print('微博短链:' + short_url)
del_comment(comment_id) # 需要删除评论,可以取消该行注释
except:
print('失败')
pass
# 删除评论
def del_comment(comment_id):
url = 'https://www.weibo.com/aj/comment/del'
payload = urllib.parse.urlencode({
'mid': '微博mid',
'cid': comment_id # 评论id
})
response = requests.post(url, headers=headers, data=payload)
try:
if response.json()['code'] == '100000':
print('评论已删除')
except:
pass
if __name__ == '__main__':
# https://so.toutiao.com/search/jump?url=https%3A%2F%2Fblog.qaiu.top%2Farchives%2Fpydroidall&aid=4916&jtoken=297f06127cb010274213422b1967bdc2ae8469b627205941dc287173b58a2a8439ea0d813d24ada8780047d33f37d7e82c6a620760de1ca37640c1dc143b4e01
# https://so.toutiao.com/search/jump?url=https%3A%2F%2Fblog.qaiu.top%2Farchives%2Fpydroidall1&aid=4916&jtoken=297f06127cb010274213422b1967bdc2ae8469b627205941dc287173b58a2a8439ea0d813d24ada8780047d33f37d7e82c6a620760de1ca37640c1dc143b4e01
# 原始 URL
url = "https://lz.qaiu.top/json/lz/i5vOm0xho2cj"
# 将 URL 编码为 Base64
encoded_url = base64.b64encode(url.encode("utf-8")).decode("utf-8")
get_short_url('https://www.so.com/link?m=ewgUSYiFWXIoTybC3fJH8YoJy8y10iRquo6cazgINwWjTn3HvVJ92TrCJu0PmMUR0RMDfOAucP3wa4G8j64SrhNH9Z0Cr0PEyn9ASuvpkUGmAjjUEGJkO5%2BIDGWVrEkPHsL7UsoKO6%2BlT%2BD6r&ccc=' + encoded_url)

View File

@@ -3,8 +3,13 @@ package cn.qaiu.parser;
import cn.qaiu.entity.ShareLinkInfo;
import org.junit.Test;
import java.util.Arrays;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
import static java.util.regex.Pattern.compile;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -70,4 +75,32 @@ public class PanDomainTemplateTest {
// new Scanner(System.in).nextLine();
TimeUnit.SECONDS.sleep(5);
}
@Test
public void verifyDuplicates() {
Matcher matcher = compile("https://(?:[a-zA-Z\\d-]+\\.)?drive\\.google\\.com/file/d/(?<KEY>.+)/view(\\?usp=(sharing|drive_link))?")
.matcher("https://adsd.drive.google.com/file/d/151bR-nk-tOBm9QAFaozJIVt2WYyCMkoz/view");
if (matcher.find()) {
System.out.println(matcher.group());
System.out.println(matcher.group("KEY"));
}
// 校验重复
Set<String> collect =
Arrays.stream(PanDomainTemplate.values()).map(PanDomainTemplate::getRegex).collect(Collectors.toSet());
if (collect.size()<PanDomainTemplate.values().length) {
System.out.println("有重复枚举正则");
} else {
System.out.println("正则无重复");
}
Set<String> collect2 =
Arrays.stream(PanDomainTemplate.values()).map(PanDomainTemplate::getStandardUrlTemplate).collect(Collectors.toSet());
if (collect2.size()<PanDomainTemplate.values().length) {
System.out.println("有重复枚举标准链接");
} else {
System.out.println("标准链接无重复");
}
}
}

View File

@@ -0,0 +1,28 @@
package cn.qaiu.parser;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.parser.impl.PodTool;
public class ParserUrlOut {
//https://onedrive.live.com/redir?resid=ABFD0A26E47D3458!4699&e=OggA4s&migratedtospo=true&redeem=aHR0cHM6Ly8xZHJ2Lm1zL3UvcyFBbGcwZmVRbUN2MnJwRnZ1NDQ0aGc1eVZxRGNLP2U9T2dnQTRz
public static void main(String[] args) {
// Matcher matcher = redirectUrlRegex.matcher("https://onedrive.live.com/redir?resid=ABFD0A26E47D3458!4698" +
// "&authkey=!ACpvXghP5xhG_cg&e=hV98W1");
// if (matcher.find()) {
// System.out.println(matcher.group("cid"));
// System.out.println(matcher.group("cid2"));
// System.out.println(matcher.group("authkey"));
// }
// appid 5cbed6ac-a083-4e14-b191-b4ba07653de2 5cbed6ac-a083-4e14-b191-b4ba07653de2
// https://my.microsoftpersonalcontent.com/personal/abfd0a26e47d3458/_layouts/15/embed.aspx?UniqueId=e47d3458-0a26-20fd-80ab-5b1200000000&Translate=false&ApiVersion=2.0
// https://my.microsoftpersonalcontent.com/personal/abfd0a26e47d3458/_layouts/15/embed.aspx?UniqueId=6b0900d6-abcf-44ce-b7bf-7b626bcbe4b8&Translate=false&ApiVersion=2.0
// https://1drv.ms/u/s!Alg0feQmCv2rpFvu444hg5yVqDcK?e=OggA4s
// https://1drv.ms/u/c/abfd0a26e47d3458/EVg0feQmCv0ggKtbEgAAAAABqGv8K6HmOwLRsvokyV5fUg?e=iqoRc0
// https://1drv.ms/u/c/abfd0a26e47d3458/EVg0feQmCv0ggKtaEgAAAAAB-lF1qjkfv5OqdrT9VSMDMw
new PodTool(ShareLinkInfo.newBuilder().shareUrl("https://1drv.ms/u/c/abfd0a26e47d3458/EdYACWvPq85Et797YmvL5LgBruUKoNxqIFATXhIv1PI2_Q")
.build())
.parse().onSuccess(System.out::println);
}
}

View File

@@ -1,4 +1,4 @@
package qaiu.web.test;
package cn.qaiu.parser;
import io.vertx.core.MultiMap;
import io.vertx.core.Vertx;

View File

@@ -1,4 +1,4 @@
package qaiu.web.test;
package cn.qaiu.util;
import cn.qaiu.util.AESUtils;
import org.junit.Assert;
@@ -18,7 +18,11 @@ public class TestAESUtil {
@Test
public void decode() throws NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException,
BadPaddingException, InvalidKeyException {
String hex = AESUtils.encryptHexByAES("1686215935703", AESUtils.CIPHER_AES2);
String hex = AESUtils.encryptBase64ByAES("MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8asrfSaoOb4je+DSmKdriQJKW\n" +
"VJ2oDZrs3wi5W67m3LwTB9QVR+cE3XWU21Nx+YBxS0yun8wDcjgQvYt625ZCcgin\n" +
"2ro/eOkNyUOTBIbuj9CvMnhUYiR61lC1f1IGbrSYYimqBVSjpifVufxtx/I3exRe\n" +
"ZosTByYp4Xwpb1+WAQIDAQAB", AESUtils.CIPHER_AES2);
System.out.println(hex);
Assert.assertEquals("B4C5B9833113ACA41F16AABADE17349C", hex.toUpperCase());
}

View File

@@ -0,0 +1,32 @@
package cn.qaiu.util;
import org.junit.Test;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TestRegex {
@Test
public void regexYFC() {
String html = """
true|
<div class="load" id="go"><a
href="https://nsub2d3.118pan.com/dl.php?YzljNGFnOHFabWpsdzVXNUhyOXNiQ0ZYMHEzUjFoQ0R6MExCckdKZmRQL1RXbERPSTUwS0xlZkUvdmN5dGNqTHhCNDJVZURFekthV0tROHNINXdNRkZYUXB5aGQ5TEdXeTgrNkc1TkZwOWhzYVdpak83dEZleWxpYnloc0c1Ky9wbVBSZ0xiSHo5aTBnVVpCRmpyMGFBRERjcldtc0FnbS9vMnd3ZGRHWU4zYTNzNncwbk56UEtOVWhFeGIvWlM1aWZLQjlaTjB3b2V0cGVrb2lpQ0x3U0dtQkJqd2plWk1yeU1mZG1oNXpRYUJpYmFhZVgvWFZScThsTFhmU1ZKRW9UT3haVHFMVGVRTUhR"
onclick="down_process2('1228264');" target="_blank"><span class="txt">极速下载</span></a><a
href="https://nsub2t3.118pan.com/dl.php?YzljNGFnOHFabWpsdzVXNUhyOXNiQ0ZYMHEzUjFoQ0R6MExCckdKZmRQL1RXbERPSTUwS0xlZkUvdmN5dGNqTHhCNDJVZURFekthV0tROHNINXdNRkZYUXB5aGQ5TEdXeTgrNkc1TkZwOWhzYVdpak83dEZleWxpYnloc0c1Ky9wbVBSZ0xiSHo5aTBnVVpCRmpyMGFBRERjcldtc0FnbS9vMnd3ZGRHWU4zYTNzNncwbk56UEtOVWhFeGIvWlM1aWZLQjlaTjB3b2V0cGVrb2lpQ0x3U0dtQkJqd2plWk1yeU1mZG1oNXpRYUJpYmFhZVgvWFZScThsTFhmU1ZKRW9UT3haVHFMVGVRTUhR"
onclick="down_process2('1228264');" target="_blank"><span class="txt txtc">电信下载</span></a><a
href="https://nsub2u3.118pan.com/dl.php?YzljNGFnOHFabWpsdzVXNUhyOXNiQ0ZYMHEzUjFoQ0R6MExCckdKZmRQL1RXbERPSTUwS0xlZkUvdmN5dGNqTHhCNDJVZURFekthV0tROHNINXdNRkZYUXB5aGQ5TEdXeTgrNkc1TkZwOWhzYVdpak83dEZleWxpYnloc0c1Ky9wbVBSZ0xiSHo5aTBnVVpCRmpyMGFBRERjcldtc0FnbS9vMnd3ZGRHWU4zYTNzNncwbk56UEtOVWhFeGIvWlM1aWZLQjlaTjB3b2V0cGVrb2lpQ0x3U0dtQkJqd2plWk1yeU1mZG1oNXpRYUJpYmFhZVgvWFZScThsTFhmU1ZKRW9UT3haVHFMVGVRTUhR"
onclick="down_process2('1228264');" target="_blank"><span class="txt">联通下载</span></a><a
href="https://nsub2d3.118pan.com/dl.php?YzljNGFnOHFabWpsdzVXNUhyOXNiQ0ZYMHEzUjFoQ0R6MExCckdKZmRQL1RXbERPSTUwS0xlZkUvdmN5dGNqTHhCNDJVZURFekthV0tROHNINXdNRkZYUXB5aGQ5TEdXeTgrNkc1TkZwOWhzYVdpak83dEZleWxpYnloc0c1Ky9wbVBSZ0xiSHo5aTBnVVpCRmpyMGFBRERjcldtc0FnbS9vMnd3ZGRHWU4zYTNzNncwbk56UEtOVWhFeGIvWlM1aWZLQjlaTjB3b2V0cGVrb2lpQ0x3U0dtQkJqd2plWk1yeU1mZG1oNXpRYUJpYmFhZVgvWFZScThsTFhmU1ZKRW9UT3haVHFMVGVRTUhR"
onclick="down_process2('1228264');" target="_blank"><span class="txt txtc">普通下载</span></a></div>
""";
Pattern compile = Pattern.compile("href=\"([^\"]+)\"");
Matcher matcher = compile.matcher(html);
if (matcher.find()) {
// System.out.println(matcher.group(0));
System.out.println(matcher.group(1));
}
}
}

View File

@@ -0,0 +1,19 @@
package cn.qaiu.util;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.*;
public class URLUtilTest {
@Test
public void getParam() {
URLUtil util = URLUtil.from("https://i.y.qq.com/v8/playsong.html?ADTAG=cbshare&_wv=1&appshare=android_qq" +
"&appsongtype=1&appversion=13100008&channelId=10036163&hosteuin=7iosow-s7enz&openinqqmusic=1&platform" +
"=11&songmid=000XjcLg0fbRjv&type=0");
Assert.assertEquals(util.getParam("songmid"), "000XjcLg0fbRjv");
Assert.assertEquals(util.getParam("type"), "0");
}
}

View File

@@ -1,24 +0,0 @@
package qaiu.web.test;
import org.junit.Test;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TestRegex {
@Test
public void regexYFC() {
String html = """
<input type="hidden" id="typed_id" value="file_559003251828">
<input type="hidden" id="share_link_token" value="9cbe4b73521ba4d65a8cd38a8c">
""";
Pattern compile = Pattern.compile("id=\"typed_id\"\\s+value=\"file_(\\d+)\"");
Matcher matcher = compile.matcher(html);
if (matcher.find()) {
System.out.println(matcher.group(0));
System.out.println(matcher.group(1));
}
}
}

View File

@@ -1,54 +0,0 @@
package qaiu.web.test;
import io.vertx.core.MultiMap;
import io.vertx.core.Vertx;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.client.WebClient;
import org.junit.Test;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TestWebClient2 {
@Test
public void matcherHtml() {
Pattern compile = Pattern.compile("class=\"ifr2\" name=.+src=\"(/fn\\?[a-zA-Z0-9_+/=]{16,})\"");
var text = """
<div class="ifr"><!--<iframe class="ifr2" name="1" src="/fn?v2" frameborder="0" scrolling="no"></iframe>-->
<iframe class="ifr2" name="1685001208" src="/fn?UzUBa1oxBmUAYgNsUDUFNVI6BjJfJlchV21TZFU_aVWwANVQzXTBXMlUxUTcLZ1dwUn8DYwQ5AHFVOwdmBjRUPlM2AS9aOgY3AGIDMFA2" frameborder="0" scrolling="no"></iframe>""";
System.out.println(text);
Matcher matcher = compile.matcher(text);
if (matcher.find()) {
System.out.println(matcher.group(0));
System.out.println(matcher.group(1));
}
}
@Test
public void lzClient() {
Vertx vertx = Vertx.vertx();
WebClient client = WebClient.create(vertx);
MultiMap form = MultiMap.caseInsensitiveMultiMap();
// action=downprocess&sign=AGYHOQk4BjdTWgQ7BzcGOlU_bATVSNQMxBDFQZgZoBj4HMFEgWnMOZ1I1A2NWOgUxB20HMlM_aUGoLOgQz&p=e4k4
form.set("action", "downprocess");
form.set("sign", "VzFWaA4_aBzYIAQI9ADBUaARvATVRNlNhUGUBNwBuATkDNFEgXHVVPAZhB2dTP1ZiVD5UYQBpV2EBPwA3");
form.set("p", "e4k4");
client.postAbs("https://wwsd.lanzoue.com/ajaxm.php")
.putHeader("referer", "https://wwsd.lanzoue.com/iFhd00x8k0kh")
.sendForm(form).onSuccess(res -> {
JsonObject jsonObject = res.bodyAsJsonObject();
System.out.println(jsonObject);
vertx.close();
});
//
// https://developer.lanzoug.com/file/?VTMBPwEwU2IGD1dvV2ICblBvU2sENQZhVSZSMAA1WihSOVYsDTZTZlN2UXMFfAZjBzJXJQAxAG5XP1UyXGQGKlVlAXgBbVMpBmNXLFdhAmpQZFN4BCEGbVUiUnIAOloyUj5WZA0PU25TYVE6BWAGNgdlV2IAbQAyV2JValw3BiFVMwElAWFTNgZmVzBXMwIyUDpTYARrBiJVIlIkAGFaaVJiVjMNY1MoUzVRMgV+BjUHaFd9ADwAMVdlVTFcOAYyVWcBYgFqUz4GaVdlVzMCNFBrUzcEOAZgVWJSZQA/WmJSM1Y2DWhTNFMzUTEFYgY3B2VXZgBxAHhXOVUjXCYGclUmATMBLlNuBjRXPFcyAjNQP1NvBG8GPVVqUnIAKFoyUj9WZA02UzpTNFExBWkGMgdtV2IAaQAxV2FVYFwuBilVcwEwATBTcAZtVzBXNQI7UD9TZgRrBjFVY1JlAGlafVInVnENJ1M6UzRRMQVpBjIHbVdiAG0AMldgVWRcJgZyVTwBJgFhUzYGYVczVy0CMVA5U2QEdQY1VWZSYgByWmxSag==
// https://developer.lanzoug.com/file/?B2FWaA4/BDVTWgc/UWRVOQQ7BT1VZFYxUSJUNgE0UiAEbwJ4CDMOOwInU3EKc1w5ATRSIAIzUz1ROVcwATkDLwc3Vi8OYgR+UzYHfFFnVT0EMAUuVXBWPVEmVHQBO1I6BGgCMAgKDjMCMFM4Cm9cbAFjUmcCb1NhUWRXaAFqAyQHYVZyDm4EYVMzB2BRNVVlBG4FNlU6VnJRJlQiAWBSYQQ0AmcIZg51AmRTMApxXG8BblJ4Aj5TYlFjVzMBZQM3BzVWNQ5lBGlTPAc1UTVVYwQ/BWFVaVYwUWZUYwE+UmoEZQJiCG0OaQJiUzMKbVxtAWNSYwJzUytRP1chAXsDdwd0VmQOIQQ5U2EHbFE0VWQEawU5VT5WbVFuVHQBKVI6BGkCMAgzDmcCZVMzCmZcaAFrUmcCaFNlUWNXZwFzAywHIVZnDj8EJ1M4B2BRM1VsBGsFMFU6VmZRb1RgAW5SdQRxAiUIIg5nAmVTMwpmXGgBa1JnAm9TYVFmV2YBewN3B25WcQ5uBGFTNAdjUStVZgRtBTJVJFZlUWJUZAFzUmQEPA==
// https://developer.lanzoug.com/file/?CW9WaAk4BzZUXVRsCz5cMAE+Bj5UZVM0USJUNlRhA3FUPwJ4CTJUYQInASMHflI3ATQGdFdmAW9ROQFmVGwEKAk5Vi8JZQd9VDFULws9XDQBNQYtVHFTOFEmVHRUbgNrVDgCMAkLVGkCMAFqB2JSYgFjBjNXOgEzUWQBPlQ/BCMJb1ZyCWkHYlQ0VDMLb1xsAWsGNVQ7U3dRJlQiVDUDMFRkAmcJZ1QvAmQBYgd8UmEBbgYsV2sBMFFjAWVUMAQwCTtWNQliB2pUO1RmC29cagE6BmJUaFM1UWZUY1RrAztUNQJiCWxUMwJiAWEHYFJjAWMGN1cmAXlRPwF3VC4EcAl6VmQJJgc6VGZUPwtuXG0BbgY6VD9TaFFuVHRUfANrVDkCMAkyVD0CZQFhB2tSZgFrBjNXPgE6UWABM1QmBCsJL1ZnCTgHJFQ/VDMLaVxlAW4GM1Q7U2RRb1RmVDgDJFQhAiUJI1Q9AmUBYQdrUmYBawYzVzoBM1FmATBULgRwCWBWcQlpB2JUM1QwC3FcbwFoBjFUJVNgUWJUZFQmAzVUbA==
}
}

View File

@@ -32,7 +32,8 @@
<commons-lang3.version>3.12.0</commons-lang3.version>
<commons-beanutils2.version>2.0.0</commons-beanutils2.version>
<jackson.version>2.14.2</jackson.version>
<logback.version>1.4.12</logback.version>
<logback.version>1.5.8</logback.version>
<junit.version>4.13.2</junit.version>
</properties>
<dependencyManagement>

View File

@@ -23,3 +23,4 @@ pnpm-debug.log*
*.sw?
/nfd-front.zip
/nfd-front
/package-lock.json

View File

@@ -1,14 +1,28 @@
# nfd-web
解析服务的前端页面, 提供API测试, 统计查询, 二维码生成等
# nfd-web
使用vue3+element-plus打造
解析服务的前端页面, 提供API测试, 统计查询, 二维码生成等;
20241101 支持剪切板链接自动识别解析, 一键生成短链
20241111 vue框架升级为3.0
![img_2.png](img/img_2.png)
![img.png](img/img.png)
![img_1.png](img/img_1.png)
## 关于如何将前端项目和java一块打包:
1. 先打包前端模块
2. 打包后请将当前目录下的nfd-front目录放置在项目下webroot目录, 然后使用maven打包java模块即可
2. ~~打包后请将当前目录下的nfd-front目录放置在项目下webroot目录, 然后使用maven打包java模块即可~~ `npm run build` 会直接打包到后端代理目录下, 无需复制
3. 项目部署后演示页面的代理端口是6401默认使用http, 如需https可以加nginx代理, 也可以使用本项目自带的代理服务和配置证书路径
## nginx配置
```nginx
location / {
proxy_pass http://127.0.0.1:6401;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
```
## Project setup
```
npm install
@@ -31,3 +45,8 @@ npm run lint
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
## 参考项目
- https://github.com/HurryBy/CloudDiskAnalysis
- https://github.com/syhyz1990/panAI

12186
web-front/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "nfd-web",
"version": "0.1.0",
"version": "0.1.9",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
@@ -8,25 +8,27 @@
"lint": "vue-cli-service lint"
},
"dependencies": {
"@element-plus/icons-vue": "^2.3.1",
"@vueuse/core": "^11.2.0",
"axios": "^1.7.4",
"clipboard": "^2.0.11",
"core-js": "^3.8.3",
"element-ui": "^2.15.14",
"element-plus": "^2.8.7",
"qrcode": "^1.5.4",
"vue": "^2.7.16",
"vue-clipboard2": "^0.3.3",
"vue-json-viewer": "^2.2.22"
"vue": "^3.5.12",
"vue-clipboard3": "^2.0.0",
"vue3-json-viewer": "^2.2.2"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"compression-webpack-plugin": "^6.1.1",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"filemanager-webpack-plugin": "8.0.0",
"vue-template-compiler": "^2.7.16"
"@babel/core": "^7.26.0",
"@babel/eslint-parser": "^7.25.9",
"@vue/cli-plugin-babel": "~5.0.8",
"@vue/cli-plugin-eslint": "~5.0.8",
"@vue/cli-service": "~5.0.8",
"compression-webpack-plugin": "^11.1.0",
"eslint": "^9.14.0",
"eslint-plugin-vue": "^9.30.0",
"filemanager-webpack-plugin": "8.0.0"
},
"eslintConfig": {
"root": true,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -1,13 +1,16 @@
<template>
<div id="app">
<el-row :gutter="20">
<el-card class="box-card">
<div style="text-align: right"><DarkMode/></div>
<div class="demo-basic--circle">
<div class="block" style="text-align: center;">
<img :height="150" src="../public/images/lanzou111.png" alt="lz"></img>
</div>
</div>
<h3 style="text-align: center;">NFD网盘直链解析0.1.8_bate2(API演示)</h3>
<h3 style="text-align: center;">NFD网盘直链解析0.1.8_bate3(API演示)</h3>
<div class="typo">
<p style="text-align: center;">
<span>
@@ -33,25 +36,41 @@
<hr>
<div class="main" v-loading="isLoading">
<div class="grid-content">
<el-input placeholder="请粘贴分享链接" v-model="link" id="url" lass="input-with-select">
<strong slot="prepend">分享链接</strong>
<!-- 开关按钮控制是否自动读取剪切板 -->
<el-switch
v-model="autoReadClipboard"
active-text="自动识别剪切板"
></el-switch>
<el-input placeholder="请粘贴分享链接(http://或https://)" v-model="link" id="url">
<template #prepend>分享链接</template>
<template #append v-if="!autoReadClipboard">
<el-button @click="() => getPaste(1)">读取剪切板</el-button>
</template>
</el-input>
<el-input placeholder="请输入密码" v-model="password" id="url" lass="input-with-select">
<strong slot="prepend">分享密码</strong>
<el-input placeholder="请输入密码" v-model="password" id="url">
<template #prepend>分享密码</template>
</el-input>
<el-input v-show="respData.data" placeholder="解析地址" :value="getLink2" id="url" lass="input-with-select">
<el-button slot="append" v-clipboard:copy="getLink2"
v-clipboard:success="onCopy"
v-clipboard:error="onError">点我复制
</el-button>
<el-input v-show="getLink2" :value="getLink2" id="url">
<template #prepend>智能直链</template>
<template #append>
<el-button v-clipboard:copy="getLink2"
v-clipboard:success="onCopy"
v-clipboard:error="onError">
<el-icon><CopyDocument/></el-icon>
</el-button>
</template>
</el-input>
<p style="text-align: center">
<el-button style="" @click="onSubmit">解析测试</el-button>
<el-button style="margin-left: 20px" @click="genMd">生成Markdown链接</el-button>
<el-button style="margin-left: 20px" @click="generateQRCode">生成二维码</el-button>
<el-button style="margin-left: 40px;margin-bottom: 10px" @click="onSubmit">解析测试</el-button>
<el-button style="margin-left: 20px;margin-bottom: 10px" @click="genMd">生成Markdown链接</el-button>
<el-button style="margin-left: 20px" @click="generateQRCode">扫码下载</el-button>
<el-button style="margin-left: 20px" @click="getTj">链接信息统计</el-button>
</p>
</div>
<div v-if="respData.code" style="margin-top: 10px">
<strong>解析结果: </strong>
<json-viewer
@@ -63,26 +82,20 @@
/>
<a :href="downUrl" v-show="downUrl">点击下载</a>
</div>
<el-row v-if="mdText" style="text-align: center">
<el-col span="22">
<el-input
type="textarea"
:autosize="{ minRows: 4, maxRows: 8}"
placeholder="请输入内容"
v-model="mdText">
<div v-if="mdText" style="text-align: center">
<el-input :value="mdText" readonly>
<template #append>
<el-button v-clipboard:copy="mdText"
v-clipboard:success="onCopy"
v-clipboard:error="onError">
<el-icon><CopyDocument/></el-icon>
</el-button>
</template>
</el-input>
</el-col>
<el-col span="2">
<el-button v-clipboard:copy="mdText"
v-clipboard:success="onCopy"
v-clipboard:error="onError">复制
</el-button>
</el-col>
</el-row>
</div>
<div style="text-align: center" v-show="showQrc">
<div style="text-align: center"><el-link target="_blank" :href="codeUrl">{{ codeUrl }}</el-link></div>
<canvas ref="qrcodeCanvas"></canvas>
<div style="text-align: center"> 扫码下载 </div>
<div style="text-align: center"><el-link target="_blank" :href="codeUrl">{{ codeUrl }}</el-link></div>
</div>
<div v-if="tjData.shareLinkInfo">
<el-descriptions class="margin-top" title="分享详情" :column="1" border>
@@ -110,34 +123,18 @@
<script>
import axios from 'axios'
import QRCode from 'qrcode'
/*
蓝奏云 (lz)
登录, 上传, 下载, 分享
直链解析
奶牛快传 (cow)
登录, 上传, 下载, 分享
直链解析
移动云空间 (ec)
登录, 上传, 下载, 分享
直链解析
UC网盘 (uc)似乎已经失效,需要登录
登录, 上传, 下载, 分享
直链解析
小飞机网盘 (fj)
登录, 上传, 下载, 分享
直链解析
亿方云 (fc)
登录, 上传, 下载, 分享
直链解析
123云盘 (ye)
登录, 上传, 下载,, 分享
*/
import DarkMode from '@/components/DarkMode'
import parserUrl from './parserUrl1'
export default {
name: 'App',
components: {DarkMode},
data() {
return {
// baseAPI: `${location.protocol}//${location.hostname}:6400`,
baseAPI: `${location.protocol}//${location.host}`,
autoReadClipboard: true, // 开关状态,默认为自动读取
current: {}, // 当前分享
showQrc: false,
codeUrl: '',
@@ -188,12 +185,15 @@ export default {
}
},
methods: {
// toggleDark() {
// toggleDark()
// },
check() {
this.mdText = ''
this.showQrc = false
this.respData = {}
this.tjData = {}
if (!this.link.startsWith("https://")) {
if (!this.link.startsWith("https://") && !this.link.startsWith("http://")) {
this.$message.error("请输入有效链接!")
throw new Error('请输入有效链接')
}
@@ -238,7 +238,7 @@ export default {
},
getInfo() {
// 初始化统计信息
axios.get('/n1/statisticsInfo').then(
axios.get('/v2/statisticsInfo').then(
response => {
if (response.data.success) {
this.node1Info = response.data.data
@@ -275,9 +275,7 @@ export default {
const options = { // 设置二维码的参数,例如大小、边距等
width: 150,
height: 150,
margin: 2,
colorDark : "#8e0fb7",
colorLight : "#fff2ad",
margin: 2
};
axios.get(this.getLinkInfo, {params: {url: this.link, pwd: this.password}}).then(
response => {
@@ -312,13 +310,54 @@ export default {
this.$message.error(response.data.msg)
}
});
}
},
async getPaste(v) {
const text = await navigator.clipboard.readText();
console.log('获取到的文本内容是:', text);
let linkInfo = parserUrl.parseLink(text);
let pwd = parserUrl.parsePwd(text) || '';
if (linkInfo.link) {
if(linkInfo.link !== this.link || pwd !== this.password ) {
this.password = pwd;
this.link = linkInfo.link;
this.getLink2 = `${this.baseAPI}/parser?url=${this.link}`
if (this.link) this.$message.success(`自动识别分享成功, 网盘类型: ${linkInfo.name}; 分享URL ${this.link}; 分享密码: ${this.password || '空'}`);
} else {
v || this.$message.warning(`[${linkInfo.name}]分享信息无变化`)
}
} else {
this.$message.warning("未能提取到分享链接, 该分享可能尚未支持, 你可以复制任意网盘/音乐App的分享到该页面, 系统智能识别")
}
},
},
mounted() {
this.getLinkInfo = `${this.baseAPI}/v2/linkInfo`
this.getLink = `${this.baseAPI}/json/parser`
let item = window.localStorage.getItem("autoReadClipboard");
if (item) {
this.autoReadClipboard = (item === 'true');
}
this.getInfo()
// 页面首次加载时,根据开关状态判断是否读取剪切板
if (this.autoReadClipboard) {
this.getPaste()
}
// 当文档获得焦点时触发
window.addEventListener('focus', () => {
if (this.autoReadClipboard) {
this.getPaste()
}
});
},
watch: {
autoReadClipboard(val) {
window.localStorage.setItem("autoReadClipboard", val)
}
}
}
</script>
@@ -333,9 +372,6 @@ export default {
max-width: 900px;
}
::selection {
background: rgba(0, 149, 255, .1);
}
body:before {
top: 0;
@@ -344,7 +380,6 @@ body:before {
bottom: 0;
opacity: .3;
z-index: -1;
content: "";
position: fixed;
}
@@ -358,11 +393,6 @@ body:before {
width: 130px;
}
.input-with-select .el-input-group__prepend {
background-color: #fff;
}
.box-card {
margin-top: 4em !important;
margin-bottom: 4em !important;

View File

@@ -0,0 +1,37 @@
<template>
<el-switch
v-model="darkMode"
size="large"
style="--el-switch-on-color: #4882f8; --el-switch-off-color: #ff8000"
inline-prompt
:active-icon="Moon"
:inactive-icon="Sunny"
@change="toggleDark"
/>
</template>
<script setup>
import { ref,watch } from 'vue'
import { useDark, useToggle } from '@vueuse/core'
/** 引入Element-Plus图标 */
import { Sunny, Moon } from '@element-plus/icons-vue'
defineOptions({
name: 'DarkMode'
})
/** 切换模式 */
const isDark = useDark({})
const toggleDark = useToggle(isDark)
let item = window.localStorage.getItem("darkMode");
if (item) {
item = (item === 'true');
}
/** 是否切换为暗黑模式 */
const darkMode = ref(item)
watch(darkMode, (newValue) => {
console.log(`darkMode: ${newValue}`)
window.localStorage.setItem("darkMode", newValue);
})
</script>

View File

@@ -0,0 +1,17 @@
//index.ts
import { ObjectDirective, App, Plugin } from "vue";
// 自定义指令 可以引用多个
import vClipboard from "./vClipboard";
// 构建指令集
const directives = [vClipboard];
export default {
install: (app) => {
// 安装指令集
directives.forEach((item) => {
app.directive(item.name, item.options);
});
},
};

View File

@@ -0,0 +1,71 @@
// vClipboard.ts
// vue-clipboard3 提供的 composition api
import useClipboard from "vue-clipboard3";
const { toClipboard } = useClipboard();
export default {
name: "clipboard",
options: {
// 挂载
mounted(el, binding) {
// binding.arg 为动态指令参数
// 由于 指令是支持响应式的 因此我们指令需要有一个“全局”对象这里我们为了不借助其他对象浪费资源就直接使用el自身了
// 将copy的值 成功回调 失败回调 及 click事件都绑定到el上 这样在更新和卸载时方便操作
switch (binding.arg) {
case "copy":
// copy值
el.clipValue = binding.value;
// click事件
el.clipCopy = function () {
toClipboard(el.clipValue)
.then(result => {
el.clipSuccess && el.clipSuccess(result);
})
.catch(err => {
el.clipError && el.clipError(err);
});
};
// 绑定click事件
el.addEventListener("click", el.clipCopy);
break;
case "success":
// 成功回调
el.clipSuccess = binding.value;
break;
case "error":
// 失败回调
el.clipError = binding.value;
break;
}
},
// 相应修改 这里比较简单 重置相应的值即可
updated(el, binding) {
switch (binding.arg) {
case "copy":
el.clipValue = binding.value;
break;
case "success":
el.clipSuccess = binding.value;
break;
case "error":
el.clipError = binding.value;
break;
}
},
// 卸载 删除click事件 删除对应的自定义属性
unmounted(el, binding) {
switch (binding.arg) {
case "copy":
el.removeEventListener("click", el.clipCopy);
delete el.clipValue;
delete el.clipCopy;
break;
case "success":
delete el.clipSuccess;
break;
case "error":
delete el.clipError;
break;
}
},
},
};

View File

@@ -1,19 +1,30 @@
import Vue from 'vue'
import * as Vue from 'vue'
import App from './App.vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import VueClipboard from 'vue-clipboard2'
import JsonViewer from 'vue-json-viewer'
import VueClipboard from 'vue-clipboard3'
import DirectiveExtensions from './directive'
import JsonViewer from 'vue3-json-viewer'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/dark/css-vars.css'
import "vue3-json-viewer/dist/index.css";
import './styles/dark/css-vars.css'
window.$vueApp = Vue.createApp(App)
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
window.$vueApp.component(key, component)
}
// Import JsonViewer as a Vue.js plugin
Vue.use(JsonViewer)
window.$vueApp.use(JsonViewer)
window.$vueApp.use(DirectiveExtensions)
// or
// components: {JsonViewer}
Vue.use(VueClipboard)
Vue.config.productionTip = false
Vue.use(ElementUI)
new Vue({
render: h => h(App),
}).$mount('#app')
window.$vueApp.use(VueClipboard)
window.$vueApp.use(ElementPlus)
window.$vueApp.mount('#app')

398
web-front/src/parserUrl1.js Normal file
View File

@@ -0,0 +1,398 @@
// 修改自 https://github.com/syhyz1990/panAI
const util = {
isMobile: (() => !!navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone|HarmonyOS|MicroMessenger)/i))(),
}
let opt = {
// 'baidu': {
// reg: /((?:https?:\/\/)?(?:e?yun|pan)\.baidu\.com\/(doc\/|enterprise\/)?(?:s\/[\w~]*(((-)?\w*)*)?|share\/\S{4,}))/,
// host: /(pan|e?yun)\.baidu\.com/,
// input: ['#accessCode', '.share-access-code', '#wpdoc-share-page > .u-dialog__wrapper .u-input__inner'],
// button: ['#submitBtn', '.share-access .g-button', '#wpdoc-share-page > .u-dialog__wrapper .u-btn--primary'],
// name: '百度网盘',
// storage: 'hash'
// },
// 'aliyun': {
// reg: /((?:https?:\/\/)?(?:(?:www\.)?(?:aliyundrive|alipan)\.com\/s|alywp\.net)\/[a-zA-Z\d]+)/,
// host: /www\.(aliyundrive|alipan)\.com|alywp\.net/,
// input: ['form .ant-input', 'form input[type="text"]', 'input[name="pwd"]'],
// button: ['form .button--fep7l', 'form button[type="submit"]'],
// name: '阿里云盘',
// storage: 'hash'
// },
// 'weiyun': {
// reg: /((?:https?:\/\/)?share\.weiyun\.com\/[a-zA-Z\d]+)/,
// host: /share\.weiyun\.com/,
// input: ['.mod-card-s input[type=password]', 'input.pw-input'],
// button: ['.mod-card-s .btn-main', ".pw-btn-wrap button.btn"],
// name: '微云',
// storage: 'hash'
// },
// 'tianyi': {
// reg: /((?:https?:\/\/)?cloud\.189\.cn\/(?:t\/|web\/share\?code=)?[a-zA-Z\d]+)/,
// host: /cloud\.189\.cn/,
// input: ['.access-code-item #code_txt', "input.access-code-input"],
// button: ['.access-code-item .visit', ".button"],
// name: '天翼云盘',
// storage: (() => util.isMobile === true ? 'local' : 'hash')(),
// storagePwdName: 'tmp_tianyi_pwd'
// },
// 'caiyun': {
// reg: /((?:https?:\/\/)?caiyun\.139\.com\/(?:m\/i|w\/i\/|web\/|front\/#\/detail)\??(?:linkID=)?[a-zA-Z\d]+)/,
// host: /(?:cai)?yun\.139\.com/,
// input: ['.token-form input[type=text]'],
// button: ['.token-form .btn-token'],
// name: '移动云盘',
// storage: 'local',
// storagePwdName: 'tmp_caiyun_pwd'
// },
// 'xunlei': {
// reg: /((?:https?:\/\/)?pan\.xunlei\.com\/s\/[\w-]{10,})/,
// host: /pan\.xunlei\.com/,
// input: ['.pass-input-wrap .td-input__inner'],
// button: ['.pass-input-wrap .td-button'],
// name: '迅雷云盘',
// storage: 'hash'
// },
// '360': {
// reg: /((?:https?:\/\/)?(?:[a-zA-Z\d\-.]+)?(?:yunpan\.360\.cn|yunpan\.com)(\/lk)?\/surl_\w{6,})/,
// host: /[\w.]+?yunpan\.com/,
// input: ['.pwd-input'],
// button: ['.submit-btn'],
// name: '360云盘',
// storage: 'local',
// storagePwdName: 'tmp_360_pwd'
// },
// '115': {
// reg: /((?:https?:\/\/)?115\.com\/s\/[a-zA-Z\d]+)/,
// host: /115\.com/,
// input: ['.form-decode input'],
// button: ['.form-decode .submit a'],
// name: '115网盘',
// storage: 'hash'
// },
// 'quark': {
// reg: /((?:https?:\/\/)?pan\.quark\.cn\/s\/[a-zA-Z\d-]+)/,
// host: /pan\.quark\.cn/,
// input: ['.ant-input'],
// button: ['.ant-btn-primary'],
// name: '夸克网盘',
// storage: 'local',
// storagePwdName: 'tmp_quark_pwd'
// },
// 'vdisk': {
// reg: /(?:https?:\/\/)?vdisk.weibo.com\/lc\/\w+/,
// host: /vdisk\.weibo\.com/,
// input: ['#keypass', "#access_code"],
// button: ['.search_btn_wrap a', "#linkcommon_btn"],
// name: '微盘',
// storage: 'hash',
// },
// 'uc': {
// reg: /(?:https?:\/\/)?drive\.uc\.cn\/s\/[a-zA-Z\d]+/,
// host: /drive\.uc\.cn/,
// input: ["input[class*='ShareReceivePC--input']", '.input-wrap input'],
// button: ["button[class*='ShareReceivePC--submit-btn'", '.input-wrap button'],
// name: 'UC云盘',
// storage: 'hash'
// },
// 'jianguoyun': {
// reg: /((?:https?:\/\/)?www\.jianguoyun\.com\/p\/[\w-]+)/,
// host: /www\.jianguoyun\.com/,
// input: ['input[type=password]'],
// button: ['.ok-button', '.confirm-button'],
// name: '坚果云',
// storage: 'hash'
// },
// 'wo': {
// reg: /(?:https?:\/\/)?pan\.wo\.cn\/s\/[\w_]+/,
// host: /(pan\.wo\.cn|panservice\.mail\.wo\.cn)/,
// input: ['input.el-input__inner', ".van-field__control"],
// button: ['.s-button', ".share-code button"],
// name: '联通云盘',
// storage: (() => util.isMobile === true ? 'local' : 'hash')(),
// storagePwdName: 'tmp_wo_pwd'
// },
// 'mega': {
// reg: /((?:https?:\/\/)?(?:mega\.nz|mega\.co\.nz)\/#F?![\w!-]+)/,
// host: /(?:mega\.nz|mega\.co\.nz)/,
// input: ['.dlkey-dialog input'],
// button: ['.dlkey-dialog .fm-dialog-new-folder-button'],
// name: 'Mega',
// storage: 'local'
// },
// '520vip': {
// reg: /((?:https?:\/\/)?www\.(?:520-vip|eos-53)\.com\/file-\d+\.html)/,
// host: /www\.520-vip\.com/,
// name: '520云盘',
// },
// '567pan': {
// reg: /((?:https?:\/\/)?www\.567(?:pan|yun|file|inc)\.(?:com|cn)\/file-\d+\.html)/,
// host: /www\.567inc\.cn/,
// name: '567盘',
// replaceHost: "www.567inc.com",
// },
// 'ayunpan': {
// reg: /((?:https?:\/\/)?www\.ayunpan\.com\/file-\d+\.html)/,
// host: /www\.ayunpan\.com/,
// name: 'AYunPan',
// },
// 'iycdn.com': {
// reg: /((?:https?:\/\/)?www\.iycdn\.com\/file-\d+\.html)/,
// host: /www\.iycdn\.com/,
// name: '爱优网盘',
// },
// 'feimaoyun': {
// reg: /((?:https?:\/\/)?www\.feimaoyun\.com\/s\/[0-9a-zA-Z]+)/,
// host: /www\.feimaoyun\.com/,
// name: '飞猫盘',
// },
// 'uyunp.com': {
// reg: /((?:https?:\/\/)?download\.uyunp\.com\/share\/s\/short\/\?surl=[0-9a-zA-Z]+)/,
// host: /download\.uyunp\.com/,
// name: '优云下载',
// },
// 'dudujb': {
// reg: /(?:https?:\/\/)?www\.dudujb\.com\/file-\d+\.html/,
// host: /www\.dudujb\.com/,
// name: '贵族网盘',
// },
// 'xunniu': {
// reg: /(?:https?:\/\/)?www\.xunniu(?:fxp|wp|fx)\.com\/file-\d+\.html/,
// host: /www\.xunniuwp\.com/,
// name: '迅牛网盘',
// },
// 'xueqiupan': {
// reg: /(?:https?:\/\/)?www\.xueqiupan\.com\/file-\d+\.html/,
// host: /www\.xueqiupan\.com/,
// name: '雪球云盘',
// },
// '77file': {
// reg: /(?:https?:\/\/)?www\.77file\.com\/s\/[a-zA-Z\d]+/,
// host: /www\.77file\.com/,
// name: '77file',
// },
// 'ownfile': {
// reg: /(?:https?:\/\/)?ownfile\.net\/files\/[a-zA-Z\d]+\.html/,
// host: /ownfile\.net/,
// name: 'OwnFile',
// },
// 'feiyunfile': {
// reg: /(?:https?:\/\/)?www\.feiyunfile\.com\/file\/[\w=]+\.html/,
// host: /www\.feiyunfile\.com/,
// name: '飞云网盘',
// },
// 'yifile': {
// reg: /(?:https?:\/\/)?www\.yifile\.com\/f\/\w+/,
// host: /www\.yifile\.com/,
// name: 'YiFile',
// },
// 'dufile': {
// reg: /(?:https?:\/\/)?dufile\.com\/file\/\w+\.html/,
// host: /dufile\.com/,
// name: 'duFile',
// },
// 'flowus': {
// reg: /((?:https?:\/\/)?flowus\.cn\/[\S ^\/]*\/?share\/[a-z\d]{8}-[a-z\d]{4}-[a-z\d]{4}-[a-z\d]{4}-[a-z\d]{12})/,
// host: /flowus\.cn/,
// name: 'FlowUs息流',
// storage: 'hash'
// },
// 'chrome': {
// reg: /^https?:\/\/chrome.google.com\/webstore\/.+?\/([a-z]{32})(?=[\/#?]|$)/,
// host: /chrome\.google\.com/,
// replaceHost: "chrome.crxsoso.com",
// name: 'Chrome商店',
// },
// 'edge': {
// reg: /^https?:\/\/microsoftedge.microsoft.com\/addons\/.+?\/([a-z]{32})(?=[\/#?]|$)/,
// host: /microsoftedge\.microsoft\.com/,
// replaceHost: "microsoftedge.crxsoso.com",
// name: 'Edge商店',
// },
// 'firefox': {
// reg: /^https?:\/\/(reviewers\.)?(addons\.mozilla\.org|addons(?:-dev)?\.allizom\.org)\/.*?(?:addon|review)\/([^/<>"'?#]+)/,
// host: /addons\.mozilla\.org/,
// replaceHost: "addons.crxsoso.com",
// name: 'Firefox商店',
// },
// 'microsoft': {
// reg: /^https?:\/\/(?:apps|www).microsoft.com\/(?:store|p)\/.+?\/([a-zA-Z\d]{10,})(?=[\/#?]|$)/,
// host: /(apps|www)\.microsoft\.com/,
// replaceHost: "apps.crxsoso.com",
// name: 'Windows商店',
// }
'lanzou': {
reg: /((?:https?:\/\/)?(?:[a-zA-Z0-9\-.]+)?(?:lanzou[a-z]|lanzn)\.com\/[a-zA-Z\d_\-]+(?:\/[\w-]+)?)/,
host: /(?:[a-zA-Z\d-.]+)?(?:lanzou[a-z]|lanzn)\.com/,
input: ['#pwd'],
button: ['.passwddiv-btn', '#sub'],
name: '蓝奏云',
storage: 'hash'
},
'cowtransfer': {
reg: /((?:https?:\/\/)?(?:[a-zA-Z\d-.]+)?cowtransfer\.com\/s\/[a-zA-Z\d]+)/,
host: /(?:[a-zA-Z\d-.]+)?cowtransfer\.com/,
input: ['.receive-code-input input'],
button: ['.open-button'],
name: '奶牛快传',
storage: 'hash'
},
'ctfile': {
reg: /((?:https?:\/\/)?(?:[a-zA-Z\d-.]+)?(?:ctfile|545c|u062|ghpym|474b)\.com\/\w+\/[a-zA-Z\d-]+)/,
host: /(?:[a-zA-Z\d-.]+)?(?:ctfile|545c|u062|474b)\.com/,
input: ['#passcode'],
button: ['.card-body button'],
name: '城通网盘',
storage: 'hash'
},
'123pan': {
reg: /((?:https?:\/\/)?www\.(123pan|123865|123684)\.com\/s\/[\w-]{6,})/,
host: /www\.123pan\.com/,
input: ['.ca-fot input', ".appinput .appinput"],
button: ['.ca-fot button', ".appinput button"],
name: '123云盘',
storage: 'hash'
},
'wenshushu': {
reg: /((?:https?:\/\/)?(?:www\.wenshushu|ws28)\.cn\/(?:k|box|f)\/\w+)/,
host: /www\.wenshushu\.cn/,
input: ['.pwd-inp .ivu-input'],
button: ['.pwd-inp .ivu-btn'],
name: '文叔叔网盘',
storage: 'hash'
},
// ---new---
feijix: {
reg: /https:\/\/(share\.feijipan\.com|www\.feijix\.com)\/s\/.+/,
host: /feijix\.com|feijipan\.com/,
name: '小飞机网盘'
},
lecloud: {
reg: /https:\/\/lecloud\.lenovo\.com\/share\/.+/,
host: /lenovo\.com/,
name: '联想乐云'
},
fangcloud: {
reg: /https:\/\/v2\.fangcloud\.(com|cn)\/(s|sharing)\/.+/,
host: /fangcloud\.(com|cn)/,
name: '亿方云'
},
ilanzou: {
reg: /https:\/\/www\.ilanzou\.com\/s\/.+/,
host: /ilanzou\.com/,
name: '蓝奏云优享'
},
qqMailTransfer: {
reg: /https:\/\/iwx\.mail\.qq\.com\/ftn\/download\?.+/,
host: /mail\.qq\.com/,
name: 'QQ邮箱中转站'
},
pan118: {
reg: /https:\/\/(?:[a-zA-Z\d-]+\.)?118pan\.com\/b.+/,
host: /118pan\.com/,
name: '118网盘'
},
pan115: {
// https://115.com/s/swhyiia3wzi?password=h374
reg: /https:\/\/(115|anxia)\.com\/s\/.+/,
host: /115pan\.com/,
name: '115网盘'
},
onedrive: {
reg: /https:\/\/1drv\.ms\/.+/,
host: /1drv\.ms/,
name: 'OneDrive'
},
googleDrive: {
reg: /https:\/\/drive\.google\.com\/file\/d\/.+\/view\?usp=(sharing|drive_link)?/,
host: /drive\.google\.com/,
name: 'GoogleDrive'
},
icloud: {
reg: /https:\/\/www\.icloud\.com\.cn\/iclouddrive\/([a-zA-Z\d_-]+)(#.+)?/,
host: /www\.icloud\.com\.cn/,
name: 'iCloud',
},
n163Music: {
reg: /https:\/\/163cn\.tv\/.+/,
host: /163cn\.tv/,
name: '网易云音乐分享'
},
qqMusic: {
reg: /https:\/\/y\.qq\.com\/n\/ryqq\/songDetail\/.+/,
host: /y\.qq\.com/,
name: 'QQ音乐歌曲详情'
},
kuwoMusic: {
reg: /https:\/\/(m\.)?kuwo\.cn\/(newh5app\/)?play_detail\/.+/,
host: /kuwo\.cn/,
name: '酷我音乐分享'
},
miguMusic: {
reg: /https:\/\/music\.migu\.cn\/v3\/music\/song\/.+/,
host: /migu\.cn/,
name: '咪咕音乐分享'
},
other: {
reg: /https:\/\/([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*\.)+[a-zA-Z]{2,}\/s\/.+/,
host: /.*/,
name: '其他/Cloudreve/可道云'
},
};
let main = {
//正则解析网盘链接
parseLink(text = '') {
let obj = {name: '', link: '', storage: '', storagePwdName: ''};
if (text) {
try {
text = decodeURIComponent(text);
} catch {
}
text = text.replace(/[点點]/g, '.');
text = text.replace(/[\u4e00-\u9fa5(),\u200B\uD83C-\uDBFF\uDC00-\uDFFF]/g, '');
text = text.replace(/lanzous/g, 'lanzouw'); //修正lanzous打不开的问题
for (let name in opt) {
let val = opt[name];
if (val.reg.test(text)) {
let matches = text.match(val.reg);
obj.name = val.name;
obj.link = matches[0];
obj.storage = val.storage;
obj.storagePwdName = val.storagePwdName || null;
if (val.replaceHost) {
obj.link = obj.link.replace(val.host, val.replaceHost);
}
return obj;
}
}
}
return obj;
},
//正则解析提取码
parsePwd(text = '') {
text = text.replace(/\u200B/g, '').replace('%3A', ":");
text = text.replace(/(?:本帖)?隐藏的?内容[:]?/, "");
let reg = /wss:[a-zA-Z0-9]+|(?<=\s*(?:密|提取|访问|訪問|key|password|pwd|#|\?p=)\s*[码碼]?\s*[:=]?\s*)[a-zA-Z0-9]{3,8}/i;
if (reg.test(text)) {
let match = text.match(reg);
return match[0];
}
return '';
},
};
export default {
parseLink: main.parseLink,
parsePwd: main.parsePwd,
opt: opt
}

View File

@@ -0,0 +1,5 @@
html.dark {
/* 自定义深色背景颜色 */
--el-bg-color: #424242;
--el-bg-color-overlay: #424242;
}

View File

View File

@@ -8,6 +8,7 @@ const CompressionPlugin = require('compression-webpack-plugin');
const FileManagerPlugin = require('filemanager-webpack-plugin')
module.exports = {
productionSourceMap: false, // 是否在构建生产包时生成sourceMap文件false将提高构建速度
transpileDependencies: true,
lintOnSave: false,
outputDir: 'nfd-front',
@@ -15,13 +16,9 @@ module.exports = {
host: '127.0.0.1',
port: 6444,
proxy: {
'/api': {
'/': {
target: 'http://127.0.0.1:6400', // 请求本地
changeOrigin: true,
pathRewrite: {
'^/api': '/' //本身的接口地址没有 '/api' 这种通用前缀所以要rewrite如果本身有则去掉
},
ws: true
ws: false
},
}
},
@@ -34,23 +31,28 @@ module.exports = {
'@': resolve('src')
}
},
plugins: [
new CompressionPlugin({
test: /\.js$|\.html$|\.css/, // 匹配文件
threshold: 10240 // 对超过10k文件压缩
}),
// new FileManagerPlugin({ //初始化 filemanager-webpack-plugin 插件实例
// onEnd: {
// mkdir: ['./nfd-front'],
// delete: [ //首先需要删除项目根目录下的dist.zip
// './nfd-front.zip',
// ],
// archive: [ //然后我们选择dist文件夹将之打包成dist.zip并放在根目录
// {source: './nfd-front', destination: './nfd-front.zip'},
// ]
// }
// })
new FileManagerPlugin({ //初始化 filemanager-webpack-plugin 插件实例
events: {
onEnd: {
mkdir: ['./nfd-front'],
copy: [
{ source: './nfd-front', destination: '../webroot/nfd-front' }
],
delete: [ //首先需要删除项目根目录下的dist.zip
'./nfd-front.zip',
'../webroot/nfd-front',
],
archive: [ //然后我们选择dist文件夹将之打包成dist.zip并放在根目录
{source: './nfd-front', destination: './nfd-front.zip'},
]
}
}
})
]
},

File diff suppressed because it is too large Load Diff

View File

@@ -56,7 +56,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@@ -7,8 +7,12 @@ import cn.qaiu.vx.core.Deploy;
import cn.qaiu.vx.core.util.ConfigConstant;
import cn.qaiu.vx.core.util.VertxHolder;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.jackson.DatabindCodec;
import io.vertx.core.shareddata.LocalMap;
import static cn.qaiu.vx.core.util.ConfigConstant.LOCAL;
/**
@@ -24,6 +28,7 @@ public class AppMain {
}
/**
* 框架回调方法
* 初始化数据库/缓存等
*
* @param jsonObject 配置
@@ -39,5 +44,24 @@ public class AppMain {
if (jsonObject.containsKey(ConfigConstant.CACHE)) {
CacheConfigLoader.init(jsonObject.getJsonObject(ConfigConstant.CACHE));
}
// 代理
if (jsonObject.containsKey(ConfigConstant.PROXY)) {
LocalMap<Object, Object> localMap = VertxHolder.getVertxInstance().sharedData().getLocalMap(LOCAL);
JsonArray proxyJsonArray = jsonObject.getJsonArray(ConfigConstant.PROXY);
if (proxyJsonArray != null) {
proxyJsonArray.forEach(proxyJson -> {
String panTypes = ((JsonObject)proxyJson).getString("panTypes");
if (!panTypes.isEmpty()) {
JsonObject jsonObject1 = new JsonObject();
for (String s : panTypes.split(",")) {
jsonObject1.put(s, proxyJson);
}
localMap.put("proxy", jsonObject1);
}
});
}
}
}
}

View File

@@ -32,6 +32,7 @@ public class CacheConfigLoader {
return CONFIGS.get(pdt.name().toLowerCase());
}
public static Integer getDuration(String type) {
return CONFIGS.get(type.toLowerCase());
String key = type.toLowerCase();
return CONFIGS.getOrDefault(key, -1);
}
}

View File

@@ -52,15 +52,16 @@ public class CacheManager {
}
// 写入网盘厂商API解析次数
public Future<Integer> updateTotalByCached(String shareKey) {
public Future<Integer> updateTotalByField(String shareKey, CacheTotalField field) {
Promise<Integer> promise = Promise.promise();
String fieldLower = field.name().toLowerCase();
String sql = """
MERGE INTO `api_statistics_info` (`pan_type`, `share_key`, `cache_hit_total`, `update_ts`)
MERGE INTO `api_statistics_info` (`pan_type`, `share_key`, `{field}`, `update_ts`)
KEY (`share_key`)
VALUES (#{panType}, #{shareKey}, #{total}, #{ts})
""";
""".replace("{field}", fieldLower);
getShareKeyTotal(shareKey, "cache_hit_total").onSuccess(total -> {
getShareKeyTotal(shareKey, fieldLower).onSuccess(total -> {
Integer newTotal = (total == null ? 0 : total) + 1;
SqlTemplate.forUpdate(jdbcPool, sql)
.execute(new HashMap<>() {{
@@ -81,30 +82,6 @@ public class CacheManager {
return fullShareKey.split(":")[0];
}
// 写入网盘厂商API解析次数
public Future<Integer> updateTotalByParser(String shareKey) {
Promise<Integer> promise = Promise.promise();
String sql = """
MERGE INTO `api_statistics_info` (`pan_type`, `share_key`, `api_parser_total`, `update_ts`)
KEY (`share_key`)
VALUES (#{panType}, #{shareKey}, #{total}, #{ts})
""";
getShareKeyTotal(shareKey, "api_parser_total").onSuccess(total -> {
Integer newTotal = (total == null ? 0 : total) + 1;
SqlTemplate.forUpdate(jdbcPool, sql)
.execute(new HashMap<>() {{
put("panType", getShareType(shareKey));
put("shareKey", shareKey);
put("total", newTotal);
put("ts", System.currentTimeMillis());
}})
.onSuccess(res -> promise.complete(res.rowCount()))
.onFailure(Throwable::printStackTrace);
});
return promise.future();
}
public Future<Integer> getShareKeyTotal(String shareKey, String name) {
String sql = """
select `share_key`, sum({total_name}) sum_num

View File

@@ -0,0 +1,10 @@
package cn.qaiu.lz.common.cache;
/**
* 缓存字段
*/
public enum CacheTotalField {
API_PARSER_TOTAL, // 解析次数
CACHE_HIT_TOTAL, // 缓存次数
FAILED_TOTAL // 解析失败次数
}

View File

@@ -28,10 +28,6 @@ public class URLParamUtil {
if (params.contains("url")) {
String encodedUrl = params.get("url");
url = handleTruncatedUrl(encodedUrl, params);
if (url.endsWith(".html")) {
// 123云盘的后缀处理
url = url.replace(".html", "");
}
}
return url;
}

View File

@@ -0,0 +1,17 @@
package cn.qaiu.lz.web.controller;
import cn.qaiu.vx.core.annotaions.RouteHandler;
import cn.qaiu.vx.core.annotaions.RouteMapping;
import cn.qaiu.vx.core.enums.RouteMethod;
import io.vertx.ext.web.RoutingContext;
import lombok.extern.slf4j.Slf4j;
@RouteHandler(value = "/d", order = 99)
@Slf4j
public class DownRedirect {
@RouteMapping(value = "/:type/:key", method = RouteMethod.GET)
public void parseKey(RoutingContext ctx, String type, String key) {
ctx.reroute("/" + type + "/" + key);
}
}

View File

@@ -5,10 +5,11 @@ import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.lz.common.cache.CacheManager;
import cn.qaiu.lz.common.util.URLParamUtil;
import cn.qaiu.lz.web.model.LinkInfoResp;
import cn.qaiu.lz.web.model.StatisticsInfo;
import cn.qaiu.lz.web.model.SysUser;
import cn.qaiu.lz.web.service.DbService;
import cn.qaiu.lz.web.service.UserService;
import cn.qaiu.lz.web.model.StatisticsInfo;
import cn.qaiu.parser.PanDomainTemplate;
import cn.qaiu.parser.ParserCreate;
import cn.qaiu.vx.core.annotaions.RouteHandler;
import cn.qaiu.vx.core.annotaions.RouteMapping;
@@ -21,6 +22,12 @@ import io.vertx.core.http.HttpServerRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;
@RouteHandler(value = "/v2", order = 10)
@Slf4j
public class ParserApi {
@@ -52,6 +59,7 @@ public class ParserApi {
.apiLink(getDownLink(parserCreate, true))
.shareLinkInfo(shareLinkInfo).build();
// 解析次数统计
shareLinkInfo.getOtherParam().put("UA",request.headers().get("user-agent"));
cacheManager.getShareKeyTotal(shareLinkInfo.getCacheKey()).onSuccess(res -> {
if (res != null) {
build.setCacheHitTotal(res.get("hit_total") == null ? 0: res.get("hit_total"));
@@ -68,12 +76,25 @@ public class ParserApi {
private static String getDownLink(ParserCreate create, boolean isJson) {
String linkPrefix = SharedDataUtil.getJsonConfig("server")
.getString("domainName");
String linkPrefix = SharedDataUtil.getJsonConfig("server").getString("domainName");
if (StringUtils.isBlank(linkPrefix)) {
linkPrefix = "http://127.0.0.1";
}
return linkPrefix + (isJson ? "/json/" : "/") + create.genPathSuffix();
// 下载短链前缀 /d
return linkPrefix + (isJson ? "/json/" : "/d/") + create.genPathSuffix();
}
/**
* 获取支持的网盘列表
* @return list-map: name: 网盘名, type: 网盘标识, url: 网盘域名地址
*/
@RouteMapping("/getPanList")
public List<Map<String, String>> getPanList() {
return Arrays.stream(PanDomainTemplate.values()).map(pan -> new TreeMap<String, String>() {{
put("name", pan.getDisplayName());
put("type", pan.name().toLowerCase());
put("url", pan.getPanDomain());
}}).collect(Collectors.toList());
}
}

View File

@@ -12,6 +12,8 @@ import io.vertx.core.Future;
import io.vertx.core.Promise;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.RoutingContext;
import lombok.extern.slf4j.Slf4j;
/**
@@ -27,11 +29,11 @@ public class ServerApi {
private final CacheService cacheService = AsyncServiceUtil.getAsyncServiceInstance(CacheService.class);
@RouteMapping(value = "/parser", method = RouteMethod.GET, order = 1)
public Future<Void> parse(HttpServerResponse response, HttpServerRequest request, String pwd) {
public Future<Void> parse(HttpServerResponse response, HttpServerRequest request, RoutingContext rcx, String pwd) {
Promise<Void> promise = Promise.promise();
String url = URLParamUtil.parserParams(request);
cacheService.getCachedByShareUrlAndPwd(url, pwd)
cacheService.getCachedByShareUrlAndPwd(url, pwd, JsonObject.of("UA",request.headers().get("user-agent")))
.onSuccess(res -> ResponseUtil.redirect(
response.putHeader("nfd-cache-hit", res.getCacheHit().toString())
.putHeader("nfd-cache-expires", res.getExpires()),
@@ -43,22 +45,22 @@ public class ServerApi {
@RouteMapping(value = "/json/parser", method = RouteMethod.GET, order = 1)
public Future<CacheLinkInfo> parseJson(HttpServerRequest request, String pwd) {
String url = URLParamUtil.parserParams(request);
return cacheService.getCachedByShareUrlAndPwd(url, pwd);
return cacheService.getCachedByShareUrlAndPwd(url, pwd, JsonObject.of("UA",request.headers().get("user-agent")));
}
@RouteMapping(value = "/json/:type/:key", method = RouteMethod.GET)
public Future<CacheLinkInfo> parseKeyJson(String type, String key) {
public Future<CacheLinkInfo> parseKeyJson(HttpServerRequest request, String type, String key) {
String pwd = "";
if (key.contains("@")) {
String[] keys = key.split("@");
key = keys[0];
pwd = keys[1];
}
return cacheService.getCachedByShareKeyAndPwd(type, key, pwd);
return cacheService.getCachedByShareKeyAndPwd(type, key, pwd, JsonObject.of("UA",request.headers().get("user-agent")));
}
@RouteMapping(value = "/:type/:key", method = RouteMethod.GET)
public Future<Void> parseKey(HttpServerResponse response, String type, String key) {
public Future<Void> parseKey(HttpServerResponse response, HttpServerRequest request, String type, String key) {
Promise<Void> promise = Promise.promise();
String pwd = "";
if (key.contains("@")) {
@@ -66,7 +68,7 @@ public class ServerApi {
key = keys[0];
pwd = keys[1];
}
cacheService.getCachedByShareKeyAndPwd(type, key, pwd)
cacheService.getCachedByShareKeyAndPwd(type, key, pwd, JsonObject.of("UA",request.headers().get("user-agent")))
.onSuccess(res -> ResponseUtil.redirect(
response.putHeader("nfd-cache-hit", res.getCacheHit().toString())
.putHeader("nfd-cache-expires", res.getExpires()),

View File

@@ -2,11 +2,15 @@ package cn.qaiu.lz.web.model;
import cn.qaiu.db.ddl.Table;
import cn.qaiu.lz.common.ToJson;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.vertx.codegen.annotations.DataObject;
import io.vertx.core.json.JsonObject;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@Data
@DataObject
@NoArgsConstructor
@@ -16,9 +20,17 @@ public class SysUser implements ToJson {
private String username;
private String password;
private Integer age;
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
private LocalDateTime createTime;
public SysUser(JsonObject json) {
this.id = json.getString("id");
this.username = json.getString("username");
this.password = json.getString("password");
this.age = json.getInteger("age");
if (json.getString("createTime") != null) {
this.createTime = LocalDateTime.parse(json.getString("createTime"));
}
}
}

View File

@@ -4,6 +4,7 @@ import cn.qaiu.lz.web.model.CacheLinkInfo;
import cn.qaiu.vx.core.base.BaseAsyncService;
import io.vertx.codegen.annotations.ProxyGen;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
/**
* @author <a href="https://qaiu.top">QAIU</a>
@@ -12,7 +13,7 @@ import io.vertx.core.Future;
@ProxyGen
public interface CacheService extends BaseAsyncService {
Future<CacheLinkInfo> getCachedByShareKeyAndPwd(String type, String shareKey, String pwd);
Future<CacheLinkInfo> getCachedByShareKeyAndPwd(String type, String shareKey, String pwd, JsonObject otherParam);
Future<CacheLinkInfo> getCachedByShareUrlAndPwd(String shareUrl, String pwd);
Future<CacheLinkInfo> getCachedByShareUrlAndPwd(String shareUrl, String pwd, JsonObject otherParam);
}

View File

@@ -3,13 +3,17 @@ package cn.qaiu.lz.web.service.impl;
import cn.qaiu.entity.ShareLinkInfo;
import cn.qaiu.lz.common.cache.CacheConfigLoader;
import cn.qaiu.lz.common.cache.CacheManager;
import cn.qaiu.lz.common.cache.CacheTotalField;
import cn.qaiu.lz.web.model.CacheLinkInfo;
import cn.qaiu.lz.web.service.CacheService;
import cn.qaiu.parser.ParserCreate;
import cn.qaiu.vx.core.annotaions.Service;
import cn.qaiu.vx.core.util.ConfigConstant;
import cn.qaiu.vx.core.util.VertxHolder;
import io.vertx.core.Future;
import io.vertx.core.Promise;
import io.vertx.core.json.JsonObject;
import io.vertx.core.shareddata.LocalMap;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.util.Date;
@@ -20,6 +24,16 @@ public class CacheServiceImpl implements CacheService {
private final CacheManager cacheManager = new CacheManager();
private Future<CacheLinkInfo> getAndSaveCachedShareLink(ParserCreate parserCreate) {
LocalMap<Object, Object> localMap = VertxHolder.getVertxInstance().sharedData()
.getLocalMap(ConfigConstant.LOCAL);
if (localMap.containsKey(ConfigConstant.PROXY)) {
JsonObject proxy = (JsonObject) localMap.get(ConfigConstant.PROXY);
String type = parserCreate.getShareLinkInfo().getType();
if (proxy.containsKey(type)) {
parserCreate.getShareLinkInfo().getOtherParam().put(ConfigConstant.PROXY, proxy.getJsonObject(type));
}
}
Promise<CacheLinkInfo> promise = Promise.promise();
// 构建组合的缓存key
ShareLinkInfo shareLinkInfo = parserCreate.getShareLinkInfo();
@@ -46,12 +60,12 @@ public class CacheServiceImpl implements CacheService {
"shareKey", cacheKey
));
cacheManager.cacheShareLink(cacheLinkInfo).onFailure(Throwable::printStackTrace);
cacheManager.updateTotalByParser(cacheKey).onFailure(Throwable::printStackTrace);
cacheManager.updateTotalByField(cacheKey, CacheTotalField.API_PARSER_TOTAL).onFailure(Throwable::printStackTrace);
}).onFailure(promise::fail);
} else {
result.setExpires(generateDate(result.getExpiration()));
promise.complete(result);
cacheManager.updateTotalByCached(cacheKey).onFailure(Throwable::printStackTrace);
cacheManager.updateTotalByField(cacheKey, CacheTotalField.CACHE_HIT_TOTAL).onFailure(Throwable::printStackTrace);
}
}).onFailure(t -> promise.fail(t.fillInStackTrace()));
return promise.future();
@@ -62,14 +76,16 @@ public class CacheServiceImpl implements CacheService {
}
@Override
public Future<CacheLinkInfo> getCachedByShareKeyAndPwd(String type, String shareKey, String pwd) {
public Future<CacheLinkInfo> getCachedByShareKeyAndPwd(String type, String shareKey, String pwd, JsonObject otherParam) {
ParserCreate parserCreate = ParserCreate.fromType(type).shareKey(shareKey).setShareLinkInfoPwd(pwd);
parserCreate.getShareLinkInfo().getOtherParam().putAll(otherParam.getMap());
return getAndSaveCachedShareLink(parserCreate);
}
@Override
public Future<CacheLinkInfo> getCachedByShareUrlAndPwd(String shareUrl, String pwd) {
public Future<CacheLinkInfo> getCachedByShareUrlAndPwd(String shareUrl, String pwd, JsonObject otherParam) {
ParserCreate parserCreate = ParserCreate.fromShareUrl(shareUrl).setShareLinkInfoPwd(pwd);
parserCreate.getShareLinkInfo().getOtherParam().putAll(otherParam.getMap());
return getAndSaveCachedShareLink(parserCreate);
}
}

View File

@@ -5,16 +5,17 @@ server:
# 使用数据库
enableDatabase: true
# 服务域名或者IP 生成二维码链接时需要
domainName: https://lz.qaiu.top
domainName: http://127.0.0.1:6401
# 反向代理服务器配置路径(不用加后缀)
proxyConf: server-proxy
# vertx线程配置, 为0表示eventLoopPoolSize将会采用默认配置(CPU核心*2) workerPoolSize将会采用默认20
# vertx核心线程配置(一般无需改的), 为0表示eventLoopPoolSize将会采用默认配置(CPU核心*2) workerPoolSize将会采用默认20
vertx:
eventLoopPoolSize: 0
workerPoolSize: 0
# vertx-service配置(一般无需改的)
custom:
# 异步服务线程数
asyncServiceInstances: 4
@@ -40,22 +41,40 @@ dataSource:
username: root
password: '123456'
# 缓存配置
# 直链缓存相关配置
cache:
# 该配置未使用后续加入其他Cache实现时区分类型
type: h2db
# 默认时长: 单位分钟, 实际有效期分钟-1
# 默认时长: 单位分钟,大部分网盘未严格验证,建议不要太大
defaultDuration: 59
# 具体网盘的缓存配置如果不加配置则不缓存每次请求都会请求网盘API格式网盘标识: 时长
duration:
ce:
cow:
ec:
fc:
fj: 30
fj:
iz: 20
le: 2879
lz:
qq: 999999
lz: 20
qq: 9999999
ws:
ye:
mne: 30
mqq: 30
mkg: 30
p115: 5
# httpClient静态代理服务器配置(外网代理)
proxy:
# - panTypes: pgd,pdb,pod
# type: http # 支持http/socks4/socks5
# host: 127.0.0.1
# port: 7890
# username:
# password:
# 代理池配置
#ip-pool:
# api-url:

View File

@@ -1,6 +1,4 @@
# 要激活的配置: dev--连接本地数据库; prod连接线上数据库
# 要激活的配置: app-配置名称.yml
active: dev
# 版本号
version_app: 0.1.8
# 公司名称 -> LOGO版权文字
# 控制台输出的版权文字
copyright: QAIU

View File

@@ -0,0 +1,5 @@
# 正向代理
server-name: Vert.x-proxy-http(v4.1.2)
proxy:
- listen: 6402

View File

@@ -0,0 +1,31 @@
### 诚通网盘 https://www.ctfile.com 缓存链接有效期 待验证 https://474b.com/file/4015376-131945810
# 参数 f=shareKey r=Math.random()
# frist json里拿到file_chk: file->file_chk
# {"code":200,"file":
# {"follow_link":"https:\/\/www.ctfile.com\/p\/login?ref=https%3A%2F%2Fapp.ctfile.com%2F%23%2Fcommunity%2Ffriends%3Fuid%3D4015376","popad":5,"is_userself":0,"link_protected":0,"file_name":"500-数学丛书.-.[控制论].[具有适应性特色的自动控制系统].pdf","file_size":"8.54 MB","file_time":"2015-11-15","file_views":67,"username":"大学资料大全","email":"13730*****@qq.com","page_title":"500-数学丛书.-.[控制论].[具有适应性特色的自动控制系统].pdf - 大学资料大全 的分享","title":"大学资料大全","page_desc":"大学资料大全 考研 机械 化工 医学 计算机 软件 文档 资","reg_url":"https:\/\/www.ctfile.com\/tokenGo.php?token=asdasdasd&url=https%3A%2F%2Fwww.ctfile.com%2Fp%2Fregister","login_url":"https:\/\/www.ctfile.com\/tokenGo.php?token=asdasdasd&url=https%3A%2F%2Fwww.ctfile.com%2Fp%2Flogin","home_url":"https:\/\/www.ctfile.com\/tokenGo.php?token=asdasdasd&url=https%3A%2F%2Fhome.ctfile.com","web_url":"https:\/\/www.ctfile.com\/tokenGo.php?token=asdasdasd&url=https%3A%2F%2Fwww.ctfile.com","file_dir":"\/d\/4015376-13641882-1728451726-88d6d28597a698a7","userid":4015376,"file_id":131945810,"free_speed":"2 分钟 ","software_speed":"1 分钟 ","vip_speed":"1 秒","my_uid":0,"is_guest":true,"my_username":"","is_mb":0,"doubleclick_url":"https:\/\/doubleclick.ctfile.com\/?adv&advert&mod=cpv&act=add&uid=4015376&fid=131945810&t=1728451726&k=00b42bc176838414e0223344cbcbf83c&ref=",
# "file_chk":"723e63ee67e25922ecb0d187412f8cc8","groups_price":{"10":595,"13":1500,"14":3000}}}
https://webapi.ctfile.com/getfile.php?path=file&f=4015376-131945810&passcode=&token=asdasdasd&r=0.4047614357286914&ref=
accept: application/json, text/javascript, */*; q=0.01
### 响应文件大小, 文件名, token是随机数 file_chk取上一步解析值
# 解析文件key uid-fid, folder_id=0, file_chk, rd=Math.random(), token=随机方法, 写死&mb=0&app=0&acheck=0&verifycode=
https://webapi.ctfile.com/get_file_url.php?uid=4015376&fid=131945810&folder_id=0&file_chk=723e63ee67e25922ecb0d187412f8cc8&mb=0&token=asdasdasd&app=0&acheck=0&verifycode=&rd=0.0796029918724035
### 响应:
{"xhr":true,"downurl":"https:\/\/92-cucc-data.bego.cc\/d4015376\/0f056fafc06b2caae1fbc09398baa987\/500-%E6%95%B0%E5%AD%A6%E4%B8%9B%E4%B9%A6.-.%5B%E6%8E%A7%E5%88%B6%E8%AE%BA%5D.%5B%E5%85%B7%E6%9C%89%E9%80%82%E5%BA%94%E6%80%A7%E7%89%B9%E8%89%B2%E7%9A%84%E8%87%AA%E5%8A%A8%E6%8E%A7%E5%88%B6%E7%B3%BB%E7%BB%9F%5D.pdf?cts=D39A91A92A31Fccd73&ctp=39A91A92A31&ctt=1728470964&limit=1&spd=50000&ctk=0f056fafc06b2caae1fbc09398baa987&chk=760e47c028b68ea41eeca1d09b84cce9-8535153&mtd=1","code":200,"pop":0,"file_size":8535153,"confirm_url":"https:\/\/doubleclick.ctfile.com\/?adv&adimage&adimages&mod=cpv&act=confirm&uid=4015376&fid=131945810&fv=65&t=1728449364&g=10&ad=5&rc=0&adb=1&size=8535153&chk=760e47c028b68ea41eeca1d09b84cce9-8535153&k=08ebe5fb20996a6c35602bbfca1a93f2","file_name":"500-数学丛书.-.[控制论].[具有适应性特色的自动控制系统].pdf"}
解析替换\/ -> \
https://92-cucc-data.bego.cc/d4015376/0f056fafc06b2caae1fbc09398baa987/500-%E6%95%B0%E5%AD%A6%E4%B8%9B%E4%B9%A6.-.%5B%E6%8E%A7%E5%88%B6%E8%AE%BA%5D.%5B%E5%85%B7%E6%9C%89%E9%80%82%E5%BA%94%E6%80%A7%E7%89%B9%E8%89%B2%E7%9A%84%E8%87%AA%E5%8A%A8%E6%8E%A7%E5%88%B6%E7%B3%BB%E7%BB%9F%5D.pdf?cts=D39A91A92A31Fccd73&ctp=39A91A92A31&ctt=1728470964&limit=1&spd=50000&ctk=0f056fafc06b2caae1fbc09398baa987&chk=760e47c028b68ea41eeca1d09b84cce9-8535153&mtd=1
###
https://92-cucc-data.bego.cc/d4015376/0f056fafc06b2caae1fbc09398baa987/500-%E6%95%B0%E5%AD%A6%E4%B8%9B%E4%B9%A6.-.%5B%E6%8E%A7%E5%88%B6%E8%AE%BA%5D.%5B%E5%85%B7%E6%9C%89%E9%80%82%E5%BA%94%E6%80%A7%E7%89%B9%E8%89%B2%E7%9A%84%E8%87%AA%E5%8A%A8%E6%8E%A7%E5%88%B6%E7%B3%BB%E7%BB%9F%5D.pdf?cts=D39A91A92A31Fccd73&ctp=39A91A92A31&ctt=1728470964&limit=1&spd=50000&ctk=0f056fafc06b2caae1fbc09398baa987&chk=760e47c028b68ea41eeca1d09b84cce9-8535153&mtd=1
###
https://92-cucc-data.bego.cc/d4015376/0f056fafc06b2caae1fbc09398baa987/500-%E6%95%B0%E5%AD%A6%E4%B8%9B%E4%B9%A6.-.%5B%E6%8E%A7%E5%88%B6%E8%AE%BA%5D.%5B%E5%85%B7%E6%9C%89%E9%80%82%E5%BA%94%E6%80%A7%E7%89%B9%E8%89%B2%E7%9A%84%E8%87%AA%E5%8A%A8%E6%8E%A7%E5%88%B6%E7%B3%BB%E7%BB%9F%5D.pdf?cts=D39A91A92A31Fccd73&ctp=39A91A92A31&ctt=1728470964&limit=1&spd=50000&ctk=0f056fafc06b2caae1fbc09398baa987&chk=760e47c028b68ea41eeca1d09b84cce9-8535153&mtd=1

Some files were not shown because too many files have changed in this diff Show More