From 3ffb2e46400dc4a42a574f370a6b462bcbdf1550 Mon Sep 17 00:00:00 2001 From: William P Date: Sat, 12 Jul 2025 16:51:15 -0400 Subject: [PATCH] add error reporting to download process --- app/main.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/main.py b/app/main.py index e6ba3ff..ba05390 100644 --- a/app/main.py +++ b/app/main.py @@ -126,16 +126,29 @@ class DownloadVideo(ui.View): worker_task = asyncio.create_task(progress_worker(msg)) + error = None + async def progress_callback(percent): await progress_queue.put(percent) - await asyncio.to_thread( - ytdlp.download_video, self.url, format_string, out_path, temp_path, progress_callback, asyncio.get_event_loop() - ) + loop = asyncio.get_running_loop() + def threaded_download(): + nonlocal error + try: + ytdlp.download_video( + self.url, format_string, out_path, temp_path, progress_callback, loop + ) + except Exception as e: + error = e + await asyncio.to_thread(threaded_download) stop_event.set() await worker_task + if error: + await msg.edit(content=f"❌ Download failed: {error}") + return + # Show completion and summary await msg.edit(content="✅ Download complete!\n" )