From 7ae19c2f8deb92f4298aa6804dc5968da669caaa Mon Sep 17 00:00:00 2001 From: npeter83 Date: Fri, 3 Jul 2026 03:19:00 +0200 Subject: [PATCH] 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. --- backend/app/sync/videos.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/app/sync/videos.py b/backend/app/sync/videos.py index d9c9f8b..89d6865 100644 --- a/backend/app/sync/videos.py +++ b/backend/app/sync/videos.py @@ -54,6 +54,11 @@ def _insert_stubs(db: Session, rows: list[dict]) -> int: return 0 seen: dict[str, dict] = {} 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 stmt = ( pg_insert(Video)