From 2056a91071785604a89a4086bab41e640e7d1abf Mon Sep 17 00:00:00 2001 From: q Date: Wed, 4 Feb 2026 17:09:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B6=85=E6=98=9F=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=EF=BC=8C=E6=B8=85=E7=90=86=E5=86=97=E4=BD=99=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../verticle/conf/HttpProxyConfConverter.java | 73 --------- .../vx/core/verticle/conf/HttpProxyConf.java | 89 ----------- .../cn/qaiu/parser/PanDomainTemplate.java | 2 +- .../java/cn/qaiu/parser/impl/PcxTool.java | 143 ++++++++++++++++-- 4 files changed, 129 insertions(+), 178 deletions(-) delete mode 100644 core/src/main/generated/cn/qaiu/vx/core/verticle/conf/HttpProxyConfConverter.java delete mode 100644 core/src/main/java/cn/qaiu/vx/core/verticle/conf/HttpProxyConf.java diff --git a/core/src/main/generated/cn/qaiu/vx/core/verticle/conf/HttpProxyConfConverter.java b/core/src/main/generated/cn/qaiu/vx/core/verticle/conf/HttpProxyConfConverter.java deleted file mode 100644 index 17b355a..0000000 --- a/core/src/main/generated/cn/qaiu/vx/core/verticle/conf/HttpProxyConfConverter.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.qaiu.vx.core.verticle.conf; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.JsonArray; -import io.vertx.core.json.impl.JsonUtil; -import java.time.Instant; -import java.time.format.DateTimeFormatter; -import java.util.Base64; - -/** - * Converter and mapper for {@link cn.qaiu.vx.core.verticle.conf.HttpProxyConf}. - * NOTE: This class has been automatically generated from the {@link cn.qaiu.vx.core.verticle.conf.HttpProxyConf} original class using Vert.x codegen. - */ -public class HttpProxyConfConverter { - - - private static final Base64.Decoder BASE64_DECODER = JsonUtil.BASE64_DECODER; - private static final Base64.Encoder BASE64_ENCODER = JsonUtil.BASE64_ENCODER; - - static void fromJson(Iterable> json, HttpProxyConf obj) { - for (java.util.Map.Entry member : json) { - switch (member.getKey()) { - case "password": - if (member.getValue() instanceof String) { - obj.setPassword((String)member.getValue()); - } - break; - case "port": - if (member.getValue() instanceof Number) { - obj.setPort(((Number)member.getValue()).intValue()); - } - break; - case "preProxyOptions": - if (member.getValue() instanceof JsonObject) { - obj.setPreProxyOptions(new io.vertx.core.net.ProxyOptions((io.vertx.core.json.JsonObject)member.getValue())); - } - break; - case "timeout": - if (member.getValue() instanceof Number) { - obj.setTimeout(((Number)member.getValue()).intValue()); - } - break; - case "username": - if (member.getValue() instanceof String) { - obj.setUsername((String)member.getValue()); - } - break; - } - } - } - - static void toJson(HttpProxyConf obj, JsonObject json) { - toJson(obj, json.getMap()); - } - - static void toJson(HttpProxyConf obj, java.util.Map json) { - if (obj.getPassword() != null) { - json.put("password", obj.getPassword()); - } - if (obj.getPort() != null) { - json.put("port", obj.getPort()); - } - if (obj.getPreProxyOptions() != null) { - json.put("preProxyOptions", obj.getPreProxyOptions().toJson()); - } - if (obj.getTimeout() != null) { - json.put("timeout", obj.getTimeout()); - } - if (obj.getUsername() != null) { - json.put("username", obj.getUsername()); - } - } -} diff --git a/core/src/main/java/cn/qaiu/vx/core/verticle/conf/HttpProxyConf.java b/core/src/main/java/cn/qaiu/vx/core/verticle/conf/HttpProxyConf.java deleted file mode 100644 index 5131fb6..0000000 --- a/core/src/main/java/cn/qaiu/vx/core/verticle/conf/HttpProxyConf.java +++ /dev/null @@ -1,89 +0,0 @@ -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; - } -} diff --git a/parser/src/main/java/cn/qaiu/parser/PanDomainTemplate.java b/parser/src/main/java/cn/qaiu/parser/PanDomainTemplate.java index 69ce2be..08fec7b 100644 --- a/parser/src/main/java/cn/qaiu/parser/PanDomainTemplate.java +++ b/parser/src/main/java/cn/qaiu/parser/PanDomainTemplate.java @@ -263,7 +263,7 @@ public enum PanDomainTemplate { // https://pan-yz.cldisk.com/external/m/file/953658049102462976 Pcx("超星云盘(需要referer头)", - compile("https://pan-yz\\.cldisk\\.com/external/m/file/(?\\w+)"), + compile("https://pan-yz\\.(chaoxing\\.com|cldisk\\.com)/external/m/file/(?\\w+)(\\?.*)?"), "https://pan-yz.cldisk.com/external/m/file/{shareKey}", PcxTool.class), // WPS:分享格式:https://www.kdocs.cn/l/ck0azivLlDi3 ;API格式:https://www.kdocs.cn/api/office/file/{shareKey}/download diff --git a/parser/src/main/java/cn/qaiu/parser/impl/PcxTool.java b/parser/src/main/java/cn/qaiu/parser/impl/PcxTool.java index c937b80..852456d 100644 --- a/parser/src/main/java/cn/qaiu/parser/impl/PcxTool.java +++ b/parser/src/main/java/cn/qaiu/parser/impl/PcxTool.java @@ -1,11 +1,13 @@ package cn.qaiu.parser.impl; +import cn.qaiu.entity.FileInfo; import cn.qaiu.entity.ShareLinkInfo; import cn.qaiu.parser.PanBase; +import cn.qaiu.util.FileSizeConverter; 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; /** * 超星云盘 @@ -19,24 +21,135 @@ public class PcxTool extends PanBase { public Future parse() { client.getAbs(shareLinkInfo.getShareUrl()) .send().onSuccess(res -> { - // 'download': 'https://d0.ananas.chaoxing.com/download/de08dcf546e4dd88a17bead86ff6338d?at_=1740211698795&ak_=d62a3acbd5ce43e1e8565b67990691e4&ad_=8c4ef22e980ee0dd9532ec3757ab19f8&fn=33.c' String body = res.bodyAsString(); - // 获取download - String str = "var fileinfo = {"; - String fileInfo = res.bodyAsString().substring(res.bodyAsString().indexOf(str) + str.length() - 1 - , res.bodyAsString().indexOf("};") + 1); - fileInfo = fileInfo.replace("'", "\""); - JsonObject jsonObject = new JsonObject(fileInfo); - String download = jsonObject.getString("download"); - if (download.contains("fn=")) { - complete(download); - } else { - fail("获取下载链接失败: 不支持的文件类型: {}", jsonObject.getString("suffix")); + try { + // 提取文件信息 + setFileInfo(body); + + // 直接用正则提取download链接 + String download = extractDownloadUrl(body); + if (download != null && download.contains("fn=")) { + complete(download); + } else { + fail("获取下载链接失败"); + } + } catch (Exception e) { + fail("解析文件信息失败: {}", e.getMessage()); } }).onFailure(handleFail(shareLinkInfo.getShareUrl())); return promise.future(); } + /** + * 从HTML中提取download链接 + */ + private String extractDownloadUrl(String html) { + // 匹配 'download': 'https://xxx' 或 "download": "https://xxx" + Pattern pattern = Pattern.compile("['\"]download['\"]\\s*:\\s*['\"]([^'\"]+)['\"]"); + Matcher matcher = pattern.matcher(html); + if (matcher.find()) { + return matcher.group(1); + } + return null; + } + + /** + * 从HTML中提取文件信息并设置到shareLinkInfo + */ + private void setFileInfo(String html) { + try { + FileInfo fileInfo = new FileInfo(); + + // 提取文件名:从标签或文件名input + String fileName = extractByRegex(html, "<title>([^<]+)"); + if (fileName == null) { + fileName = extractByRegex(html, "