mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2025-12-15 11:53:02 +00:00
vert.x升级到4.4.1
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
# lz-cow-api
|
||||
蓝奏云-奶牛快传的直链解析的API服务
|
||||
使用Jdk17+Vert.x4.4.1+Jsoup
|
||||
Core模块集成Vert.x实现声明式路由API
|
||||
|
||||
示例:
|
||||
```
|
||||
// 解析并重定向到直链
|
||||
###
|
||||
# @no-redirect
|
||||
GET http://127.0.0.1:6400/parse?url=https://lanzoux.com/ia2cntg
|
||||
GET http://127.0.0.1:6400/parser?url=https://lanzoux.com/ia2cntg
|
||||
###
|
||||
# @no-redirect
|
||||
GET http://127.0.0.1:6400/parse?url=https://cowtransfer.com/s/9a644fe3e3a748
|
||||
GET http://127.0.0.1:6400/parser?url=https://cowtransfer.com/s/9a644fe3e3a748
|
||||
|
||||
// Rest请求(只提供共享文件Id): cow 奶牛快传; lz 蓝奏云
|
||||
###
|
||||
|
||||
18
bin/lz-api.service
Normal file
18
bin/lz-api.service
Normal file
@@ -0,0 +1,18 @@
|
||||
[Unit]
|
||||
Description=lz-api
|
||||
Documentation=https://qaiu.top
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
# User=USER
|
||||
ExecStart=/usr/bin/java -server -Xmx128m -jar /root/java/lz-cow-api-web/lz-cow-api-web-0.0.1.jar
|
||||
ExecStop=/bin/kill -s QUIT $MAINPID
|
||||
Restart=always
|
||||
StandOutput=syslog
|
||||
|
||||
StandError=inherit
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
10
bin/service-install.sh
Normal file
10
bin/service-install.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
cp ./lz-api.service /etc/systemd/system/
|
||||
|
||||
# 重新加载 systemd
|
||||
systemctl daemon-reload
|
||||
|
||||
# 运行服务
|
||||
systemctl start lz-api
|
||||
|
||||
# 在系统启动时启动服务
|
||||
systemctl enable lz-api
|
||||
@@ -14,11 +14,11 @@
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<vertx.version>4.1.3</vertx.version>
|
||||
<org.reflections.version>0.9.12</org.reflections.version>
|
||||
<vertx.version>4.4.1</vertx.version>
|
||||
<org.reflections.version>0.10.2</org.reflections.version>
|
||||
<lombok.version>1.18.12</lombok.version>
|
||||
<slf4j.version>2.0.5</slf4j.version>
|
||||
<commons-lang3.version>3.8.1</commons-lang3.version>
|
||||
<commons-lang3.version>3.12.0</commons-lang3.version>
|
||||
<jackson.version>2.11.3</jackson.version>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -67,18 +67,21 @@ public final class Deploy {
|
||||
* 打印logo
|
||||
*/
|
||||
private void outLogo(JsonObject conf) {
|
||||
Date date = new Date();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
int year = calendar.get(Calendar.YEAR);
|
||||
String logoTemplete = "\nWeb Server powered by: \n" +
|
||||
" ____ ____ _ _ _ \n" +
|
||||
"|_^^_| |_^^_| / |_ | | | | \n" +
|
||||
" \\ \\ / /.---. _ .--.`| |-' _ __ | |__| |_ \n" +
|
||||
" \\ \\ / // /__\\\\[ `/'`\\]| | [ \\ [ ]|____ _| \n" +
|
||||
" \\ V / | \\__., | | | |, _ > ' < _| |_ \n" +
|
||||
" \\_/ '.__.'[___] \\__/(_)[__]`\\_] |_____| \n" +
|
||||
" Version: %s; Framework version: %s; %s©%d.\n\n";
|
||||
calendar.setTime(new Date());
|
||||
var year = calendar.get(Calendar.YEAR);
|
||||
var logoTemplete = """
|
||||
|
||||
Web Server powered by:\s
|
||||
____ ____ _ _ _ \s
|
||||
|_^^_| |_^^_| / |_ | | | | \s
|
||||
\\ \\ / /.---. _ .--.`| |-' _ __ | |__| |_ \s
|
||||
\\ \\ / // /__\\\\[ `/'`\\]| | [ \\ [ ]|____ _|\s
|
||||
\\ V / | \\__., | | | |, _ > ' < _| |_ \s
|
||||
\\_/ '.__.'[___] \\__/(_)[__]`\\_] |_____|\s
|
||||
Version: %s; Framework version: %s; %s©%d.
|
||||
|
||||
""";
|
||||
|
||||
System.out.printf(logoTemplete,
|
||||
conf.getString("version_app"),
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package cn.qaiu.lz;
|
||||
|
||||
import cn.qaiu.vx.core.Deploy;
|
||||
import cn.qaiu.vx.core.util.VertxHolder;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import lombok.val;
|
||||
|
||||
|
||||
/**
|
||||
@@ -22,7 +24,6 @@ public class AppMain {
|
||||
* @param jsonObject 配置
|
||||
*/
|
||||
private static void exec(JsonObject jsonObject) {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -41,38 +41,36 @@ public class CowTool {
|
||||
}
|
||||
*/
|
||||
public static String parse(String fullUrl) throws IOException {
|
||||
String uniqueUrl = fullUrl.substring(fullUrl.lastIndexOf('/') + 1);
|
||||
String baseUrl = "https://cowtransfer.com/core/api/transfer/share";
|
||||
String result = Jsoup
|
||||
var uniqueUrl = fullUrl.substring(fullUrl.lastIndexOf('/') + 1);
|
||||
var baseUrl = "https://cowtransfer.com/core/api/transfer/share";
|
||||
var result = Jsoup
|
||||
.connect(baseUrl + "?uniqueUrl=" + uniqueUrl).ignoreContentType(true)
|
||||
.get()
|
||||
.text();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
var objectMapper = new ObjectMapper();
|
||||
Map<String, Object> map = objectMapper.readValue(result, new TypeReference<>() {
|
||||
});
|
||||
|
||||
if ("success".equals(map.get("message")) && map.containsKey("data")) {
|
||||
Map<String, Object> data = CastUtil.cast(map.get("data"));
|
||||
String guid = data.get("guid").toString();
|
||||
var guid = data.get("guid").toString();
|
||||
Map<String, Object> firstFile = CastUtil.cast(data.get("firstFile"));
|
||||
String fileId = firstFile.get("id").toString();
|
||||
String result2 = Jsoup
|
||||
var fileId = firstFile.get("id").toString();
|
||||
var result2 = Jsoup
|
||||
.connect(baseUrl + "/download?transferGuid=" + guid + "&fileId=" + fileId)
|
||||
.ignoreContentType(true)
|
||||
.get()
|
||||
.text();
|
||||
Map<String, Object> map2 = objectMapper.readValue(result2, new TypeReference<>() {
|
||||
});
|
||||
Map<String, Object> map2 = objectMapper.readValue(result2, new TypeReference<>() {});
|
||||
|
||||
if ("success".equals(map2.get("message")) && map2.containsKey("data")) {
|
||||
Map<String, Object> data2 = CastUtil.cast(map2.get("data"));
|
||||
String downloadUrl = data2.get("downloadUrl").toString();
|
||||
var downloadUrl = data2.get("downloadUrl").toString();
|
||||
if (StringUtils.isNotEmpty(downloadUrl)) {
|
||||
log.info("cow parse success: {}", downloadUrl);
|
||||
return downloadUrl;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
log.info("Cow parse field------------->end");
|
||||
return null;
|
||||
|
||||
@@ -18,27 +18,26 @@ import java.util.regex.Pattern;
|
||||
public class LzTool {
|
||||
|
||||
public static String parse(String fullUrl) throws Exception {
|
||||
String userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.3";
|
||||
String url = fullUrl.substring(0, fullUrl.lastIndexOf('/') + 1);
|
||||
String id = fullUrl.substring(fullUrl.lastIndexOf('/') + 1);
|
||||
var userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.3";
|
||||
var url = fullUrl.substring(0, fullUrl.lastIndexOf('/') + 1);
|
||||
var id = fullUrl.substring(fullUrl.lastIndexOf('/') + 1);
|
||||
Map<String, String> header = new HashMap<>();
|
||||
header.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
|
||||
header.put("referer", url);
|
||||
|
||||
|
||||
/*
|
||||
// 部分链接需要设置安卓UA
|
||||
sec-ch-ua: "Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"
|
||||
sec-ch-ua-mobile: ?1
|
||||
sec-ch-ua-platform: "Android"
|
||||
*/
|
||||
String userAgent2 = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36";
|
||||
|
||||
var userAgent2 = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36";
|
||||
Map<String, String> header2 = new HashMap<>();
|
||||
header2.put("Accept-Language", "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2");
|
||||
header2.put("sec-ch-ua-mobile", "sec-ch-ua-mobile");
|
||||
header2.put("sec-ch-ua-platform", "Android");
|
||||
header2.put("referer", url);
|
||||
|
||||
//第一次请求,获取iframe的地址
|
||||
String result = Jsoup.connect(url + id)
|
||||
.userAgent(userAgent)
|
||||
@@ -75,11 +74,11 @@ public class LzTool {
|
||||
.text()
|
||||
.replace("\\", "");
|
||||
//json转为map
|
||||
params = new ObjectMapper().readValue(result, new TypeReference<Map<String, String>>() {});
|
||||
params = new ObjectMapper().readValue(result, new TypeReference<>() {});
|
||||
// System.out.println(params);
|
||||
//通过json的数据拼接出最终的URL发起第最终请求,并得到响应信息头
|
||||
url = params.get("dom") + "/file/" + params.get("url");
|
||||
Map<String, String> headers = Jsoup.connect(url)
|
||||
var headers = Jsoup.connect(url)
|
||||
.ignoreContentType(true)
|
||||
.userAgent(userAgent2)
|
||||
.headers(header2)
|
||||
|
||||
@@ -36,14 +36,14 @@ public class ServerApi {
|
||||
return JsonResult.data("ok");
|
||||
}
|
||||
|
||||
@RouteMapping(value = "/parse", method = RouteMethod.GET)
|
||||
@RouteMapping(value = "/parser", method = RouteMethod.GET)
|
||||
public void parse(HttpServerResponse response, String url) throws Exception {
|
||||
if (url.contains("lanzou")) {
|
||||
String urlDownload = LzTool.parse(url);
|
||||
var urlDownload = LzTool.parse(url);
|
||||
log.info("url = {}", urlDownload);
|
||||
response.putHeader("location", urlDownload).setStatusCode(302).end();
|
||||
} else if (url.contains("cowtransfer.com")) {
|
||||
String urlDownload = CowTool.parse(url);
|
||||
var urlDownload = CowTool.parse(url);
|
||||
response.putHeader("location", urlDownload).setStatusCode(302).end();
|
||||
}
|
||||
|
||||
@@ -51,30 +51,30 @@ public class ServerApi {
|
||||
|
||||
@RouteMapping(value = "/lz/:id", method = RouteMethod.GET)
|
||||
public void lzParse(HttpServerResponse response, String id) throws Exception {
|
||||
String url = "https://wwa.lanzoux.com/" + id;
|
||||
String urlDownload = LzTool.parse(url);
|
||||
var url = "https://wwa.lanzoux.com/" + id;
|
||||
var urlDownload = LzTool.parse(url);
|
||||
log.info("url = {}", urlDownload);
|
||||
response.putHeader("location", urlDownload).setStatusCode(302).end();
|
||||
}
|
||||
|
||||
@RouteMapping(value = "/cow/:id", method = RouteMethod.GET)
|
||||
public void cowParse(HttpServerResponse response, String id) throws Exception {
|
||||
String url = "https://cowtransfer.com/s/" + id;
|
||||
String urlDownload = CowTool.parse(url);
|
||||
var url = "https://cowtransfer.com/s/" + id;
|
||||
var urlDownload = CowTool.parse(url);
|
||||
response.putHeader("location", urlDownload).setStatusCode(302).end();
|
||||
}
|
||||
|
||||
@RouteMapping(value = "/json/lz/:id", method = RouteMethod.GET)
|
||||
public JsonResult<String> lzParseJson(HttpServerResponse response, String id) throws Exception {
|
||||
String url = "https://wwa.lanzoux.com/" + id;
|
||||
String urlDownload = LzTool.parse(url);
|
||||
var url = "https://wwa.lanzoux.com/" + id;
|
||||
var urlDownload = LzTool.parse(url);
|
||||
log.info("url = {}", urlDownload);
|
||||
return JsonResult.data(urlDownload);
|
||||
}
|
||||
|
||||
@RouteMapping(value = "/json/cow/:id", method = RouteMethod.GET)
|
||||
public JsonResult<String> cowParseJson(HttpServerResponse response, String id) throws Exception {
|
||||
String url = "https://cowtransfer.com/s/" + id;
|
||||
var url = "https://cowtransfer.com/s/" + id;
|
||||
return JsonResult.data(CowTool.parse(url));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
GET http://127.0.0.1:6400/api/serverApi/test3?fullUrl=https://wwp.lanzoux.com/iNvid035jgcb
|
||||
###
|
||||
# @no-redirect
|
||||
GET http://127.0.0.1:6400/parse?url=https://lanzoux.com/ia2cntg
|
||||
GET http://127.0.0.1:6400/parser?url=https://lanzoux.com/ia2cntg
|
||||
###
|
||||
# @no-redirect
|
||||
GET http://127.0.0.1:6400/parse?url=https://cowtransfer.com/s/9a644fe3e3a748
|
||||
GET http://127.0.0.1:6400/parser?url=https://cowtransfer.com/s/9a644fe3e3a748
|
||||
###
|
||||
# @no-redirect
|
||||
GET http://127.0.0.1:6400/cow/9a644fe3e3a748
|
||||
|
||||
Reference in New Issue
Block a user