From c3b83ba1d315309032ecf71ed4fe0f505035471b Mon Sep 17 00:00:00 2001 From: Mattias Thall Date: Tue, 26 May 2026 22:50:56 +0200 Subject: [PATCH] Enrich playlist video dates after indexing flat-playlist mode returns timestamp=null for most playlist entries so published_at is missing after the initial index. Now kicks off _enrich_missing_task (scoped to the playlist size) as a daemon thread immediately after indexing commits, filling in dates and view counts in the background via individual video fetches. Co-Authored-By: Claude Sonnet 4.6 --- backend/routers/playlists.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/routers/playlists.py b/backend/routers/playlists.py index 026bb35..80dfd6e 100644 --- a/backend/routers/playlists.py +++ b/backend/routers/playlists.py @@ -204,12 +204,17 @@ def _index_playlist_task(playlist_id: int, youtube_playlist_id: str, channel_id: playlist.video_count = len(video_yt_ids) playlist.indexed_at = datetime.utcnow() playlist.video_ids = json.dumps(video_yt_ids) - # Backfill thumbnail from first video if playlist has none if not playlist.thumbnail_url and video_yt_ids: from ..services.ytdlp import _stable_thumbnail playlist.thumbnail_url = _stable_thumbnail(video_yt_ids[0]) db.commit() except Exception: db.rollback() + return finally: db.close() + + # Enrich dates and view counts for videos missing them — runs in background + import threading + from ..routers.channels import _enrich_missing_task + threading.Thread(target=_enrich_missing_task, args=(len(video_yt_ids),), daemon=True).start()