feat(identity): web metadata enrichment for titles missing on TMDB (META-1)
- metadata.enrich (propose, low, replay safe): normalized-title cache (kv_cache
region enrich, 7 days) -> daily budget -> web.search (title + 短剧 / 电视剧 平台,
second query limited to whitelist via site:) -> web.fetch of up to 3 relevant
whitelisted pages (registered site domains never read, redirects out of the
whitelist dropped) -> upstream model extraction with rule fallback -> server-side
evidence check (rule_confirmed / multi_evidence / needs_review). Suggestion only.
- POST /identity-pool/{id}/enrich (suggest) and /enrich/apply (console session):
provisional entity or same-title merge, season/episode units, field-level
metadata with source web/agent + evidence, aliases, release assignment.
Poster proxy GET /img/enrich/{id} (og:image from whitelisted pages only).
- Auto-enrich once per pool entry when subscription/rule lookups find nothing on
TMDB (identity.autoEnrich, off by default); identity.enrichDailyBudget,
identity.enrichDomains settings; web.fetch now returns og:image.
- Pool sheet "元数据补全" section; entity detail shows evidence links.
- Migration 0049_enrichment (metadata_enrichment, metadata_field.evidence, source
web). Requires image rebuild / api + worker restart to take effect.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
18a5cf1de7
commit
f4666a4671
36 files changed
+2514
-25
No files matched your search
@@ -13,6 +13,7 @@ import {
|
||||
CalendarClock,
|
||||
CalendarPlus,
|
||||
ChevronRight,
|
||||
ExternalLink,
|
||||
FolderTree,
|
||||
GitMerge,
|
||||
Lock,
|
||||
@@ -249,6 +250,44 @@ function IdentityRow({ i }: { i: ExternalIdentity }) {
|
||||
}
|
||||
|
||||
// ── 元数据字段来源与锁 ──
|
||||
|
||||
const ENRICH_ONLY_FIELDS = new Set<string>(["platform", "episodeCount", "genres", "posterUrl"]);
|
||||
|
||||
/** META-1 补全写入的字段:证据等级 + 出处网页(来源 web = 网页原文,agent = Agent 归纳,都不是 TMDB) */
|
||||
function EvidenceLine({ field }: { field: MediaEntityDetail["metadataFields"][number] | undefined }) {
|
||||
const ev = field?.evidence;
|
||||
if (!ev) return null;
|
||||
let host: string | null = null;
|
||||
try {
|
||||
host = ev.sourceUrl ? new URL(ev.sourceUrl).hostname.replace(/^www\./, "") : null;
|
||||
} catch {}
|
||||
return (
|
||||
<p className="flex flex-wrap items-center gap-x-1.5 text-meta text-muted-foreground">
|
||||
<span>证据 {evidenceLabel(ev.evidenceLevel)}</span>
|
||||
{ev.sourceUrl && host ? (
|
||||
<a
|
||||
href={ev.sourceUrl}
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
className="inline-flex items-center gap-1 break-all underline-offset-4 hover:text-foreground hover:underline"
|
||||
>
|
||||
{host}
|
||||
<ExternalLink className="h-3 w-3 shrink-0" />
|
||||
</a>
|
||||
) : (
|
||||
<span>无出处</span>
|
||||
)}
|
||||
{field?.field === "posterUrl" && ev.enrichmentId ? (
|
||||
<img
|
||||
src={`/api/v1/img/enrich/${ev.enrichmentId}`}
|
||||
alt="海报"
|
||||
loading="lazy"
|
||||
className="mt-1 h-24 w-auto rounded-tight border border-border object-cover"
|
||||
/>
|
||||
) : null}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
function MetadataPanel({ detail, entity }: { detail: LibraryDetail; entity: MediaEntityDetail | undefined }) {
|
||||
const id = detail.entity.id;
|
||||
const refresh = useRefreshMetadata(id);
|
||||
@@ -256,10 +295,13 @@ function MetadataPanel({ detail, entity }: { detail: LibraryDetail; entity: Medi
|
||||
const [editing, setEditing] = useState<EntityMetadataField | null>(null);
|
||||
const locks = new Set(detail.metadataSources.fieldLocks);
|
||||
const fields = detail.metadataSources.fields;
|
||||
const finals = FieldEnum.options.map((f) => {
|
||||
const parsed = FinalFieldValue.safeParse(fields[f]);
|
||||
return { field: f, final: parsed.success ? parsed.data : null, locked: locks.has(f) };
|
||||
});
|
||||
const finals = FieldEnum.options
|
||||
.map((f) => {
|
||||
const parsed = FinalFieldValue.safeParse(fields[f]);
|
||||
return { field: f, final: parsed.success ? parsed.data : null, locked: locks.has(f) };
|
||||
})
|
||||
// 补全专有字段(平台 / 集数 / 类型 / 网页海报)只在有值时显示
|
||||
.filter((x) => x.final || !ENRICH_ONLY_FIELDS.has(x.field));
|
||||
const candidatesOf = (f: string) => (entity?.metadataFields ?? []).filter((m) => m.field === f);
|
||||
const current = editing ? finals.find((x) => x.field === editing)?.final?.value : undefined;
|
||||
|
||||
@@ -292,7 +334,15 @@ function MetadataPanel({ detail, entity }: { detail: LibraryDetail; entity: Medi
|
||||
<div className="w-24 shrink-0 pt-0.5 text-meta text-muted-foreground">{ENTITY_FIELD_LABEL[field]}</div>
|
||||
<div className="min-w-0 flex-1 basis-48">
|
||||
<p className="text-sm break-words text-foreground">
|
||||
{final ? String(final.value ?? "—") : <span className="text-muted-foreground">未提供</span>}
|
||||
{final ? (
|
||||
Array.isArray(final.value) ? (
|
||||
final.value.join("、")
|
||||
) : (
|
||||
String(final.value ?? "—")
|
||||
)
|
||||
) : (
|
||||
<span className="text-muted-foreground">未提供</span>
|
||||
)}
|
||||
</p>
|
||||
{final ? (
|
||||
<p className="text-meta text-muted-foreground">
|
||||
@@ -300,6 +350,7 @@ function MetadataPanel({ detail, entity }: { detail: LibraryDetail; entity: Medi
|
||||
{final.language ? ` · ${final.language}` : ""} · {relTime(final.at)}
|
||||
</p>
|
||||
) : null}
|
||||
{final ? <EvidenceLine field={cands.find((c) => c.source === final.source)} /> : null}
|
||||
{cands.length ? (
|
||||
<p className="mt-0.5 text-meta break-words text-muted-foreground">
|
||||
候选:
|
||||
|
||||
Reference in new issue
Block a user