fix downloader

This commit is contained in:
2025-12-05 22:53:59 +03:00
parent e635a6fb0d
commit 541b5a9218
3 changed files with 21 additions and 2 deletions

View File

@@ -442,24 +442,30 @@ async def download_media(
original_stderr = sys.stderr
error_filter = None
logger.info(f"Starting yt-dlp download for URL: {url}")
try:
# Redirect stderr to filter non-critical errors
error_filter = YtDlpErrorFilter(original_stderr)
sys.stderr = error_filter
logger.info(f"Extracting info for URL: {url}")
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
# Check for cancellation before start
if cancel_event and cancel_event.is_set():
raise KeyboardInterrupt("Download cancelled")
# Get video information
logger.info(f"Extracting video info for: {url}")
info = ydl.extract_info(url, download=False)
logger.info(f"Video info extracted: title={info.get('title', 'N/A')[:50]}, duration={info.get('duration', 'N/A')}")
# Check for cancellation after getting info
if cancel_event and cancel_event.is_set():
raise KeyboardInterrupt("Download cancelled")
# Download (progress hook will be called from this thread)
logger.info(f"Starting download for: {url}")
# Note: Some postprocessors may show errors (like FixupM3u8 with aspect ratio),
# but the video file is still downloaded correctly
try: