h
This commit is contained in:
@@ -131,7 +131,8 @@ def _build_supported_domains() -> set[str]:
|
||||
domains = extract_domains(regex)
|
||||
_SUPPORTED_DOMAINS.update(domains)
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to build supported domains from yt-dlp extractors")
|
||||
return _SUPPORTED_DOMAINS
|
||||
|
||||
|
||||
@@ -299,7 +300,8 @@ def _add_browser_cookies_if_available(options: Dict[str, Any], preferred_browser
|
||||
log(f"Requested browser cookie DB '{preferred_browser}' not found; falling back to autodetect.")
|
||||
_BROWSER_COOKIE_WARNING_EMITTED = True
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to check browser cookie path for preferred browser '%s'", preferred_browser)
|
||||
|
||||
# Auto-detect in common order (chrome/chromium/brave)
|
||||
for candidate in ("chrome", "chromium", "brave"):
|
||||
@@ -308,6 +310,8 @@ def _add_browser_cookies_if_available(options: Dict[str, Any], preferred_browser
|
||||
options["cookiesfrombrowser"] = [candidate]
|
||||
return
|
||||
except Exception:
|
||||
from SYS.logger import logger
|
||||
logger.exception("Error while checking cookie path for candidate browser '%s'", candidate)
|
||||
continue
|
||||
|
||||
if not _BROWSER_COOKIE_WARNING_EMITTED:
|
||||
@@ -650,7 +654,8 @@ def format_for_table_selection(
|
||||
if vcodec != "none" and acodec == "none" and format_id:
|
||||
selection_format_id = f"{format_id}+ba"
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to compute selection_format_id for format: %s", fmt)
|
||||
|
||||
# Format file size
|
||||
size_str = ""
|
||||
@@ -661,7 +666,8 @@ def format_for_table_selection(
|
||||
size_mb = float(size_bytes) / (1024 * 1024)
|
||||
size_str = f"{size_prefix}{size_mb:.1f}MB"
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to compute size string for format: %s", fmt)
|
||||
|
||||
# Build description
|
||||
desc_parts: List[str] = []
|
||||
@@ -755,7 +761,8 @@ class YtDlpTool:
|
||||
if resolved is not None and resolved.is_file():
|
||||
return resolved
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to initialize cookiefile using resolve_cookies_path")
|
||||
return None
|
||||
|
||||
def resolve_height_selector(self, format_str: Optional[str]) -> Optional[str]:
|
||||
@@ -908,13 +915,15 @@ class YtDlpTool:
|
||||
if bundled_ffmpeg_dir.exists():
|
||||
base_options.setdefault("ffmpeg_location", str(bundled_ffmpeg_dir))
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to inspect bundled ffmpeg directory")
|
||||
|
||||
try:
|
||||
if os.name == "nt":
|
||||
base_options.setdefault("file_access_retries", 40)
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to set Windows-specific yt-dlp options")
|
||||
|
||||
if opts.cookies_path and opts.cookies_path.is_file():
|
||||
base_options["cookiefile"] = str(opts.cookies_path)
|
||||
@@ -948,7 +957,8 @@ class YtDlpTool:
|
||||
|
||||
opts = _dc.replace(opts, mode="audio", ytdl_format=None)
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to set opts mode to audio via dataclasses.replace")
|
||||
elif opts.ytdl_format == "video":
|
||||
try:
|
||||
opts = opts._replace(mode="video", ytdl_format=None)
|
||||
@@ -958,7 +968,8 @@ class YtDlpTool:
|
||||
|
||||
opts = _dc.replace(opts, mode="video", ytdl_format=None)
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to set opts mode to video via dataclasses.replace")
|
||||
|
||||
if opts.no_playlist:
|
||||
base_options["noplaylist"] = True
|
||||
@@ -978,7 +989,8 @@ class YtDlpTool:
|
||||
|
||||
opts = _dc.replace(opts, mode="audio")
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to set opts mode to audio via dataclasses.replace (configured default)")
|
||||
ytdl_format = None
|
||||
else:
|
||||
# Leave ytdl_format None so that default_format(opts.mode)
|
||||
@@ -1130,7 +1142,8 @@ class YtDlpTool:
|
||||
try:
|
||||
debug("yt-dlp argv: " + " ".join(str(a) for a in argv))
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to debug-print yt-dlp CLI arguments")
|
||||
|
||||
|
||||
def config_schema() -> List[Dict[str, Any]]:
|
||||
@@ -1150,6 +1163,8 @@ def config_schema() -> List[Dict[str, Any]]:
|
||||
if _browser_cookie_path_for(b) is not None:
|
||||
browser_choices.append(b)
|
||||
except Exception:
|
||||
from SYS.logger import logger
|
||||
logger.exception("Error while checking cookie path for browser '%s'", b)
|
||||
continue
|
||||
|
||||
return [
|
||||
@@ -1410,7 +1425,8 @@ def _download_with_sections_via_cli(
|
||||
try:
|
||||
_set_pipe_percent(current)
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to set pipeline percent to %d", current)
|
||||
|
||||
def start(self) -> None:
|
||||
if self._thread is not None or self._start_pct >= self._max_pct:
|
||||
@@ -1426,7 +1442,8 @@ def _download_with_sections_via_cli(
|
||||
try:
|
||||
_set_pipe_percent(self._max_pct)
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to set pipeline percent to max %d", self._max_pct)
|
||||
|
||||
session_id = hashlib.md5((url + str(time.time()) + "".join(random.choices(string.ascii_letters, k=10))).encode()).hexdigest()[:12]
|
||||
first_section_info = None
|
||||
@@ -1440,7 +1457,8 @@ def _download_with_sections_via_cli(
|
||||
try:
|
||||
_set_pipe_percent(display_pct)
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to set pipeline percent to display_pct %d for section %d", display_pct, section_idx)
|
||||
|
||||
pipeline.set_status(f"Downloading & clipping clip section {section_idx}/{total_sections}")
|
||||
|
||||
@@ -1484,7 +1502,8 @@ def _download_with_sections_via_cli(
|
||||
try:
|
||||
cmd.extend(["--ffmpeg-location", str(ytdl_options["ffmpeg_location"])])
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to append ffmpeg_location CLI option")
|
||||
if ytdl_options.get("format"):
|
||||
cmd.extend(["-f", ytdl_options["format"]])
|
||||
if ytdl_options.get("merge_output_format"):
|
||||
@@ -1547,7 +1566,8 @@ def _download_with_sections_via_cli(
|
||||
try:
|
||||
_set_pipe_percent(99)
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to set pipeline percent to 99 at end of multi-section job")
|
||||
|
||||
return session_id, first_section_info or {}
|
||||
|
||||
@@ -1654,7 +1674,8 @@ def _progress_callback(status: Dict[str, Any]) -> None:
|
||||
if isinstance(value, (int, float)) and value > 0:
|
||||
return int(value)
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to interpret total bytes value: %r", value)
|
||||
return None
|
||||
|
||||
if event == "downloading":
|
||||
@@ -1669,7 +1690,8 @@ def _progress_callback(status: Dict[str, Any]) -> None:
|
||||
total=_total_bytes(total),
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to update pipeline transfer for label '%s'", label)
|
||||
else:
|
||||
_YTDLP_PROGRESS_BAR.update(
|
||||
downloaded=int(downloaded) if downloaded is not None else None,
|
||||
@@ -1683,7 +1705,8 @@ def _progress_callback(status: Dict[str, Any]) -> None:
|
||||
if _YTDLP_TRANSFER_STATE.get(label, {}).get("started"):
|
||||
pipeline.finish_transfer(label=label)
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to finish pipeline transfer for label '%s'", label)
|
||||
_YTDLP_TRANSFER_STATE.pop(label, None)
|
||||
else:
|
||||
_YTDLP_PROGRESS_BAR.finish()
|
||||
@@ -1848,7 +1871,8 @@ def download_media(opts: DownloadOptions, *, config: Optional[Dict[str, Any]] =
|
||||
if cand.suffix.lower() in {".json", ".info.json"}:
|
||||
continue
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to inspect candidate suffix for %s", cand)
|
||||
media_file = cand
|
||||
break
|
||||
if media_file is None and media_candidates:
|
||||
@@ -1870,10 +1894,13 @@ def download_media(opts: DownloadOptions, *, config: Optional[Dict[str, Any]] =
|
||||
if name.startswith(prefix):
|
||||
return name[len(prefix):]
|
||||
except Exception:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to check name prefix for '%s'", name)
|
||||
try:
|
||||
return Path(name).suffix
|
||||
except Exception:
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to obtain suffix for name '%s'", name)
|
||||
return ""
|
||||
|
||||
try:
|
||||
@@ -1884,7 +1911,8 @@ def download_media(opts: DownloadOptions, *, config: Optional[Dict[str, Any]] =
|
||||
try:
|
||||
media_file.unlink()
|
||||
except OSError:
|
||||
pass
|
||||
from SYS.logger import logger
|
||||
logger.exception("Failed to unlink duplicate media file %s", media_file)
|
||||
else:
|
||||
media_file.rename(new_media_path)
|
||||
debug(f"Renamed section file: {media_file.name} -> {new_media_name}")
|
||||
|
||||
Reference in New Issue
Block a user