diff --git a/backend/routers/videos.py b/backend/routers/videos.py index bdc69fb..0bfeabe 100644 --- a/backend/routers/videos.py +++ b/backend/routers/videos.py @@ -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) diff --git a/backend/services/ytdlp.py b/backend/services/ytdlp.py index 67cf041..1bd5432 100644 --- a/backend/services/ytdlp.py +++ b/backend/services/ytdlp.py @@ -435,7 +435,7 @@ def fetch_playlist_videos(playlist_id: str, max_videos: int = 200) -> list[dict] ] if max_videos > 0: args += ["--playlist-end", str(max_videos)] - stdout, _, code = _run(args, timeout=120) + stdout, _, code = _meta_run(args, timeout=120) videos = [] for line in stdout.splitlines(): @@ -503,7 +503,7 @@ def fetch_channel_links(channel_id: str) -> list[str]: url = f"https://www.youtube.com/{channel_id}/about" else: url = f"https://www.youtube.com/channel/{channel_id}/about" - stdout, _, code = _run([ + stdout, _, code = _meta_run([ "yt-dlp", url, "--dump-json",