From 5215fb2e1b2496b8a980083e81346ef36fa6ffa7 Mon Sep 17 00:00:00 2001 From: Vxrtrauter Date: Sun, 12 Oct 2025 20:26:34 +0200 Subject: [PATCH] pribably fixed notifications --- core/network/aria2_integration.py | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/core/network/aria2_integration.py b/core/network/aria2_integration.py index 49cd7e5..b9a7ec1 100644 --- a/core/network/aria2_integration.py +++ b/core/network/aria2_integration.py @@ -54,18 +54,29 @@ def dlprogress(): return 0 except: return 0 - + +def get_active_downloads(): + try: + downloads = state.aria2.get_downloads() + return [d for d in downloads if d.is_active] + except: + return [] def send_notification(shutdown_event): + notified = set() while not shutdown_event.is_set(): try: - for download in state.downloads: - if dlprogress() == 100: - notification.notify( - title = "Download finished", - message = f"{download.name} has finished downloading.", - timeout = 4 - ) - except Exception as e: + for d in state.aria2.get_downloads(): + if d.is_metadata: + continue + if d.progress == 100 and d.gid not in notified: + notification.notify( + title="Download finished", + message=f"{d.name} has finished downloading.", + timeout=4 + ) + notified.add(d.gid) + state.downloads = [d for d in state.aria2.get_downloads() if d.is_active and not d.is_metadata] + except Exception: pass - time.sleep(5) + time.sleep(5) \ No newline at end of file