mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 17:59:43 +02:00
pribably fixed notifications
This commit is contained in:
@@ -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:
|
||||||
|
continue
|
||||||
|
if d.progress == 100 and d.gid not in notified:
|
||||||
notification.notify(
|
notification.notify(
|
||||||
title="Download finished",
|
title="Download finished",
|
||||||
message = f"{download.name} has finished downloading.",
|
message=f"{d.name} has finished downloading.",
|
||||||
timeout=4
|
timeout=4
|
||||||
)
|
)
|
||||||
except Exception as e:
|
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)
|
||||||
Reference in New Issue
Block a user