mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2025-12-17 04:43:02 +00:00
奶牛快传支持下载zip目录分享#11, core框架优化
This commit is contained in:
@@ -2,6 +2,7 @@ package cn.qaiu.lz.common.parser.impl;
|
|||||||
|
|
||||||
import cn.qaiu.lz.common.parser.IPanTool;
|
import cn.qaiu.lz.common.parser.IPanTool;
|
||||||
import cn.qaiu.lz.common.parser.PanBase;
|
import cn.qaiu.lz.common.parser.PanBase;
|
||||||
|
import cn.qaiu.lz.common.util.JsExecUtils;
|
||||||
import cn.qaiu.vx.core.util.VertxHolder;
|
import cn.qaiu.vx.core.util.VertxHolder;
|
||||||
import io.vertx.core.Future;
|
import io.vertx.core.Future;
|
||||||
import io.vertx.core.MultiMap;
|
import io.vertx.core.MultiMap;
|
||||||
@@ -9,7 +10,10 @@ import io.vertx.core.Promise;
|
|||||||
import io.vertx.core.json.JsonObject;
|
import io.vertx.core.json.JsonObject;
|
||||||
import io.vertx.ext.web.client.WebClient;
|
import io.vertx.ext.web.client.WebClient;
|
||||||
import io.vertx.ext.web.client.WebClientOptions;
|
import io.vertx.ext.web.client.WebClientOptions;
|
||||||
|
import org.openjdk.nashorn.api.scripting.ScriptObjectMirror;
|
||||||
|
|
||||||
|
import javax.script.ScriptException;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@@ -29,6 +33,42 @@ public class LzTool extends PanBase implements IPanTool {
|
|||||||
super(key, pwd);
|
super(key, pwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
var wsk_sign = 'c20230818';
|
||||||
|
var aihidcms = 'Fn5L';
|
||||||
|
var iucjdsd = '';
|
||||||
|
var ws_sign = 'c20230818';
|
||||||
|
var sasign = 'B2EBPw8_bBDVRWFdoAzMGOlI5ATwEbVFgV2NVZwVhATYILld0WjoAZQhoVDsEYlZjBm4BNgVoVGcHMQ_c_c';
|
||||||
|
var ajaxdata = '?ctdf';
|
||||||
|
$.ajax({
|
||||||
|
type : 'post',
|
||||||
|
url : '/ajaxm.php',
|
||||||
|
//b data : { 'action':'downprocess','signs':ajaxdata,'sign':'w},
|
||||||
|
data : { 'action':'downprocess','signs':ajaxdata,'sign':sasign,'websign':iucjdsd,'websignkey':aihidcms,'ves':1 },
|
||||||
|
//b data : { 'action':'downprocess','signs':ajaxdata,'sign':'','websign':ws_sign,'websignkey':wsk_sign,'ves':1 },
|
||||||
|
dataType : 'json',
|
||||||
|
success:function(msg){
|
||||||
|
var date = msg;
|
||||||
|
if(date.zt == '1'){
|
||||||
|
$("#tourl").html("<a href="+date.dom+"/file/"+ date.url +" target=_blank rel=noreferrer><span class=txt>电信下载</span><span class='txt txtc'>联通下载</span><span class=txt>普通下载</span></a>");
|
||||||
|
setTimeout('$("#outime").css("display","block");',1800000);
|
||||||
|
}else{
|
||||||
|
$("#tourl").html("网页超时,请刷新");
|
||||||
|
};
|
||||||
|
|
||||||
|
},
|
||||||
|
error:function(){
|
||||||
|
$("#tourl").html("获取失败,请刷新");
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析器
|
||||||
|
* @return url String
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public Future<String> parse() {
|
public Future<String> parse() {
|
||||||
String sUrl = key.startsWith("https://") ? key : SHARE_URL_PREFIX + "/" + key;
|
String sUrl = key.startsWith("https://") ? key : SHARE_URL_PREFIX + "/" + key;
|
||||||
|
|
||||||
@@ -41,33 +81,59 @@ public class LzTool extends PanBase implements IPanTool {
|
|||||||
Matcher matcher = compile.matcher(html);
|
Matcher matcher = compile.matcher(html);
|
||||||
if (!matcher.find()) {
|
if (!matcher.find()) {
|
||||||
// 没有Iframe说明是加密分享, 匹配sign通过密码请求下载页面
|
// 没有Iframe说明是加密分享, 匹配sign通过密码请求下载页面
|
||||||
Pattern compile2 = Pattern.compile("sign=(\\w{16,})");
|
// 去TMD正则
|
||||||
Matcher matcher2 = compile2.matcher(html);
|
String jsText = getJsText(html);
|
||||||
if (!matcher2.find()) {
|
try {
|
||||||
fail(sUrl + ": sign正则匹配失败, 可能分享已失效");
|
ScriptObjectMirror scriptMirror = JsExecUtils.executeDynamicJs(jsText, "down_p");
|
||||||
|
System.out.println(scriptMirror);
|
||||||
|
|
||||||
|
} catch (ScriptException | NoSuchMethodException e) {
|
||||||
|
fail(e, "js引擎执行失败");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String sign = matcher2.group(1);
|
|
||||||
getDownURL(promise, sUrl, client, sign);
|
// getDownURL(promise, sUrl, client, sign);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String iframePath = matcher.group(1);
|
String iframePath = matcher.group(1);
|
||||||
client.getAbs(SHARE_URL_PREFIX + iframePath).send().onSuccess(res2 -> {
|
client.getAbs(SHARE_URL_PREFIX + iframePath).send().onSuccess(res2 -> {
|
||||||
String html2 = res2.bodyAsString();
|
String html2 = res2.bodyAsString();
|
||||||
System.out.println(html);
|
|
||||||
Matcher matcher2 = Pattern.compile("'sign'\s*:\s*'(\\w+)'").matcher(html2);
|
// 去TMD正则
|
||||||
if (!matcher2.find()) {
|
// Matcher matcher2 = Pattern.compile("'sign'\s*:\s*'(\\w+)'").matcher(html2);
|
||||||
|
String jsText = getJsText(html2);
|
||||||
|
if (jsText == null) {
|
||||||
fail(SHARE_URL_PREFIX + iframePath + " -> " + sUrl + ": sign正则匹配失败, 可能分享已失效");
|
fail(SHARE_URL_PREFIX + iframePath + " -> " + sUrl + ": sign正则匹配失败, 可能分享已失效");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String sign = matcher2.group(1);
|
try {
|
||||||
getDownURL(promise, sUrl, client, sign);
|
ScriptObjectMirror scriptObjectMirror = JsExecUtils.executeDynamicJs(jsText, null);
|
||||||
|
getDownURL(promise, sUrl, client, (Map<String, String>) scriptObjectMirror.get("data"));
|
||||||
|
} catch (ScriptException | NoSuchMethodException e) {
|
||||||
|
fail(e, "js引擎执行失败");
|
||||||
|
}
|
||||||
}).onFailure(handleFail(SHARE_URL_PREFIX));
|
}).onFailure(handleFail(SHARE_URL_PREFIX));
|
||||||
}).onFailure(handleFail(sUrl));
|
}).onFailure(handleFail(sUrl));
|
||||||
return promise.future();
|
return promise.future();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getDownURL(Promise<String> promise, String key, WebClient client, String sign) {
|
private String getJsText(String html) {
|
||||||
|
String jsTagStart = "<script type=\"text/javascript\">";
|
||||||
|
String jsTagEnd = "</script>";
|
||||||
|
int index = html.indexOf(jsTagStart);
|
||||||
|
if (index == -1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int startPos = index + jsTagStart.length();
|
||||||
|
int endPos = html.indexOf(jsTagEnd, startPos);
|
||||||
|
return html.substring(startPos, endPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getDownURL(Promise<String> promise, String key, WebClient client, Map<String, ?> signMap) {
|
||||||
|
MultiMap map = MultiMap.caseInsensitiveMultiMap();
|
||||||
|
signMap.forEach((k,v)->{
|
||||||
|
map.set(k,v.toString());
|
||||||
|
});
|
||||||
MultiMap headers = MultiMap.caseInsensitiveMultiMap();
|
MultiMap headers = MultiMap.caseInsensitiveMultiMap();
|
||||||
var userAgent2 = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, " +
|
var userAgent2 = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, " +
|
||||||
"like " +
|
"like " +
|
||||||
@@ -81,8 +147,7 @@ public class LzTool extends PanBase implements IPanTool {
|
|||||||
String url = SHARE_URL_PREFIX + "/ajaxm.php";
|
String url = SHARE_URL_PREFIX + "/ajaxm.php";
|
||||||
client.postAbs(url).putHeaders(headers).sendForm(MultiMap
|
client.postAbs(url).putHeaders(headers).sendForm(MultiMap
|
||||||
.caseInsensitiveMultiMap()
|
.caseInsensitiveMultiMap()
|
||||||
.set("action", "downprocess")
|
.setAll(map)).onSuccess(res2 -> {
|
||||||
.set("sign", sign).set("p", pwd)).onSuccess(res2 -> {
|
|
||||||
JsonObject urlJson = res2.bodyAsJsonObject();
|
JsonObject urlJson = res2.bodyAsJsonObject();
|
||||||
if (urlJson.getInteger("zt") != 1) {
|
if (urlJson.getInteger("zt") != 1) {
|
||||||
fail(urlJson.getString("inf"));
|
fail(urlJson.getString("inf"));
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package cn.qaiu.lz.common.util;
|
package cn.qaiu.lz.common.util;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.openjdk.nashorn.api.scripting.ScriptObjectMirror;
|
import org.openjdk.nashorn.api.scripting.ScriptObjectMirror;
|
||||||
|
|
||||||
import javax.script.Invocable;
|
import javax.script.Invocable;
|
||||||
@@ -9,14 +10,21 @@ import javax.script.ScriptException;
|
|||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行Js脚本
|
* 执行Js脚本
|
||||||
|
*
|
||||||
* @author <a href="https://qaiu.top">QAIU</a>
|
* @author <a href="https://qaiu.top">QAIU</a>
|
||||||
* @date 2023/7/29 17:35
|
* @date 2023/7/29 17:35
|
||||||
*/
|
*/
|
||||||
public class JsExecUtils {
|
public class JsExecUtils {
|
||||||
private static final String JS_PATH = "/js/ye123.js";
|
private static final String JS_PATH = "js/ye123.js";
|
||||||
|
private static final String LZ_JS_PATH = "js/lz.js";
|
||||||
|
|
||||||
|
private static final String RES_PATH;
|
||||||
private static final Invocable inv;
|
private static final Invocable inv;
|
||||||
|
|
||||||
// 初始化脚本引擎
|
// 初始化脚本引擎
|
||||||
@@ -28,9 +36,9 @@ public class JsExecUtils {
|
|||||||
if (resource == null) {
|
if (resource == null) {
|
||||||
throw new RuntimeException("js resource path is null");
|
throw new RuntimeException("js resource path is null");
|
||||||
}
|
}
|
||||||
String path = resource.getPath();
|
RES_PATH = resource.getPath();
|
||||||
String reader = path + JS_PATH;
|
String reader = RES_PATH + JS_PATH;
|
||||||
try (FileReader fReader = new FileReader(reader)){
|
try (FileReader fReader = new FileReader(reader)) {
|
||||||
engine.eval(fReader);
|
engine.eval(fReader);
|
||||||
fReader.close();
|
fReader.close();
|
||||||
inv = (Invocable) engine;
|
inv = (Invocable) engine;
|
||||||
@@ -42,8 +50,40 @@ public class JsExecUtils {
|
|||||||
/**
|
/**
|
||||||
* 调用js文件
|
* 调用js文件
|
||||||
*/
|
*/
|
||||||
public static ScriptObjectMirror executeJs(String functionName, Object... args) throws ScriptException, NoSuchMethodException {
|
public static ScriptObjectMirror executeJs(String functionName, Object... args) throws ScriptException,
|
||||||
//调用js中的方法
|
NoSuchMethodException {
|
||||||
|
//调用js中的函数
|
||||||
return (ScriptObjectMirror) inv.invokeFunction(functionName, args);
|
return (ScriptObjectMirror) inv.invokeFunction(functionName, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用执行蓝奏云js文件
|
||||||
|
*/
|
||||||
|
public static ScriptObjectMirror executeDynamicJs(String jsText, String funName) throws ScriptException,
|
||||||
|
NoSuchMethodException {
|
||||||
|
ScriptEngineManager engineManager = new ScriptEngineManager();
|
||||||
|
ScriptEngine engine = engineManager.getEngineByName("JavaScript"); // 得到脚本引擎
|
||||||
|
try {
|
||||||
|
//获取文件所在的相对路径
|
||||||
|
Path path;
|
||||||
|
try {
|
||||||
|
path = Paths.get(RES_PATH + LZ_JS_PATH);
|
||||||
|
} catch (RuntimeException ioe) {
|
||||||
|
path = Paths.get(RES_PATH.substring(1) + LZ_JS_PATH);
|
||||||
|
}
|
||||||
|
String jsContent = Files.readString(path) + "\n" + jsText;
|
||||||
|
engine.eval(jsContent);
|
||||||
|
Invocable inv = (Invocable) engine;
|
||||||
|
//调用js中的函数
|
||||||
|
if (StringUtils.isNotEmpty(funName)) {
|
||||||
|
inv.invokeFunction(funName);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ScriptObjectMirror) engine.get("signObj");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,4 +24,13 @@ https://developer.lanzoug.com/file/?VDJbZVxtADFSWwY+U2YHa1FuU2tTYgBnBnUGZFNmWylS
|
|||||||
###
|
###
|
||||||
https://developer.lanzoug.com/file/?VTNVa1tqAjMFDAM7BDEAbAE+U2tfbgZhBnVbOQUwVCYEb1IoAToCNwQhVnRXLlcyVWAEdl9uVzkEbFYxVm5VeVVlVSxbNwJ4BWADeAQyAGgBNVN4X3oGbQZxW3sFP1Q8BGhSYAEDAj8ENlY9VzJXZ1U3BDFfMldlBDFWaVY9VXJVM1VxWzsCZwVlA2QEYAAwAWtTYF8wBiIGcVstBWRUZwQ0UjcBbwJ5BGJWNVcsV2RVOgQuX2NXZgQ2VjJWMlVhVWdVNlswAm8FagMxBGAANgE6UzdfYwZgBjFbbAU6VGwEZVIyAWQCZQRkVjZXMFdmVTcENV8uVy8EalYgVixVIVUmVWdbdAI/BTcDaARhADEBblNvXzQGPQY5W3sFLVQ8BGlSYAE6AmsEY1Y2VztXY1U/BDFfM1dnBDRWZFYkVXpVc1VkW2oCIQVuA2QEZgA5AW5TZl8wBjYGMFtkBWFUcwRxUnUBKwJrBGNWNlc7V2NVPwQxXzJXZQQzVmdWLFUhVTxVcls7AmcFYgNnBH4AMwFoU2RfLgY1BjVbawV3VGIEPA==
|
https://developer.lanzoug.com/file/?VTNVa1tqAjMFDAM7BDEAbAE+U2tfbgZhBnVbOQUwVCYEb1IoAToCNwQhVnRXLlcyVWAEdl9uVzkEbFYxVm5VeVVlVSxbNwJ4BWADeAQyAGgBNVN4X3oGbQZxW3sFP1Q8BGhSYAEDAj8ENlY9VzJXZ1U3BDFfMldlBDFWaVY9VXJVM1VxWzsCZwVlA2QEYAAwAWtTYF8wBiIGcVstBWRUZwQ0UjcBbwJ5BGJWNVcsV2RVOgQuX2NXZgQ2VjJWMlVhVWdVNlswAm8FagMxBGAANgE6UzdfYwZgBjFbbAU6VGwEZVIyAWQCZQRkVjZXMFdmVTcENV8uVy8EalYgVixVIVUmVWdbdAI/BTcDaARhADEBblNvXzQGPQY5W3sFLVQ8BGlSYAE6AmsEY1Y2VztXY1U/BDFfM1dnBDRWZFYkVXpVc1VkW2oCIQVuA2QEZgA5AW5TZl8wBjYGMFtkBWFUcwRxUnUBKwJrBGNWNlc7V2NVPwQxXzJXZQQzVmdWLFUhVTxVcls7AmcFYgNnBH4AMwFoU2RfLgY1BjVbawV3VGIEPA==
|
||||||
|
|
||||||
|
### 20230819新规则
|
||||||
|
POST /ajaxm.php
|
||||||
|
|
||||||
|
# var wsk_sign = 'c20230818';
|
||||||
|
# var aihidcms = 'J5Nh';
|
||||||
|
# var iucjdsd = '';
|
||||||
|
# var ws_sign = 'c20230818';
|
||||||
|
# var sasign = 'AGZQbgk4UGEDCgo1ATEGOlY_aBTlSNVRiV2gEMlA1WmkBJ1R3AWFUMVY2VDsDZQE0Vj4CMgNsADdXZw_c_c';
|
||||||
|
# var ajaxdata = '?ctdf';
|
||||||
|
data : { 'action':'downprocess','signs':ajaxdata,'sign':sasign,'websign':iucjdsd,'websignkey':aihidcms,'ves':1 }
|
||||||
|
|||||||
40
web-service/src/main/resources/js/lz.js
Normal file
40
web-service/src/main/resources/js/lz.js
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
* 蓝奏云解析器js签名获取工具
|
||||||
|
*/
|
||||||
|
|
||||||
|
var signObj;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
var $,jQuery;
|
||||||
|
|
||||||
|
$ = jQuery = function(){
|
||||||
|
return new jQuery.fn.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
jQuery.fn = jQuery.prototype = {
|
||||||
|
init:function(){
|
||||||
|
return {
|
||||||
|
focus: function(a) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jQuery.fn.init.prototype = jQuery.fn;
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 伪装ajax函数获取关键数据
|
||||||
|
var $ = {
|
||||||
|
ajax: function(obj) {
|
||||||
|
signObj = obj
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var document = {
|
||||||
|
getElementById: function (v) {
|
||||||
|
return {
|
||||||
|
value : v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user