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 <noreply@anthropic.com>
This commit is contained in:
@@ -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.video_count = len(video_yt_ids)
|
||||||
playlist.indexed_at = datetime.utcnow()
|
playlist.indexed_at = datetime.utcnow()
|
||||||
playlist.video_ids = json.dumps(video_yt_ids)
|
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:
|
if not playlist.thumbnail_url and video_yt_ids:
|
||||||
from ..services.ytdlp import _stable_thumbnail
|
from ..services.ytdlp import _stable_thumbnail
|
||||||
playlist.thumbnail_url = _stable_thumbnail(video_yt_ids[0])
|
playlist.thumbnail_url = _stable_thumbnail(video_yt_ids[0])
|
||||||
db.commit()
|
db.commit()
|
||||||
except Exception:
|
except Exception:
|
||||||
db.rollback()
|
db.rollback()
|
||||||
|
return
|
||||||
finally:
|
finally:
|
||||||
db.close()
|
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()
|
||||||
|
|||||||
Reference in New Issue
Block a user