F
This commit is contained in:
@@ -18,12 +18,13 @@ from contextlib import AbstractContextManager, nullcontext
|
||||
|
||||
from API.HTTP import _download_direct_file
|
||||
from SYS.models import DownloadError, DownloadOptions, DownloadMediaResult
|
||||
from SYS.logger import log, debug
|
||||
from SYS.logger import log, debug, is_debug_enabled
|
||||
from SYS.pipeline_progress import PipelineProgress
|
||||
from SYS.result_table import Table
|
||||
from SYS.rich_display import stderr_console as get_stderr_console
|
||||
from SYS import pipeline as pipeline_context
|
||||
from SYS.metadata import normalize_urls as normalize_url_list
|
||||
from SYS.utils import sha256_file
|
||||
|
||||
from tool.ytdlp import (
|
||||
YtDlpTool,
|
||||
@@ -1495,6 +1496,41 @@ class Download_File(Cmdlet):
|
||||
forced_single_applied = True
|
||||
|
||||
# Proactive fallback for single audio formats which might be unstable
|
||||
if (
|
||||
actual_format
|
||||
and isinstance(actual_format, str)
|
||||
and actual_format == "audio"
|
||||
):
|
||||
actual_format = "bestaudio/best"
|
||||
|
||||
# DEBUG: Render config panel for tracking pipeline state
|
||||
if is_debug_enabled():
|
||||
try:
|
||||
from rich.table import Table as RichTable
|
||||
from rich import box as RichBox
|
||||
from tool.ytdlp import YtDlpDefaults
|
||||
|
||||
t = RichTable(title="Download Config", show_header=True, header_style="bold magenta", box=RichBox.ROUNDED)
|
||||
t.add_column("Property", style="cyan")
|
||||
t.add_column("Value", style="green")
|
||||
t.add_row("URL", url)
|
||||
t.add_row("Mode", mode)
|
||||
t.add_row("Format", str(actual_format))
|
||||
t.add_row("Playlist Items", str(actual_playlist_items))
|
||||
|
||||
# Browser/Cookie info from ytdlp tool
|
||||
defaults = getattr(ytdlp_tool, "defaults", None)
|
||||
if isinstance(defaults, YtDlpDefaults):
|
||||
t.add_row("Cookie File", str(defaults.cookiefile or "None"))
|
||||
t.add_row("Browser Cookies", str(defaults.cookies_from_browser or "None"))
|
||||
t.add_row("User Agent", str(defaults.user_agent or "default"))
|
||||
|
||||
debug(t)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# If no format explicitly chosen, we might want to check available formats
|
||||
# and maybe show a table if multiple are available?
|
||||
if (
|
||||
actual_format
|
||||
and isinstance(actual_format, str)
|
||||
|
||||
@@ -17,7 +17,7 @@ from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional, Sequence, Tuple
|
||||
from urllib.parse import urlsplit, quote, urljoin, unquote
|
||||
|
||||
from SYS.logger import log, debug
|
||||
from SYS.logger import log, debug, is_debug_enabled
|
||||
from API.HTTP import HTTPClient
|
||||
from SYS.pipeline_progress import PipelineProgress
|
||||
from SYS.utils import ensure_directory, unique_path, unique_preserve_order
|
||||
@@ -27,6 +27,7 @@ Cmdlet = sh.Cmdlet
|
||||
CmdletArg = sh.CmdletArg
|
||||
SharedArgs = sh.SharedArgs
|
||||
create_pipe_object_result = sh.create_pipe_object_result
|
||||
coerce_to_pipe_object = sh.coerce_to_pipe_object
|
||||
normalize_result_input = sh.normalize_result_input
|
||||
should_show_help = sh.should_show_help
|
||||
get_field = sh.get_field
|
||||
@@ -592,13 +593,33 @@ def _capture(
|
||||
}
|
||||
})
|
||||
|
||||
tool.debug_dump()
|
||||
if is_debug_enabled():
|
||||
try:
|
||||
from rich.table import Table
|
||||
from rich import box
|
||||
t = Table(title="Screenshot Config", show_header=True, header_style="bold magenta", box=box.ROUNDED)
|
||||
t.add_column("Property", style="cyan")
|
||||
t.add_column("Value", style="green")
|
||||
t.add_row("URL", options.url)
|
||||
t.add_row("Format", _normalize_format(options.output_format))
|
||||
|
||||
# Browser details
|
||||
defaults = getattr(tool, "defaults", None)
|
||||
if defaults:
|
||||
t.add_row("Browser", getattr(defaults, "browser", "unknown"))
|
||||
t.add_row("Headless", str(getattr(defaults, "headless", "unknown")))
|
||||
t.add_row("Viewport", f"{getattr(defaults, 'viewport_width', '?')}x{getattr(defaults, 'viewport_height', '?')}")
|
||||
t.add_row("Timeout", f"{getattr(defaults, 'navigation_timeout_ms', '?')}ms")
|
||||
|
||||
t.add_row("Full Page", str(options.full_page))
|
||||
t.add_row("Destination", str(destination))
|
||||
debug(t)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
debug("Launching browser...")
|
||||
format_name = _normalize_format(options.output_format)
|
||||
headless = options.headless or format_name == "pdf"
|
||||
debug(f"[_capture] Format: {format_name}, Headless: {headless}")
|
||||
|
||||
|
||||
if format_name == "pdf" and not options.headless:
|
||||
warnings.append(
|
||||
"pdf output requires headless Chromium; overriding headless mode"
|
||||
@@ -1129,6 +1150,8 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
is_temp=True,
|
||||
parent_hash=hashlib.sha256(url.encode()).hexdigest(),
|
||||
tag=merged_tags,
|
||||
url=url, # Explicitly map url to top-level PipeObject field
|
||||
source_url=url, # Map source_url as well
|
||||
extra={
|
||||
"source_url": url,
|
||||
"archive_url": screenshot_result.archive_url,
|
||||
@@ -1141,6 +1164,24 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
pipeline_context.emit(pipe_obj)
|
||||
all_emitted.append(pipe_obj)
|
||||
|
||||
# Debug: show PipeObject preview if enabled
|
||||
if is_debug_enabled():
|
||||
try:
|
||||
debug("[screen-shot] Output PipeObject preview")
|
||||
po = coerce_to_pipe_object(pipe_obj)
|
||||
from SYS.logger import _sanitize_pipe_object_for_debug as _sanitize # Or use helper if avail
|
||||
# Add simple sanitize helper if not available
|
||||
def _safe_table(obj):
|
||||
try:
|
||||
# Try calling debug_table on the object
|
||||
if hasattr(obj, "debug_table"):
|
||||
obj.debug_table()
|
||||
except Exception:
|
||||
pass
|
||||
_safe_table(po)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# If we created a local progress UI, advance it per completed item.
|
||||
progress.on_emit(pipe_obj)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user