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()