testkit/sites
mock PT 站点(配合 adapters/sites 的 MoviePilot 迁移实现)。HTML/JSON fixture 为自行编写,不代表已核对真实站点,只用于验证适配器的选择器配置与错误分类。
mock NexusPHP(观众风格)
const site = await createMockNexusPhpSite({ pageSize: 50, pageBase: 0, loginMode: "page" | "redirect" });
site.baseUrl; site.cookie; // 请求 Cookie 需包含 site.cookie
site.setLoggedIn(false); // 全站返回登录页(或 302 login.php)
site.failNext(1, 429, "7"); // 限流 / 5xx
site.setBrokenLayout(true); // 改版模拟
site.setHeaderLayout("no_logout"); // 页头布局:classic / no_logout(观众 2026 版无 logout 链接)/ bare(无登录标志)
site.infoHashOf("812345"); // 下载 .torrent 的 infohash
路由:index.php、torrents.php(search / catN / spstate=2 / page)、details.php?id=(不存在返回"没有该ID的种子")、download.php?id=(合法 .torrent,或 magnet 字段时 302 磁力)、login.php。
默认 fixture AUDIENCES_FIXTURE_RELEASES:免费+截止(812345)、综艺 403 + H&R(812346)、50%+2x(812347)、截断标题 + TB(812348)、纪录片 2x + KB(812349)。
mock M-Team API
const api = await createMockMteamApi({ apiKey, torrents, failMode });
api.setFailMode("banned_key" | "rate_limit" | "http_429" | "non_json" | "no_dl_token" | null);
api.lastSearchBody; api.issuedTokens; api.infoHashOf("912233");
路由:POST /api/torrent/search、/api/torrent/detail、/api/torrent/genDlToken(id 可走 query 或表单,签发一次性 /api/rss/dlv2?sign=&t=&tid=)、/api/member/profile;x-api-key 错误返回 {code:"1", message:"key無效"}。
默认 fixture MTEAM_FIXTURE_TORRENTS:50% 限时(912233)、商城单种免费(912234)、全站促销(912235,动画 405)、2x 免费(912236,纪录 404)、体育 407(912237)。
buildFakeTorrent({name, length}) 生成结构合法的 .torrent 与其 infohash。