Files
netdisk-fast-download/parser
qaiuandCursor Agent 542d246aab Parse Ctfile shares with the new url API and ALTCHA v2 (#303)
* Parse Ctfile shares with the new url API and ALTCHA v2

The legacy getfile.php and getdir.php endpoints now answer every share
with Cloudflare Turnstile. Password-free files and folders use ALTCHA
PBKDF2 instead: solve it off the event loop, reuse access_pass for the
same owner, and fetch the direct link from POST /url/download. Password
shares stay on Turnstile and are reported separately from missing links
and wrong or missing passwords.

Co-authored-by: qaiu <[email protected]>

* Add Ctfile v4 login parsing for password-protected shares

Password shares are blocked by Turnstile on the anonymous web API. When a
refresh token or access token is configured, convert the share to an xtc
link and use the official client list and fetch-url calls. Password-free
shares still use ALTCHA. Tests use short synthetic fixtures only.

Co-authored-by: qaiu <[email protected]>

* Parse password-protected Ctfile shares with anonymous ALTCHA

A password share's first response is often labeled Turnstile, but a fresh
ALTCHA token plus the passcode returns the file. Try that before any login.
Keep the v4 client only as a fallback when Turnstile remains and a token is
configured. Live checks download the sample PDF and a directory zip.

Co-authored-by: qaiu <[email protected]>

---------

Co-authored-by: Cursor Agent <[email protected]>
2026-11-24 16:14:43 +08:00
..

parser

NFD 解析器模块:聚合各类网盘/分享页解析,统一输出文件列表与下载信息,供上层下载器使用。

  • 语言:Java 17
  • 构建:Maven
  • 模块版本:10.2.5

依赖(Maven Central)

<dependency>
  <groupId>cn.qaiu</groupId>
  <artifactId>parser</artifactId>
  <version>10.2.5</version>
</dependency>
  • Gradle Groovy DSL:
dependencies {
  implementation 'cn.qaiu:parser:10.2.5'
}
  • Gradle Kotlin DSL:
dependencies {
  implementation("cn.qaiu:parser:10.2.5")
}

核心 API 速览

  • WebClientVertxInit:注入/获取 Vert.x 实例(内部 HTTP 客户端依赖)。
  • ParserCreate:从分享链接或类型构建解析器;生成短链 path。
  • IPanTool:统一解析接口(parse、parseFileList、parseById)。
  • CustomParserRegistry:自定义解析器注册中心(支持扩展)。
  • CustomParserConfig:自定义解析器配置类(支持扩展)。

使用示例(极简)

List<FileInfo> list = ParserCreate
  .fromShareUrl("https://share.feijipan.com/s/3pMsofZd")
  .createTool()
  .parseFileList()
  .toCompletionStage().toCompletableFuture().join();

完整示例与调试脚本见 parser/doc/README.md。

快速开始

  • 环境:JDK >= 17,Maven >= 3.9
  • 构建/安装:
mvn -pl parser -am clean package -DskipTests
mvn -pl parser -am install
  • 测试:
mvn -pl parser test

自定义解析器扩展

本模块支持用户自定义解析器扩展。通过简单的配置和注册,你可以添加自己的网盘解析实现:

// 1. 继承 PanBase 抽象类(推荐)
public class MyPanTool extends PanBase {
    public MyPanTool(ShareLinkInfo info) { 
        super(info);
    }
    @Override
    public Future<String> parse() { 
        // 使用 PanBase 提供的 HTTP 客户端
        client.getAbs("https://api.example.com")
            .send()
            .onSuccess(res -> complete(asJson(res).getString("url")))
            .onFailure(handleFail("请求失败"));
        return future();
    }
}

// 2. 注册到系统
CustomParserConfig config = CustomParserConfig.builder()
    .type("mypan")
    .displayName("我的网盘")
    .toolClass(MyPanTool.class)
    .build();
CustomParserRegistry.register(config);

// 3. 使用自定义解析器(仅支持 fromType 方式)
IPanTool tool = ParserCreate.fromType("mypan")
    .shareKey("abc123")
    .createTool();
String url = tool.parseSync();

详细文档: 自定义解析器扩展指南

文档

  • parser/doc/README.md:解析约定、示例、IDEA .http 调试
  • parser/doc/JAVASCRIPT_PARSER_GUIDE.md:JavaScript解析器开发完整指南 - 使用JavaScript编写自定义解析器
  • parser/doc/CUSTOM_PARSER_GUIDE.md:自定义解析器扩展完整指南 - Java自定义解析器扩展
  • parser/doc/CUSTOM_PARSER_QUICKSTART.md:自定义解析器快速开始 - 快速上手指南

目录

  • src/main/java/cn/qaiu/entity:通用实体(如 FileInfo)
  • src/main/java/cn/qaiu/parser:解析框架 & 各站点实现(impl)
  • src/test/java:单测与示例

许可证

MIT License