Files
UHD_Media_Tool/packages/testkit/src/sites
rootandClaude Opus 5.5 6e9e8efec2 fix(sites): HHClub parsing, resource list layout and request restraint (re-landed)
Re-lands 901b01d, which was reverted wholesale by 28974d1 (BR-2 committed
from the shared index). The agent UI files 901b01d had rolled back are
left at their AGUI-2 versions; contracts, routes, db types and the runbook
part already reached main through later commits, so this carries the rest.

HHClub (憨憨) was checked read-only against a real account (one detail
request; list, user data and health came from the product's own fetch).

Parsing fixes:
- list titles carried the site's new-torrent marker "[新]" (58 of 100
  rows; the detail page title has none); stripped with a replace filter
- refreshing a detail overwrote seeders / leechers / snatched / category
  name / H&R with null because the HHClub div detail page lacks them;
  detail values now fall back to the list snapshot (mergeDetailOverList),
  and an unknown detail promotion keeps the list promotion
- level "贵宾" is VIP (umt.vipLevels)
- sanitized minimal fixture HHANCLUB_LIST_PAGE_2026 + tests; README marks
  HHClub as verified 2026-09-29
Size, counts, category ids/names, +08:00 time and subtitle were correct.

Request restraint:
- site definitions may carry umt.defaults; merged with settings.sites
  (longer intervals, fewer pages): new settings defaultSnapshotMaxPages 1,
  defaultHealthCheckIntervalSec 6 h, defaultDetailCacheSec 24 h; default
  burst 2. HHClub: snapshot 60 min page 1 only, health 6 h, search
  concurrency 1, detail cache 24 h, 1 token / 3 s burst 2
- periodic / manual snapshots are capped to that page count; scheduled
  health checks skip sites checked within the interval; detail refresh is
  served from cache inside the window; live searches on one site queue
- every rate-limiter token is counted per site per hour
  (site_request_count, migration 0046); GET /sites/{id}/request-stats;
  site overview and resource list show requests in the last 24 hours

Resource list: two-layer rows. Main line: title + spec tags (episodes,
resolution, source, codec, HDR, group, 国语/中字, site tags) + promotion
with time left + H&R. Second line: subtitle (one line, ellipsis) and
fixed-width category / size / seed-leech-snatched / upload time
(relative, absolute on hover) columns, stale badge, inventory overlay;
folds into a card on phones.

Also aligns identity_candidate.normalized_title order in db types with
the migrations (schema drift test).

Takes effect after the stack is rebuilt (migration 0046).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-29 16:00:34 +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。