This commit is contained in:
2026-03-31 23:30:57 -07:00
parent 6ef5b645a8
commit 57b595c1a4
7 changed files with 381 additions and 111 deletions

View File

@@ -1000,22 +1000,15 @@ def _build_hydrus_header(config: Dict[str, Any]) -> Optional[str]:
def _build_ytdl_options(config: Optional[Dict[str,
Any]],
hydrus_header: Optional[str]) -> Optional[str]:
"""Compose ytdl-raw-options string including cookies and optional Hydrus header."""
"""Compose mpv ytdl-raw-options for playback.
Keep this limited to options that are truly required for MPV playback.
In particular, do not pass the repo cookiefile via `cookies=...` here:
mpv's ytdl-hook can fail to resolve some YouTube/Shorts URLs when a global
cookiefile is forced, even though the same URLs work with MPV defaults.
"""
opts: List[str] = []
cookies_path = None
try:
from tool.ytdlp import YtDlpTool
cookiefile = YtDlpTool(config or {}).resolve_cookiefile()
if cookiefile is not None:
cookies_path = str(cookiefile)
except Exception:
cookies_path = None
if cookies_path:
opts.append(f"cookies={cookies_path.replace('\\', '/')}")
# Do not force chrome cookies if none are found; let yt-dlp use its defaults or fail gracefully.
if hydrus_header:
opts.append(f"add-header={hydrus_header}")
return ",".join(opts) if opts else None
@@ -2584,19 +2577,10 @@ def _start_mpv(
_schedule_notes_prefetch(items[:1], config)
cookies_path = None
try:
from tool.ytdlp import YtDlpTool
cookiefile = YtDlpTool(config or {}).resolve_cookiefile()
if cookiefile is not None:
cookies_path = str(cookiefile)
except Exception:
cookies_path = None
if cookies_path:
debug(f"Starting MPV with cookies file: {cookies_path.replace('\\', '/')}")
if ytdl_opts:
debug(f"Starting MPV with ytdl raw options: {ytdl_opts}")
else:
debug("Starting MPV with browser cookies: chrome")
debug("Starting MPV with default yt-dlp raw options")
try:
extra_args: List[str] = [