-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnotification.py
33 lines (29 loc) · 1.02 KB
/
notification.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import utils
import outputs
try:
import notify2
def send_notification(summary, body):
notify2.init('Gogoanime CLI')
n = notify2.Notification(summary, message=body)
n.show()
except ImportError:
def send_notification(summary, body):
outputs.error_info('Notification system is not setup properly')
def episodes_update(updates):
if len(updates) == 0:
return
if len(updates) == 1:
anime_name = list(updates)[0]
epl = len(updates[anime_name])
eps = utils.compress_range(updates[anime_name])
summary = f'{epl} New episode(s)'
msg = f'{anime_name} has {epl} new episodes ({eps})'
send_notification(summary, msg)
else:
summary = f'{len(updates)} anime updates'
msg = ''
for anime_name, ep in updates.items():
epl = len(updates[anime_name])
eps = utils.compress_range(updates[anime_name])
msg += f'{epl} new ({eps}) : {anime_name}\n'
send_notification(summary, msg)