fix(youtube): retry without cookies on any yt-dlp failure, not just cookie-worded errors
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 50s
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 50s
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 <noreply@anthropic.com>
This commit is contained in:
parent
d5201df802
commit
72ba00bdcd
1 changed files with 5 additions and 3 deletions
|
|
@ -405,9 +405,11 @@ def download_youtube_video(url: str, max_retries: int = 3, format_id: str | None
|
||||||
stderr = result.stderr.strip()[-800:]
|
stderr = result.stderr.strip()[-800:]
|
||||||
logger.error(f"[DOWNLOAD] Попытка {attempt + 1}: yt-dlp failed: {stderr[:300]}")
|
logger.error(f"[DOWNLOAD] Попытка {attempt + 1}: yt-dlp failed: {stderr[:300]}")
|
||||||
|
|
||||||
# Try without cookies on cookies-related errors
|
# Пробуем без cookies при любой ошибке, а не только по ключевым словам:
|
||||||
if ('cookies' in stderr.lower() or 'bot' in stderr.lower() or 'sign in' in stderr.lower()) \
|
# cookies отключают клиент "android" (см. "does not support cookies"),
|
||||||
and '--cookies' in ' '.join(cmd):
|
# который часто остаётся единственным, кто отдаёт форматы при SABR-only
|
||||||
|
# ограничениях YouTube — так что без cookies шанс скачать выше почти всегда.
|
||||||
|
if '--cookies' in ' '.join(cmd):
|
||||||
logger.warning("[DOWNLOAD] Пробуем без cookies")
|
logger.warning("[DOWNLOAD] Пробуем без cookies")
|
||||||
cmd_no_cookies = [a for i, a in enumerate(cmd) if a != '--cookies' and cmd[i-1] != '--cookies']
|
cmd_no_cookies = [a for i, a in enumerate(cmd) if a != '--cookies' and cmd[i-1] != '--cookies']
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue