add error reporting to download process
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 2m53s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 2m53s
This commit is contained in:
19
app/main.py
19
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"
|
||||
)
|
||||
|
Reference in New Issue
Block a user