fix: don't pass the 'custom' cookies sentinel to yt-dlp (unsupported browser error)
The #902 'paste cookies.txt' feature added a 'custom' sentinel value for youtube.cookies_browser, but that feature wasn't merged to this branch — and ~7 call sites (core/youtube_client.py x5, core/video/youtube.py, web_server.py) pass cookies_browser raw to yt-dlp's cookiesfrombrowser, which rejects 'custom' ('ERROR: unsupported browser: custom') and broke YouTube download/enrichment. Sanitize 'custom' -> '' (no browser) at every site: youtube_client reads via a walrus filter, the other two guard the condition. 'custom' now means 'no browser cookies' here (the cookiefile feature isn't on this branch). Latent on dev too — only _youtube_cookie_opts was fixed there.
This commit is contained in:
parent
78874313cc
commit
8236b95db0
3 changed files with 10 additions and 8 deletions
|
|
@ -168,9 +168,10 @@ def _cookie_opts():
|
|||
try:
|
||||
from config.settings import config_manager
|
||||
cb = config_manager.get("youtube.cookies_browser", "")
|
||||
if cb:
|
||||
# 'custom' = the paste-cookies.txt sentinel (not a yt-dlp browser); skip it here.
|
||||
if cb and cb != "custom":
|
||||
return {"cookiesfrombrowser": (cb,)}
|
||||
except Exception:
|
||||
except Exception: # noqa: S110 - cookie config is best-effort; extraction still works without it
|
||||
pass
|
||||
return {}
|
||||
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ class YouTubeClient(DownloadSourcePlugin):
|
|||
|
||||
# Cookie support — use browser cookies for YouTube auth
|
||||
from config.settings import config_manager
|
||||
cookies_browser = config_manager.get('youtube.cookies_browser', '')
|
||||
cookies_browser = ('' if (_cb := config_manager.get('youtube.cookies_browser', '')) == 'custom' else _cb)
|
||||
if cookies_browser:
|
||||
self.download_opts['cookiesfrombrowser'] = (cookies_browser,)
|
||||
|
||||
|
|
@ -309,7 +309,7 @@ class YouTubeClient(DownloadSourcePlugin):
|
|||
"""Reload YouTube settings from config (called when settings are saved)."""
|
||||
from config.settings import config_manager
|
||||
self._download_delay = config_manager.get('youtube.download_delay', 3)
|
||||
cookies_browser = config_manager.get('youtube.cookies_browser', '')
|
||||
cookies_browser = ('' if (_cb := config_manager.get('youtube.cookies_browser', '')) == 'custom' else _cb)
|
||||
if cookies_browser:
|
||||
self.download_opts['cookiesfrombrowser'] = (cookies_browser,)
|
||||
elif 'cookiesfrombrowser' in self.download_opts:
|
||||
|
|
@ -736,7 +736,7 @@ class YouTubeClient(DownloadSourcePlugin):
|
|||
'default_search': 'ytsearch',
|
||||
'user_agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
|
||||
}
|
||||
cookies_browser = config_manager.get('youtube.cookies_browser', '')
|
||||
cookies_browser = ('' if (_cb := config_manager.get('youtube.cookies_browser', '')) == 'custom' else _cb)
|
||||
if cookies_browser:
|
||||
ydl_opts['cookiesfrombrowser'] = (cookies_browser,)
|
||||
|
||||
|
|
@ -816,7 +816,7 @@ class YouTubeClient(DownloadSourcePlugin):
|
|||
}
|
||||
|
||||
# Add cookie support for search (avoids bot detection)
|
||||
cookies_browser = config_manager.get('youtube.cookies_browser', '')
|
||||
cookies_browser = ('' if (_cb := config_manager.get('youtube.cookies_browser', '')) == 'custom' else _cb)
|
||||
if cookies_browser:
|
||||
ydl_opts['cookiesfrombrowser'] = (cookies_browser,)
|
||||
|
||||
|
|
@ -1180,7 +1180,7 @@ class YouTubeClient(DownloadSourcePlugin):
|
|||
'user_agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
|
||||
}
|
||||
|
||||
cookies_browser = config_manager.get('youtube.cookies_browser', '')
|
||||
cookies_browser = ('' if (_cb := config_manager.get('youtube.cookies_browser', '')) == 'custom' else _cb)
|
||||
if cookies_browser:
|
||||
download_opts['cookiesfrombrowser'] = (cookies_browser,)
|
||||
|
||||
|
|
|
|||
|
|
@ -14747,7 +14747,8 @@ def _youtube_cookie_opts():
|
|||
opts = {}
|
||||
try:
|
||||
cb = config_manager.get('youtube.cookies_browser', '')
|
||||
if cb:
|
||||
# 'custom' = the paste-cookies.txt sentinel (not a yt-dlp browser); skip it here.
|
||||
if cb and cb != 'custom':
|
||||
opts['cookiesfrombrowser'] = (cb,)
|
||||
except Exception: # noqa: S110 - cookie config is best-effort; resolve still works without it
|
||||
pass
|
||||
|
|
|
|||
Loading…
Reference in a new issue