1
0

Add notifications

Signed-off-by: MK13 <marius@kleberonline.de>
This commit is contained in:
2021-10-14 22:57:02 +02:00
parent 762acf8562
commit 0aa464018c
5 changed files with 152 additions and 11 deletions

View File

@@ -3,6 +3,7 @@ import json
import re
import subprocess
import argparse
from notifypy import Notify
feedparser.USER_AGENT = "anime-rss/1.0"
@@ -29,6 +30,15 @@ def build_target_folder():
return config["animeDownloadDir"]
def send_notification(message):
if config["notifications"]:
notification = Notify()
notification.title = "anime-rss"
notification.message = message
notification.icon = "notfication-icon.png"
notification.send()
with open(args.a, "r") as feeds:
feeds = json.load(feeds)
@@ -60,9 +70,13 @@ for feed in feeds["Feeds"]:
if int(episodeNumber[0]) > int(anime["Local"]):
print(BOLD_GREEN + "NEW NEW NEW " + anime["Title"] + " " + episodeNumber[0] + RESET)
subprocess.run(["transmission-remote", "-a", entry.link, "-w", build_target_folder()])
if subprocess.run(["transmission-remote", "-a", entry.link, "-w", build_target_folder()]).returncode == 0:
anime["Local"] = str(int(anime["Local"]) + 1).zfill(2)
send_notification("Episode " + anime["Local"] + " of " + anime["Title"] + " added!")
else:
send_notification("Transmission not running or not reachable!")
anime["Local"] = str(int(anime["Local"]) + 1).zfill(2)
with open(args.a, "w") as new_feeds:
new_feeds.write(json.dumps(feeds, indent=3))