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
@@ -32,6 +32,8 @@ export interface FetchedPage {
|
||||
text: string;
|
||||
truncated: boolean;
|
||||
bytes: number;
|
||||
/** HTML 的 og:image / twitter:image(绝对 http(s) 地址,已脱敏);没有为 null */
|
||||
image: string | null;
|
||||
}
|
||||
|
||||
export const PAGE_MAX_BYTES = 512 * 1024;
|
||||
@@ -155,5 +157,26 @@ export async function fetchPage(raw: string, opts: FetchPageOptions = {}): Promi
|
||||
text: clean.text,
|
||||
truncated: body.truncated || clean.truncated,
|
||||
bytes: body.bytes.byteLength,
|
||||
image: isHtml ? ogImage(decoded, url) : null,
|
||||
};
|
||||
}
|
||||
|
||||
/** <meta property="og:image" content="…">(属性顺序不限),退而取 twitter:image;相对地址按页面地址补全 */
|
||||
export function ogImage(html: string, base: URL): string | null {
|
||||
const head = html.slice(0, 200_000);
|
||||
for (const key of ["og:image", "og:image:url", "twitter:image"]) {
|
||||
for (const m of head.matchAll(/<meta\b[^>]*>/gi)) {
|
||||
const tag = m[0];
|
||||
const name = tag.match(/\b(?:property|name)\s*=\s*["']([^"']+)["']/i)?.[1]?.toLowerCase();
|
||||
if (name !== key) continue;
|
||||
const content = tag.match(/\bcontent\s*=\s*["']([^"']+)["']/i)?.[1]?.trim();
|
||||
if (!content) continue;
|
||||
try {
|
||||
const u = new URL(content.replace(/&/g, "&"), base);
|
||||
if (u.protocol !== "http:" && u.protocol !== "https:") continue;
|
||||
return redactUrl(u.href).slice(0, 2048);
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Reference in new issue
Block a user