Complete rate-limiter coverage for all background yt-dlp calls
- fetch_playlist_videos now uses _meta_run (background playlist indexing) - fetch_channel_links now uses _meta_run (dead code, future-proofed) - _upsert_video_from_yt accepts polite= flag; background enrichment passes polite=True - Only intentional user-facing one-shot calls (download_subs_only, fetch_video_comments, polite=False metadata) bypass the lock Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -513,9 +513,9 @@ def _row_to_detail(row) -> VideoDetail:
|
||||
)
|
||||
|
||||
|
||||
def _upsert_video_from_yt(db: Session, youtube_video_id: str) -> bool:
|
||||
def _upsert_video_from_yt(db: Session, youtube_video_id: str, polite: bool = False) -> bool:
|
||||
"""Fetch fresh metadata from yt-dlp and upsert video + channel. Returns True if successful."""
|
||||
meta = ytdlp.fetch_video_metadata(youtube_video_id)
|
||||
meta = ytdlp.fetch_video_metadata(youtube_video_id, polite=polite)
|
||||
if not meta:
|
||||
return False
|
||||
|
||||
@@ -868,7 +868,7 @@ def get_video_by_yt_id(
|
||||
def _enrich(yt_id: str):
|
||||
bg_db = SessionLocal()
|
||||
try:
|
||||
_upsert_video_from_yt(bg_db, yt_id)
|
||||
_upsert_video_from_yt(bg_db, yt_id, polite=True)
|
||||
finally:
|
||||
bg_db.close()
|
||||
background_tasks.add_task(_enrich, youtube_video_id)
|
||||
|
||||
Reference in New Issue
Block a user