18
anime-rss.py
18
anime-rss.py
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user