fix(parser): fix FangCloud share validity check and h5 share link regex

Root cause confirmed against a live share link: FcTool never actually
checked share validity against the info API — it read a top-level
"is_valid" field that the endpoint doesn't return. The real validity
flags (process.is_closed / process.is_expired) live under "process",
so an invalid share fell through to HTML scraping and surfaced a
confusing "未匹配到文件id(typed_id)" error instead of a clear
"分享已失效" message. parse() now checks share_links/info first and
fails fast with a clear message when the share is closed/expired.

Also widen PanDomainTemplate's FC regex to accept the mobile H5
landing page path (/h5/share/{key}), which previously didn't match
at all.

Updated verify_fangcloud_share.py to reflect the confirmed API
response shape instead of the earlier incorrect guess.
This commit is contained in:
Claude
2026-08-13 07:46:29 +00:00
parent 449fd741ac
commit 6c709fde65
3 changed files with 137 additions and 188 deletions
@@ -121,9 +121,9 @@ public enum PanDomainTemplate {
"https://lecloud.lenovo.com/share/{shareKey}",
LeTool.class),
// https://v2.fangcloud.com/s/
// https://v2.fangcloud.com/s/ https://v2.fangcloud.cn/h5/share/ (移动端H5落地页)
FC("亿方云",
compile("https://v2\\.fangcloud\\.(com|cn)/(s|share|sharing)/(?<KEY>.+)"),
compile("https://v2\\.fangcloud\\.(com|cn)/(?:h5/)?(s|share|sharing)/(?<KEY>.+)"),
"https://v2.fangcloud.com/s/{shareKey}",
"https://www.fangcloud.com/",
FcTool.class),
@@ -22,6 +22,7 @@ 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/";
private static final String SHARE_INFO_URL = "https://v2.fangcloud.cn/apps/share_links/info/";
private static final String DOWN_REQUEST_URL = "https://v2.fangcloud.cn/apps/files/download?file_id={fid}" +
"&scenario=share&unique_name={uname}";
@@ -38,6 +39,25 @@ public class FcTool extends PanBase {
final String dataKey = shareLinkInfo.getShareKey();
final String pwd = shareLinkInfo.getSharePassword();
WebClientSession sClient = WebClientSession.create(client);
// 先查询分享有效性, 避免分享已失效/已过期时仍去解析HTML, 报出令人困惑的技术错误
sClient.getAbs(SHARE_INFO_URL + dataKey).send().onSuccess(infoRes -> {
JsonObject infoJson = asJson(infoRes);
if (promise.future().isComplete()) {
return;
}
JsonObject process = infoJson.getJsonObject("process");
boolean isClosed = process != null && Boolean.TRUE.equals(process.getBoolean("is_closed"));
boolean isExpired = process != null && Boolean.TRUE.equals(process.getBoolean("is_expired"));
if (process == null || isClosed || isExpired) {
fail("分享已失效或不存在");
return;
}
doParse(dataKey, pwd, sClient);
}).onFailure(handleFail(SHARE_INFO_URL + dataKey));
return promise.future();
}
private void doParse(String dataKey, String pwd, WebClientSession sClient) {
// 第一次请求 自动重定向
sClient.getAbs(SHARE_URL_PREFIX + dataKey).send().onSuccess(res -> {
@@ -67,7 +87,6 @@ public class FcTool extends PanBase {
}
getDownURL(dataKey, promise, res, sClient);
}).onFailure(handleFail(SHARE_URL_PREFIX + dataKey));
return promise.future();
}
private void getDownURL(String dataKey, Promise<String> promise, HttpResponse<Buffer> res,