Files
UHD_Media_Tool/packages/testkit/src/sites
rootandClaude Opus 5.5 9be9813021 feat(sites): structure release detail pages and rework the detail drawer (DETAIL-1)
Adapters (pure functions + tests):
- detail-description: strip HTML/BBCode residue, drop site template blocks and
  ad/signature lines (configurable rules), parse PT info blocks (◎ / 【】 / 『』 /
  「键:」) into infoBlock and body paragraphs
- mediainfo: MediaInfo and BDInfo (quick summary + full report) into a summary
  of container/duration/bitrate/size, video (HDR/DV), audio and subtitle tracks
- file-tree: file list into a flattened directory tree with sizes and
  main/sample/subtitle/extra roles
- formatDetailPage combines them; the server computes it when reading the
  cached detail page, so existing caches benefit without a refetch

Contracts: SiteReleasePage gains infoBlock, paragraphs, media, fileTree.

Web: drawer now reads top-down: meta row (promo/H&R, size, peers, upload time,
IMDb/TMDB/豆瓣 tags) → 资料 → 简介 (collapsible) → 技术规格 (raw folded) →
截图 grid with keyboard lightbox → 文件 tree; inventory overlay moved into the
fixed footer next to 下载.

Fixtures: 6 desensitized samples from the local cache (site.detail and RSS
descriptions) plus synthetic multi-track MediaInfo, BDInfo, bracket blocks and
directory file lists.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-29 20:50:42 +08:00
..

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.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。