From 5588a2289b048a7a9b7c4551f7c3e185c6a9d1a6 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Fri, 8 May 2026 02:32:48 +0200 Subject: [PATCH] Feature: Add JS challenge fallback support for fetching YouTube metadata --- youtube_summarizer.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/youtube_summarizer.py b/youtube_summarizer.py index cfb4dd3..a45dd65 100644 --- a/youtube_summarizer.py +++ b/youtube_summarizer.py @@ -757,12 +757,18 @@ def fetch_video_metadata( url: str, cookies_from_browser: Optional[str] = None, cookies_file: Optional[str] = None, + use_js_challenge_fallback: bool = False, ) -> Tuple[str, str, str]: """ Fetch the title, thumbnail URL and video ID for a YouTube URL using yt_dlp. Returns a tuple: (video_id, title, thumbnail_url) """ - opts = apply_ytdlp_cookie_options({'quiet': True}, cookies_from_browser, cookies_file) + opts = apply_ytdlp_cookie_options( + {'quiet': True}, + cookies_from_browser, + cookies_file, + use_js_challenge_fallback, + ) with yt_dlp.YoutubeDL(opts) as ydl: info = ydl.extract_info(url, download=False) vid = info.get('id') @@ -775,13 +781,19 @@ def fetch_channel_name( url: str, cookies_from_browser: Optional[str] = None, cookies_file: Optional[str] = None, + use_js_challenge_fallback: bool = False, ) -> Optional[str]: """ Retrieve the channel or uploader name for a YouTube video using yt_dlp. Returns None if it cannot be determined. """ try: - opts = apply_ytdlp_cookie_options({'quiet': True}, cookies_from_browser, cookies_file) + opts = apply_ytdlp_cookie_options( + {'quiet': True}, + cookies_from_browser, + cookies_file, + use_js_challenge_fallback, + ) with yt_dlp.YoutubeDL(opts) as ydl: info = ydl.extract_info(url, download=False) # Try channel, uploader, then return None