diff --git a/app.py b/app.py index 4938733..96f3e3d 100644 --- a/app.py +++ b/app.py @@ -91,19 +91,32 @@ def _base_opts(extra=None): opts = { "cachedir": CACHE_DIR, "js_runtimes": {"node": {"executable": "/usr/bin/node"}}, + + # MUST be a list. Allows yt-dlp to download the JS solver via Node. + "remote_components": ["ejs:github"], + + # Bypass the broken 'tv_downgraded' client when using cookies. + # Forces fallback to default or web_embedded clients. + "extractor_args": { + "youtube": ["player_client=default,web_embedded"] + }, + "http_headers": {"User-Agent": _random_ua()}, "http_chunk_size": 10 * 1024 * 1024, "socket_timeout": 30, "retries": 6, "fragment_retries": 6, + "source_address": "0.0.0.0", } + if os.path.isfile(COOKIES_FILE): opts["cookiefile"] = COOKIES_FILE + if extra: opts.update(extra) + return opts - def sanitize_filename(name): return re.sub(r'[\\/*?:"<>|]', "_", name)