jkj
This commit is contained in:
@@ -16,7 +16,7 @@ from models import PipeObject
|
||||
|
||||
from API.folder import LocalLibrarySearchOptimizer
|
||||
from config import get_local_storage_path, get_hydrus_access_key, get_hydrus_url
|
||||
from hydrus_health_check import get_cookies_file_path
|
||||
|
||||
|
||||
|
||||
_ALLDEBRID_UNLOCK_CACHE: Dict[str, str] = {}
|
||||
@@ -372,12 +372,18 @@ 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."""
|
||||
opts: List[str] = []
|
||||
cookies_path = None
|
||||
try:
|
||||
cookies_path = get_cookies_file_path()
|
||||
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('\\', '/')}")
|
||||
opts.append(f"cookies={cookies_path.replace('\\', '/')}" )
|
||||
else:
|
||||
opts.append("cookies-from-browser=chrome")
|
||||
if hydrus_header:
|
||||
@@ -407,10 +413,18 @@ def _is_hydrus_path(path: str, hydrus_url: Optional[str]) -> bool:
|
||||
return True
|
||||
return False
|
||||
|
||||
def _ensure_ytdl_cookies() -> None:
|
||||
def _ensure_ytdl_cookies(config: Optional[Dict[str, Any]] = None) -> None:
|
||||
"""Ensure yt-dlp options are set correctly for this session."""
|
||||
from pathlib import Path
|
||||
cookies_path = get_cookies_file_path()
|
||||
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:
|
||||
# Check if file exists and has content (use forward slashes for path checking)
|
||||
check_path = cookies_path.replace('\\', '/')
|
||||
@@ -635,7 +649,7 @@ def _queue_items(
|
||||
pass
|
||||
|
||||
# Just verify cookies are configured, don't try to set via IPC
|
||||
_ensure_ytdl_cookies()
|
||||
_ensure_ytdl_cookies(config)
|
||||
|
||||
hydrus_header = _build_hydrus_header(config or {})
|
||||
ytdl_opts = _build_ytdl_options(config, hydrus_header)
|
||||
@@ -1426,7 +1440,15 @@ def _start_mpv(items: List[Any], config: Optional[Dict[str, Any]] = None, start_
|
||||
hydrus_header = _build_hydrus_header(config or {})
|
||||
ytdl_opts = _build_ytdl_options(config, hydrus_header)
|
||||
|
||||
cookies_path = get_cookies_file_path()
|
||||
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('\\', '/')}")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user