From 72ba00bdcd2eeabf31f74f536f7db3345ac46276 Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Wed, 8 Jul 2026 10:55:06 +0000 Subject: [PATCH] fix(youtube): retry without cookies on any yt-dlp failure, not just cookie-worded errors YouTube's SABR-only streaming rollout produces errors like "Signature solving failed" / "Requested format is not available" that don't mention cookies, so the existing no-cookies fallback never triggered. Cookies also disable the android client, which is often the only one still returning usable formats under this restriction. Co-Authored-By: Claude Sonnet 5 --- youtube-downloader/app.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/youtube-downloader/app.py b/youtube-downloader/app.py index 3d74c8c..f0f08e4 100644 --- a/youtube-downloader/app.py +++ b/youtube-downloader/app.py @@ -405,9 +405,11 @@ def download_youtube_video(url: str, max_retries: int = 3, format_id: str | None stderr = result.stderr.strip()[-800:] logger.error(f"[DOWNLOAD] Попытка {attempt + 1}: yt-dlp failed: {stderr[:300]}") - # Try without cookies on cookies-related errors - if ('cookies' in stderr.lower() or 'bot' in stderr.lower() or 'sign in' in stderr.lower()) \ - and '--cookies' in ' '.join(cmd): + # Пробуем без cookies при любой ошибке, а не только по ключевым словам: + # cookies отключают клиент "android" (см. "does not support cookies"), + # который часто остаётся единственным, кто отдаёт форматы при SABR-only + # ограничениях YouTube — так что без cookies шанс скачать выше почти всегда. + if '--cookies' in ' '.join(cmd): logger.warning("[DOWNLOAD] Пробуем без cookies") cmd_no_cookies = [a for i, a in enumerate(cmd) if a != '--cookies' and cmd[i-1] != '--cookies'] try: