fix(titles): normalize titles at stub insert too (RSS/backfill/live-search)

_insert_stubs previously stored the raw title, so a brand-new video showed its unnormalized
title until enrichment caught up. Normalize (and stash original_title) at insert as well, so
every video-title write path is covered: stub insert, enrichment, live search, and the download
worker. Every newly imported feed video is normalized from the first insert.
This commit is contained in:
npeter83 2026-07-03 03:19:00 +02:00
parent d55799cbc1
commit 7ae19c2f8d

View file

@ -54,6 +54,11 @@ def _insert_stubs(db: Session, rows: list[dict]) -> int:
return 0 return 0
seen: dict[str, dict] = {} seen: dict[str, dict] = {}
for row in rows: for row in rows:
# Normalize the title at first insert too (RSS/backfill stubs), so a brand-new video
# never flashes its raw title before enrichment refreshes it.
raw = row.get("title")
if raw:
row = {**row, "original_title": raw, "title": normalize_title(raw)}
seen[row["id"]] = row seen[row["id"]] = row
stmt = ( stmt = (
pg_insert(Video) pg_insert(Video)