test(identity): MoviePilot differential on 113 HHClub titles (ID-2)
MP MetaInfo + TheMovieDbModule name matching vs parse/recall/resolveIdentity, TMDB responses replayed offline; includes the category-alias misbinding regression from the user stack. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
387f7931e0
commit
03de030371
11 files changed
+12280
No files matched your search
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* 重新录制身份匹配差分(ID-2):我们侧的 TMDB 请求走本地缓存代理(scratchpad tmdb_proxy.py,上行计数封顶),
|
||||
* 录下的响应裁剪后写入 tmdb-fixtures.json,逐条结果写入 ours.json 并打印汇总。
|
||||
*
|
||||
* TMDB_PROXY=http://127.0.0.1:18731 deno run -A apps/server/test/sources-identity/identity-differential.run.ts
|
||||
*/
|
||||
import { writeFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import {
|
||||
DATA_DIR,
|
||||
fixtureKey,
|
||||
runDifferential,
|
||||
runPoisoned,
|
||||
summarize,
|
||||
tmdbFor,
|
||||
trimTmdb,
|
||||
} from "./identity-differential.lib.ts";
|
||||
|
||||
const proxy = Deno.env.get("TMDB_PROXY") ?? "http://127.0.0.1:18731";
|
||||
const fixtures: Record<string, unknown> = {};
|
||||
const recording: typeof fetch = async (input, init) => {
|
||||
const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
||||
const res = await fetch(url, init);
|
||||
const body = await res.clone().json();
|
||||
// 录制时代理离线未命中的详情按 404 记下(回放同样走"取不到详情"分支)
|
||||
fixtures[fixtureKey(url)] = res.ok ? trimTmdb(body) : { __status: res.status };
|
||||
return res;
|
||||
};
|
||||
const tmdb = tmdbFor(recording, `${proxy}/3`);
|
||||
const rows = await runDifferential(tmdb);
|
||||
const poisoned = await runPoisoned(tmdb);
|
||||
for (const p of poisoned) if (!p.ok) console.log("POISONED FAIL", p.c.title.slice(0, 60), p.status, p.best);
|
||||
console.log("poisoned", poisoned.filter((p) => p.ok).length, "/", poisoned.length);
|
||||
const sorted = Object.fromEntries(Object.entries(fixtures).sort(([a], [b]) => a.localeCompare(b)));
|
||||
writeFileSync(join(DATA_DIR, "tmdb-fixtures.json"), `${JSON.stringify(sorted)}\n`);
|
||||
writeFileSync(join(DATA_DIR, "ours.json"), `${JSON.stringify({ summary: summarize(rows), rows }, null, 1)}\n`);
|
||||
for (const r of rows)
|
||||
if (r.verdict !== "consistent")
|
||||
console.log(
|
||||
r.id,
|
||||
r.verdict,
|
||||
r.deviation?.kind ?? "",
|
||||
"| mp",
|
||||
r.mp,
|
||||
"| ours",
|
||||
r.status,
|
||||
r.best,
|
||||
r.bestEvidence.join(","),
|
||||
"|",
|
||||
r.title.slice(0, 50),
|
||||
);
|
||||
console.log(summarize(rows));
|
||||
Reference in new issue
Block a user