updated panel display
This commit is contained in:
+41
-32
@@ -19,7 +19,7 @@ from urllib.parse import urlparse
|
||||
|
||||
from SYS import pipeline as pipeline_context
|
||||
from SYS.config import get_nested_config_value as _get_nested
|
||||
from SYS.logger import debug, log
|
||||
from SYS.logger import debug, debug_panel, log
|
||||
from SYS.models import (
|
||||
DebugLogger,
|
||||
DownloadError,
|
||||
@@ -505,7 +505,6 @@ def probe_url(
|
||||
|
||||
def _do_probe() -> None:
|
||||
try:
|
||||
debug(f"[probe] Starting probe for {url}")
|
||||
ensure_yt_dlp_ready()
|
||||
|
||||
assert yt_dlp is not None
|
||||
@@ -529,9 +528,7 @@ def probe_url(
|
||||
ydl_opts["noplaylist"] = True
|
||||
|
||||
with yt_dlp.YoutubeDL(ydl_opts) as ydl: # type: ignore[arg-type]
|
||||
debug(f"[probe] ytdlp extract_info (download=False) start: {url}")
|
||||
info = ydl.extract_info(url, download=False)
|
||||
debug(f"[probe] ytdlp extract_info (download=False) done: {url}")
|
||||
|
||||
if not isinstance(info, dict):
|
||||
result_container[0] = None
|
||||
@@ -550,6 +547,16 @@ def probe_url(
|
||||
"webpage_url": webpage_url,
|
||||
"url": webpage_url or url,
|
||||
}
|
||||
debug_panel(
|
||||
"yt-dlp probe",
|
||||
[
|
||||
("url", url),
|
||||
("extractor", info.get("extractor", "")),
|
||||
("title", info.get("title", "")),
|
||||
("playlist", bool(info.get("entries"))),
|
||||
],
|
||||
border_style="green",
|
||||
)
|
||||
except Exception as exc:
|
||||
debug(f"Probe error for {url}: {exc}")
|
||||
result_container[1] = exc
|
||||
@@ -1112,12 +1119,6 @@ class YtDlpTool:
|
||||
if clip_safe_fmt != fmt:
|
||||
debug(f"[ytdlp] clip format normalized: {fmt} -> {clip_safe_fmt}")
|
||||
fmt = clip_safe_fmt
|
||||
debug(
|
||||
"[ytdlp] build options: "
|
||||
f"mode={opts.mode}, ytdl_format={ytdl_format}, default_format={default_fmt}, final_format={fmt}, "
|
||||
f"cookiefile={base_options.get('cookiefile')}, cookiesfrombrowser={base_options.get('cookiesfrombrowser')}, "
|
||||
f"player_client={((base_options.get('extractor_args') or {}).get('youtube') or {}).get('player_client')}"
|
||||
)
|
||||
base_options["format"] = fmt
|
||||
|
||||
if opts.mode == "audio":
|
||||
@@ -1199,9 +1200,6 @@ class YtDlpTool:
|
||||
if opts.playlist_items:
|
||||
base_options["playlist_items"] = opts.playlist_items
|
||||
|
||||
if not opts.quiet:
|
||||
debug(f"yt-dlp: mode={opts.mode}, format={base_options.get('format')}, cookiefile={base_options.get('cookiefile')}")
|
||||
|
||||
return base_options
|
||||
|
||||
def build_yt_dlp_cli_args(
|
||||
@@ -2100,7 +2098,6 @@ def download_media(opts: DownloadOptions, *, config: Optional[Dict[str, Any]] =
|
||||
format) are applied when constructing the YtDlpTool instance.
|
||||
"""
|
||||
|
||||
debug(f"[download_media] start: {opts.url}")
|
||||
try:
|
||||
netloc = urlparse(opts.url).netloc.lower()
|
||||
except Exception:
|
||||
@@ -2123,9 +2120,6 @@ def download_media(opts: DownloadOptions, *, config: Optional[Dict[str, Any]] =
|
||||
raise DownloadError(msg)
|
||||
|
||||
if opts.playlist_items:
|
||||
debug(
|
||||
f"Skipping probe for playlist (item selection: {opts.playlist_items}), proceeding with download"
|
||||
)
|
||||
probe_result: Optional[Dict[str, Any]] = {"url": opts.url}
|
||||
else:
|
||||
probe_cookiefile = None
|
||||
@@ -2138,8 +2132,6 @@ def download_media(opts: DownloadOptions, *, config: Optional[Dict[str, Any]] =
|
||||
probe_result = probe_url(opts.url, no_playlist=opts.no_playlist, timeout_seconds=15, cookiefile=probe_cookiefile)
|
||||
|
||||
if probe_result is None:
|
||||
if not opts.quiet:
|
||||
debug("yt-dlp probe returned no metadata; continuing with direct download attempt")
|
||||
if debug_logger is not None:
|
||||
debug_logger.write_record("ytdlp-probe-miss-continue", {"url": opts.url})
|
||||
|
||||
@@ -2155,7 +2147,18 @@ def download_media(opts: DownloadOptions, *, config: Optional[Dict[str, Any]] =
|
||||
if _progress_callback not in hooks:
|
||||
hooks.append(_progress_callback)
|
||||
if not opts.quiet:
|
||||
debug(f"Starting yt-dlp download: {opts.url}")
|
||||
debug_panel(
|
||||
"yt-dlp job",
|
||||
[
|
||||
("url", opts.url),
|
||||
("mode", opts.mode),
|
||||
("format", ytdl_options.get("format") or "default"),
|
||||
("cookiefile", ytdl_options.get("cookiefile")),
|
||||
("download_sections", ytdl_options.get("download_sections") or "None"),
|
||||
("force_keyframes", ytdl_options.get("force_keyframes_at_cuts", False)),
|
||||
],
|
||||
border_style="blue",
|
||||
)
|
||||
if debug_logger is not None:
|
||||
debug_logger.write_record("ytdlp-start", {"url": opts.url})
|
||||
|
||||
@@ -2164,11 +2167,6 @@ def download_media(opts: DownloadOptions, *, config: Optional[Dict[str, Any]] =
|
||||
session_id = None
|
||||
first_section_info: Dict[str, Any] = {}
|
||||
try:
|
||||
if not opts.quiet:
|
||||
if ytdl_options.get("download_sections"):
|
||||
debug(f"[yt-dlp] download_sections: {ytdl_options['download_sections']}")
|
||||
debug(f"[yt-dlp] force_keyframes_at_cuts: {ytdl_options.get('force_keyframes_at_cuts', False)}")
|
||||
|
||||
if ytdl_options.get("download_sections"):
|
||||
live_ui, _ = PipelineProgress(pipeline_context).ui_and_pipe_index()
|
||||
quiet_sections = bool(opts.quiet) or (live_ui is not None)
|
||||
@@ -2354,18 +2352,21 @@ def download_media(opts: DownloadOptions, *, config: Optional[Dict[str, Any]] =
|
||||
media_paths = renamed_media_files if renamed_media_files else None
|
||||
if not opts.quiet:
|
||||
count = len(media_paths) if isinstance(media_paths, list) else 1
|
||||
debug(f"✓ Downloaded {count} section media file(s) (session: {session_id})")
|
||||
debug_panel(
|
||||
"yt-dlp result",
|
||||
[
|
||||
("files", count),
|
||||
("session", session_id),
|
||||
("file", media_path.name),
|
||||
],
|
||||
border_style="green",
|
||||
)
|
||||
else:
|
||||
media_path = files[0]
|
||||
media_paths = None
|
||||
if not opts.quiet:
|
||||
debug(f"✓ Downloaded section file (pattern not found): {media_path.name}")
|
||||
else:
|
||||
media_path = files[0]
|
||||
media_paths = None
|
||||
|
||||
if not opts.quiet:
|
||||
debug(f"✓ Downloaded: {media_path.name}")
|
||||
if debug_logger is not None:
|
||||
debug_logger.write_record("ytdlp-file-found", {"path": str(media_path)})
|
||||
except Exception as exc:
|
||||
@@ -2462,7 +2463,15 @@ def download_media(opts: DownloadOptions, *, config: Optional[Dict[str, Any]] =
|
||||
source_url = entry.get("webpage_url") or entry.get("original_url") or entry.get("url")
|
||||
|
||||
if not opts.quiet:
|
||||
debug(f"✓ Downloaded: {media_path.name} ({len(tags_res)} tags)")
|
||||
debug_panel(
|
||||
"yt-dlp result",
|
||||
[
|
||||
("file", media_path.name),
|
||||
("tag_count", len(tags_res)),
|
||||
("source_url", source_url or opts.url),
|
||||
],
|
||||
border_style="green",
|
||||
)
|
||||
if debug_logger is not None:
|
||||
debug_logger.write_record(
|
||||
"downloaded",
|
||||
|
||||
Reference in New Issue
Block a user