mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2025-12-17 12:53:02 +00:00
0.0
This commit is contained in:
@@ -124,4 +124,8 @@ public abstract class PanBase implements IPanTool {
|
||||
}
|
||||
}
|
||||
|
||||
protected void complete(String url) {
|
||||
promise.complete(url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ package cn.qaiu.parser;
|
||||
|
||||
import cn.qaiu.parser.impl.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 枚举类 PanDomainTemplate 定义了不同网盘服务的模板信息,包括:
|
||||
* <ul>
|
||||
@@ -75,21 +79,54 @@ public enum PanDomainTemplate {
|
||||
"https://474b\\.com/file/(.+)",
|
||||
"https://474b.com/file/{shareKey}",
|
||||
CtTool.class),
|
||||
|
||||
// =====================音乐类解析 分享链接标志->MxxS (单歌曲/普通音质)==========================
|
||||
// http://163cn.tv/xxx
|
||||
MNE("网易云音乐",
|
||||
MNES("网易云音乐分享",
|
||||
"http(s)?://163cn\\.tv/(.+)",
|
||||
"http://163cn.tv/{shareKey}",
|
||||
MneTool.class),
|
||||
MnesTool.class),
|
||||
MNE("网易云音乐",
|
||||
"https://music\\.163\\.com/(#/)?song\\?id=(.+)",
|
||||
"https://music.163.com/#/song?id={shareKey}",
|
||||
MnesTool.MneTool.class),
|
||||
// https://c6.y.qq.com/base/fcgi-bin/u?__=xxx
|
||||
MQQ("QQ音乐",
|
||||
MQQS("QQ音乐分享",
|
||||
"https://(.+)\\.y\\.qq\\.com/base/fcgi-bin/u\\?__=(.+)",
|
||||
"https://c6.y.qq.com/base/fcgi-bin/u?__={shareKey}",
|
||||
MqqTool.class),
|
||||
// https://y.qq.com/n/ryqq/songDetail/000XjcLg0fbRjv?songtype=0
|
||||
MQQ("QQ音乐",
|
||||
"https://y\\.qq\\.com/n/ryqq/songDetail/(.+)\\?.*",
|
||||
"https://y.qq.com/n/ryqq/songDetail/{shareKey}",
|
||||
MqqTool.class),
|
||||
|
||||
// https://t1.kugou.com/song.html?id=xxx
|
||||
MKG("酷狗音乐",
|
||||
MKGS("酷狗音乐分享",
|
||||
"https://(.+)\\.kugou\\.com/song\\.html\\?id=(.+)",
|
||||
"https://t1.kugou.com/song.html?id={shareKey}",
|
||||
MkgTool.class),
|
||||
MkgsTool.class),
|
||||
// https://www.kugou.com/share/2bi8Fe9CSV3.html?id=2bi8Fe9CSV3#6ed9gna4"
|
||||
MKGS2("酷狗音乐分享2",
|
||||
"https://www\\.kugou\\.com/share/(.+).html\\?.*",
|
||||
"https://www.kugou.com/share/{shareKey}.html",
|
||||
MkgsTool.Mkgs2Tool.class),
|
||||
// https://www.kugou.com/mixsong/2bi8Fe9CSV3
|
||||
MKG("酷狗音乐",
|
||||
"https://(.+)\\.kugou\\.com/song\\.html\\?id=(.+)",
|
||||
"https://www.kugou.com/mixsong/{shareKey}",
|
||||
MkgsTool.MkgTool.class),
|
||||
//
|
||||
MKWS("酷我音乐分享*",
|
||||
"https://(.+)\\.kugou\\.com/song\\.html\\?id=(.+)",
|
||||
"https://t1.kugou.com/song.html?id={shareKey}",
|
||||
MkwTool.class),
|
||||
//
|
||||
MMGS("咪咕音乐分享",
|
||||
"https://(.+)\\.kugou\\.com/song\\.html\\?id=(.+)",
|
||||
"https://t1.kugou.com/song.html?id={shareKey}",
|
||||
MkwTool.class),
|
||||
// =====================私有盘解析==========================
|
||||
// https://pan.huang1111.cn/s/xxx
|
||||
// 通用域名([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}
|
||||
CE("Cloudreve",
|
||||
@@ -133,4 +170,22 @@ public enum PanDomainTemplate {
|
||||
public Class<? extends IPanTool> getToolClass() {
|
||||
return toolClass;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 校验重复
|
||||
Set<String> collect =
|
||||
Arrays.stream(PanDomainTemplate.values()).map(PanDomainTemplate::getRegexPattern).collect(Collectors.toSet());
|
||||
if (collect.size()<PanDomainTemplate.values().length) {
|
||||
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("有重复枚举标准链接");
|
||||
}
|
||||
System.out.println(collect);
|
||||
System.out.println(collect2);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ 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.MultiMap;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
@@ -13,8 +12,12 @@ 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 MkgTool extends PanBase {
|
||||
public class MkgsTool extends PanBase {
|
||||
|
||||
public static final String API_URL = "https://m.kugou.com/app/i/getSongInfo.php?cmd=playInfo&hash={hash}";
|
||||
|
||||
@@ -57,7 +60,7 @@ public class MkgTool extends PanBase {
|
||||
headers.set("Upgrade-Insecure-Requests", "1");
|
||||
};
|
||||
|
||||
public MkgTool(ShareLinkInfo shareLinkInfo) {
|
||||
public MkgsTool(ShareLinkInfo shareLinkInfo) {
|
||||
super(shareLinkInfo);
|
||||
}
|
||||
|
||||
@@ -66,32 +69,55 @@ public class MkgTool extends PanBase {
|
||||
// String shareUrl = "https://t1.kugou.com/song.html?id=2bi8Fe9CSV3";
|
||||
clientNoRedirects.getAbs(shareUrl).send().onSuccess(res -> {
|
||||
String locationURL = res.headers().get("Location");
|
||||
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));
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ 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;
|
||||
@@ -41,9 +42,21 @@ public class MkwTool extends PanBase {
|
||||
var token = matcher.group(2);
|
||||
String sign = JsExecUtils.getKwSign(token, key);
|
||||
System.out.println(sign);
|
||||
clientSession.getAbs(UriTemplate.of(API_URL)).setQueryParam("mid", "395500809")
|
||||
.putHeader("Secret", sign).putHeader("Cookie", key + "=" + token).send().onSuccess(res -> {
|
||||
System.out.println(res.bodyAsString());
|
||||
clientSession.getAbs(UriTemplate.of(API_URL)).setTemplateParam("mid", "395500809")
|
||||
.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("链接已失效");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail("解析失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
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 MneTool extends PanBase {
|
||||
|
||||
|
||||
public static final String API_URL = "https://music.163.com/song/media/outer/url?id={id}";
|
||||
|
||||
|
||||
public MneTool(ShareLinkInfo shareLinkInfo) {
|
||||
super(shareLinkInfo);
|
||||
}
|
||||
|
||||
public Future<String> parse() {
|
||||
String shareUrl = shareLinkInfo.getStandardUrl();
|
||||
clientNoRedirects.getAbs(shareUrl).send().onSuccess(res -> {
|
||||
String locationURL = res.headers().get("Location");
|
||||
String id = URLUtil.from(locationURL).getParam("id");
|
||||
clientNoRedirects.getAbs(UriTemplate.of(API_URL)).setTemplateParam("id", id).send()
|
||||
.onSuccess(res2 -> {
|
||||
promise.complete(res2.headers().get("Location"));
|
||||
}).onFailure(handleFail(API_URL.replace("{id}", id)));
|
||||
}).onFailure(handleFail(shareUrl));
|
||||
return promise.future();
|
||||
}
|
||||
}
|
||||
54
parser/src/main/java/cn/qaiu/parser/impl/MnesTool.java
Normal file
54
parser/src/main/java/cn/qaiu/parser/impl/MnesTool.java
Normal file
@@ -0,0 +1,54 @@
|
||||
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 -> {
|
||||
promise.complete(res2.headers().get("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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -329,73 +329,4 @@ 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -167,8 +167,10 @@ public interface JsContent {
|
||||
}
|
||||
var salt = Math.round(Math.random() * 1000000000) % 100000000;
|
||||
prand += salt;
|
||||
var flag = 1;
|
||||
while (prand.length > 10) {
|
||||
prand = (parseInt(prand.substring(0, 10)) + parseInt(prand.substring(10, prand.length))).toString();
|
||||
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 = "";
|
||||
|
||||
@@ -8,8 +8,6 @@ import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import static cn.qaiu.util.AESUtils.encrypt;
|
||||
|
||||
/**
|
||||
* 执行Js脚本
|
||||
*
|
||||
@@ -85,13 +83,10 @@ public class JsExecUtils {
|
||||
|
||||
public static void main(String[] args) {
|
||||
//encrypt("ZYcEEs2JdncXG8zAaytJiXxmbyhH2wxb", "Hm_Iuvt_cdb524f42f23cer9b268564v7y735ewrq2324")
|
||||
//'7909e8e754545a61ba4bc3c90c82cb6c69b6859d5ea2e46a6bf913d1b4f11dee011dced1'
|
||||
// 1e3170f1cc1ca75172409e443b89261ec777e190ebc595b458b8e114a912a9544d2b467323f8ca011b2ed0
|
||||
// 93a44ef48949d950c91303c84d36
|
||||
// 95dea502a45fb153f68d8da0bf8e4a095a001e396f60837e9c1b58a48969eb77038234d2
|
||||
// 93c3750f6ccf9d11b5c304b32495
|
||||
System.out.println(getKwSign("Hm_lvt_cdb524f42f0ce19b169a8071123a4797", "1729503755"));
|
||||
System.out.println(getKwSign("HelloWorld", "password123"));
|
||||
// 1a9b1a33222a78d6506e0aeaacf5b9b69984954de79e98e3ef4766c009025b7000000000
|
||||
// acb0a82caa6ee641ca99ad81ace7081f58412e2148619827aa0a038a8d76c75000000000
|
||||
// f7a05b893131238ee4d1f31a85401b64056bb09988b5b9c2b87c12542578360600000000
|
||||
System.out.println(getKwSign("c7nkKBeXXzCyTQ8Wc8DRNYc4Th3f6hTE", "Hm_Iuvt_cdb524f42f23cer9b268564v7y735ewrq2324"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user