Snapshot differential tests (known deviations registered, current state passes): - title/path recognition: 216 samples vs MP MetaInfo/MetaInfoPath - filter rules: 42 rules x 28 torrents vs MP FilterModule - RSS/indexer parsing: 15 feeds, 72 indexer samples - zhconv: 69 samples Generator: scripts/mp-sync/gen-differential.py; report: docs/porting/mp-rust-logic-parity.md Co-Authored-By: Claude Opus 5.5 <[email protected]>
74 lines
2.8 KiB
TypeScript
74 lines
2.8 KiB
TypeScript
/**
|
|
* 把 @umt/testkit 的 mock RSS / NexusPHP fixture 导出成文件,供 MP 差分生成脚本(scripts/mp-sync/gen-differential.py rss|indexer)读取。
|
|
* 运行:deno run -A packages/adapters/test/differential/export-inputs.ts
|
|
* 只写 `inputs/rss/tk-*.xml` 与 `inputs/indexer/tk-*.html.txt`;手写样本(hw-*)不受影响。
|
|
*/
|
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import {
|
|
AUDIENCES_FIXTURE_RELEASES,
|
|
CHDBITS_LIST_PAGE,
|
|
CHDBITS_LOGIN_PAGE,
|
|
createMockNexusPhpSite,
|
|
HHANCLUB_LIST_PAGE,
|
|
type MockFeedItem,
|
|
renderAtom,
|
|
renderRss,
|
|
} from "@umt/testkit";
|
|
|
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
const rssDir = join(here, "inputs", "rss");
|
|
const idxDir = join(here, "inputs", "indexer");
|
|
mkdirSync(rssDir, { recursive: true });
|
|
mkdirSync(idxDir, { recursive: true });
|
|
|
|
const items: MockFeedItem[] = [
|
|
{
|
|
guid: "audiences-812345",
|
|
title: "Dune.Part.Two.2024.2160p.UHD.BluRay.REMUX.DV.HDR.HEVC.TrueHD.Atmos.7.1-FraMeSToR",
|
|
link: "https://audiences.me/details.php?id=812345",
|
|
enclosureUrl: "https://audiences.me/download.php?id=812345&passkey=0123456789abcdef",
|
|
size: 84203386470,
|
|
pubDate: new Date(Date.UTC(2026, 8, 26, 13, 14, 3)),
|
|
categories: ["电影", "401"],
|
|
description: "沙丘2 / 沙丘:第二部 | <b>杜比视界</b> 国英双语 中字",
|
|
},
|
|
{
|
|
guid: "audiences-812346",
|
|
title: "Keep.Running.S12E01.20240426.2160p.WEB-DL.H265.AAC-LelveTV & Friends",
|
|
link: "https://audiences.me/details.php?id=812346",
|
|
enclosureUrl: "https://audiences.me/download.php?id=812346",
|
|
size: 5497558138,
|
|
pubDate: new Date(Date.UTC(2026, 8, 26, 12, 0, 0)),
|
|
},
|
|
{
|
|
guid: "audiences-812347",
|
|
title: "The.Bear.S03.2160p.DSNP.WEB-DL.DDP5.1.Atmos.DV.H.265-FLUX",
|
|
link: "https://audiences.me/details.php?id=812347",
|
|
},
|
|
];
|
|
writeFileSync(join(rssDir, "tk-rss-basic.xml"), renderRss("观众 Torrents", items));
|
|
writeFileSync(join(rssDir, "tk-atom-basic.xml"), renderAtom("观众 Atom", items));
|
|
|
|
const site = await createMockNexusPhpSite({
|
|
releases: AUDIENCES_FIXTURE_RELEASES,
|
|
});
|
|
try {
|
|
const res = await fetch(`${site.baseUrl}/torrents.php?page=0`, {
|
|
headers: { cookie: site.cookie },
|
|
});
|
|
writeFileSync(join(idxDir, "tk-audiences-list.html.txt"), await res.text());
|
|
site.setLoggedIn(false);
|
|
const login = await fetch(`${site.baseUrl}/torrents.php`, {
|
|
headers: { cookie: site.cookie },
|
|
});
|
|
writeFileSync(join(idxDir, "tk-audiences-login.html.txt"), await login.text());
|
|
} finally {
|
|
await site.close();
|
|
}
|
|
writeFileSync(join(idxDir, "tk-hhanclub-list.html.txt"), HHANCLUB_LIST_PAGE);
|
|
writeFileSync(join(idxDir, "tk-chdbits-list.html.txt"), CHDBITS_LIST_PAGE);
|
|
writeFileSync(join(idxDir, "tk-chdbits-login.html.txt"), CHDBITS_LOGIN_PAGE);
|
|
console.log("exported to", here);
|