feat(identity): source-aware short-drama enrichment with snippet mode and hit rate (META-2)
- classify enrich sources: encyclopedia, platform pages (hongguo, kuaikaw, video platforms), douban (search snippet only) and other sites' search snippets (snippet mode, pages never opened); one extractor per source, fields carry source kind and confidence, merged by noisy-OR across hosts - new cast field (applied as MediaCredit with placeholder ids) - robots.txt check (cached per host 1 day) and login-wall/captcha give-up - per-enrichment source attempts + GET /identity/enrich-stats, 30-day hit-rate table under settings -> metadata -> identity - setting identity.enrichSnippetAllSites (default on); default domains add baike.com and kuaikaw.cn - replay fixtures from the real run on the 4 user-library short dramas (sanitized Brave responses, hongguo page, robots.txt) Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
081db4651c
commit
9489e40e0c
23 files changed
+2615
-323
No files matched your search
@@ -1,6 +1,9 @@
|
||||
import { DEFAULT_SETTINGS } from "@umt/contracts";
|
||||
import { toast } from "sonner";
|
||||
import { useClearImageCache, useClearTmdbCache, useImageCache, useTmdbCache } from "~/api/cache.ts";
|
||||
import { useEnrichStats } from "~/api/identity.ts";
|
||||
import { DataTable } from "~/components/console/data-table.tsx";
|
||||
import { ENRICH_SOURCE_KIND } from "~/components/library/labels.ts";
|
||||
import { Button } from "~/components/ui/button.tsx";
|
||||
import { errorMessage } from "~/lib/api.ts";
|
||||
import { secretPatch } from "~/lib/secret.ts";
|
||||
@@ -212,7 +215,14 @@ const IDENTITY_CARD: CardSpec = {
|
||||
name: "identity.enrichDomains",
|
||||
label: "补全可读取的网站",
|
||||
kind: "textarea",
|
||||
hint: "每行一个域名,含子域名;只放平台和百科类网站。已登记站点的域名一律不读",
|
||||
hint: "每行一个域名,含子域名;只放平台和百科类网站。豆瓣只用搜索摘要,不读页面;robots.txt 不允许的页面不读。已登记站点的域名一律不读",
|
||||
wide: true,
|
||||
},
|
||||
{
|
||||
name: "identity.enrichSnippetAllSites",
|
||||
label: "也用其它网站的搜索摘要",
|
||||
kind: "switch",
|
||||
hint: "短剧多半只有聚合站收录。打开后,白名单以外网站的搜索摘要也用来抽年份、集数、主演、简介(只看搜索引擎给的摘要,不打开这些网页)",
|
||||
wide: true,
|
||||
},
|
||||
],
|
||||
@@ -221,6 +231,7 @@ const IDENTITY_CARD: CardSpec = {
|
||||
"identity.autoEnrich": s.identity.autoEnrich,
|
||||
"identity.enrichDailyBudget": n(s.identity.enrichDailyBudget),
|
||||
"identity.enrichDomains": s.identity.enrichDomains.join("\n"),
|
||||
"identity.enrichSnippetAllSites": s.identity.enrichSnippetAllSites ?? true,
|
||||
}),
|
||||
toPatch: (v) => ({
|
||||
identity: {
|
||||
@@ -231,10 +242,59 @@ const IDENTITY_CARD: CardSpec = {
|
||||
.split(/[\s,,]+/)
|
||||
.map((d) => d.trim().toLowerCase())
|
||||
.filter(Boolean),
|
||||
enrichSnippetAllSites: v["identity.enrichSnippetAllSites"] === true,
|
||||
},
|
||||
}),
|
||||
extra: () => <EnrichStatsTable />,
|
||||
};
|
||||
|
||||
type StatRow = { kind: string; withResults: number; hits: number; rate: number | null };
|
||||
|
||||
/** 最近 30 天补全命中率(按来源类别,META-2) */
|
||||
function EnrichStatsTable() {
|
||||
const q = useEnrichStats(30);
|
||||
const d = q.data;
|
||||
return (
|
||||
<div className="mb-3 space-y-2">
|
||||
<p className="text-meta text-muted-foreground tabular-nums">
|
||||
{d
|
||||
? `最近 ${d.days} 天元数据补全 ${d.total} 次,出了建议 ${d.suggested} 次${d.tracked < d.total ? `;有来源明细的 ${d.tracked} 次` : ""}`
|
||||
: "读取补全命中率…"}
|
||||
</p>
|
||||
{d && d.tracked > 0 ? (
|
||||
<DataTable<StatRow>
|
||||
rows={d.sources}
|
||||
rowKey={(r) => r.kind}
|
||||
empty={{ title: "还没有补全记录" }}
|
||||
columns={[
|
||||
{ key: "kind", header: "来源", cell: (r) => ENRICH_SOURCE_KIND[r.kind] ?? r.kind },
|
||||
{
|
||||
key: "withResults",
|
||||
header: "有结果",
|
||||
align: "right",
|
||||
cell: (r) => <span className="tabular-nums">{r.withResults}</span>,
|
||||
},
|
||||
{
|
||||
key: "hits",
|
||||
header: "命中",
|
||||
align: "right",
|
||||
cell: (r) => <span className="tabular-nums">{r.hits}</span>,
|
||||
},
|
||||
{
|
||||
key: "rate",
|
||||
header: "命中率",
|
||||
align: "right",
|
||||
cell: (r) => (
|
||||
<span className="tabular-nums">{r.rate === null ? "—" : `${Math.round(r.rate * 100)}%`}</span>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function MetadataSection() {
|
||||
return (
|
||||
<SettingsGate>
|
||||
|
||||
Reference in new issue
Block a user