pribably fixed notifications

This commit is contained in:
Vxrtrauter
2025-10-12 20:26:34 +02:00
parent 30e920675d
commit 5215fb2e1b
+19 -8
View File
@@ -55,17 +55,28 @@ def dlprogress():
except: except:
return 0 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): def send_notification(shutdown_event):
notified = set()
while not shutdown_event.is_set(): while not shutdown_event.is_set():
try: try:
for download in state.downloads: for d in state.aria2.get_downloads():
if dlprogress() == 100: if d.is_metadata:
notification.notify( continue
title = "Download finished", if d.progress == 100 and d.gid not in notified:
message = f"{download.name} has finished downloading.", notification.notify(
timeout = 4 title="Download finished",
) message=f"{d.name} has finished downloading.",
except Exception as e: 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 pass
time.sleep(5) time.sleep(5)