diff --git a/Pipfile b/Pipfile index b37e715..8484e38 100644 --- a/Pipfile +++ b/Pipfile @@ -5,9 +5,11 @@ name = "pypi" [packages] feedparser = "*" +notifypy = "*" [dev-packages] feedparser = "*" +notifypy = "*" [requires] python_version = "3.9" diff --git a/Pipfile.lock b/Pipfile.lock index 863a4b4..20d3f04 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "a5b1a05178ba0bdf014ddb3dab8a245707f7020e72225c1036edb8c96b27f4e1" + "sha256": "7506f6a89bb55913a844cb70340725cbf1b1032cde16d7048231be79820ec318" }, "pipfile-spec": 6, "requires": { @@ -16,29 +16,151 @@ ] }, "default": { + "certifi": { + "hashes": [ + "sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872", + "sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569" + ], + "version": "==2021.10.8" + }, + "charset-normalizer": { + "hashes": [ + "sha256:e019de665e2bcf9c2b64e2e5aa025fa991da8720daa3c1138cadd2fd1856aed0", + "sha256:f7af805c321bfa1ce6714c51f254e0d5bb5e5834039bc17db7ebe3a4cec9492b" + ], + "markers": "python_version >= '3'", + "version": "==2.0.7" + }, "feedparser": { "hashes": [ - "sha256:1b00a105425f492f3954fd346e5b524ca9cef3a4bbf95b8809470e9857aa1074", - "sha256:f596c4b34fb3e2dc7e6ac3a8191603841e8d5d267210064e94d4238737452ddd" + "sha256:1b7f57841d9cf85074deb316ed2c795091a238adb79846bc46dccdaf80f9c59a", + "sha256:5ce0410a05ab248c8c7cfca3a0ea2203968ee9ff4486067379af4827a59f9661" ], "index": "pypi", - "version": "==6.0.2" + "version": "==6.0.8" + }, + "gmail": { + "hashes": [ + "sha256:3028711d4db7db5fa47c6ddd01f237360d7ce27a3f08997bb517ba811a8418ca" + ], + "version": "==0.6.3" + }, + "idna": { + "hashes": [ + "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff", + "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d" + ], + "markers": "python_version >= '3'", + "version": "==3.3" + }, + "jeepney": { + "hashes": [ + "sha256:1b5a0ea5c0e7b166b2f5895b91a08c14de8915afda4407fb5022a195224958ac", + "sha256:fa9e232dfa0c498bd0b8a3a73b8d8a31978304dcef0515adc859d4e096f96f4f" + ], + "markers": "sys_platform == 'linux'", + "version": "==0.7.1" + }, + "loguru": { + "hashes": [ + "sha256:b28e72ac7a98be3d28ad28570299a393dfcd32e5e3f6a353dec94675767b6319", + "sha256:f8087ac396b5ee5f67c963b495d615ebbceac2796379599820e324419d53667c" + ], + "markers": "python_version >= '3.5'", + "version": "==0.5.3" + }, + "notify-py": { + "hashes": [ + "sha256:8561c7d363eddad3b07be11405135e168c2f52e42bdbfc7f2e613b07a8e7bae0", + "sha256:9b9f689631ddba2ec1313fe4b4d19b8f1f032b38bbdc118b21cdd880c134e8a6" + ], + "index": "pypi", + "version": "==0.3.3" + }, + "notifypy": { + "hashes": [ + "sha256:c14bff0c5d2fb5c09572d2e7eccb4af542c6ad2160a6cfbad684ffef75f81c6b" + ], + "index": "pypi", + "version": "==1.0.3.0" + }, + "pyjwt": { + "hashes": [ + "sha256:a0b9a3b4e5ca5517cac9f1a6e9cd30bf1aa80be74fcdf4e28eded582ecfcfbae", + "sha256:b0ed5824c8ecc5362e540c65dc6247567db130c4226670bf7699aec92fb4dae1" + ], + "markers": "python_version >= '3.6'", + "version": "==2.2.0" + }, + "pytz": { + "hashes": [ + "sha256:3672058bc3453457b622aab7a1c3bfd5ab0bdae451512f6cf25f64ed37f5b87c", + "sha256:acad2d8b20a1af07d4e4c9d2e9285c5ed9104354062f275f3fcd88dcef4f1326" + ], + "version": "==2021.3" + }, + "requests": { + "hashes": [ + "sha256:6c1246513ecd5ecd4528a0906f910e8f0f9c6b8ec72030dc9fd154dc1a6efd24", + "sha256:b8aa58f8cf793ffd8782d3d8cb19e66ef36f7aba4353eec859e74678b01b07a7" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'", + "version": "==2.26.0" }, "sgmllib3k": { "hashes": [ "sha256:7868fb1c8bfa764c1ac563d3cf369c381d1325d36124933a726f29fcdaa812e9" ], "version": "==1.0.0" + }, + "twilio": { + "hashes": [ + "sha256:5d669bf92037cfa231bf8aa336b9e38763e18d16309ddbc5d66b21b00bbad157" + ], + "markers": "python_version >= '3.6'", + "version": "==7.1.0" + }, + "urllib3": { + "hashes": [ + "sha256:4987c65554f7a2dbf30c18fd48778ef124af6fab771a377103da0585e2336ece", + "sha256:c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'", + "version": "==1.26.7" } }, "develop": { "feedparser": { "hashes": [ - "sha256:1b00a105425f492f3954fd346e5b524ca9cef3a4bbf95b8809470e9857aa1074", - "sha256:f596c4b34fb3e2dc7e6ac3a8191603841e8d5d267210064e94d4238737452ddd" + "sha256:1b7f57841d9cf85074deb316ed2c795091a238adb79846bc46dccdaf80f9c59a", + "sha256:5ce0410a05ab248c8c7cfca3a0ea2203968ee9ff4486067379af4827a59f9661" ], "index": "pypi", - "version": "==6.0.2" + "version": "==6.0.8" + }, + "jeepney": { + "hashes": [ + "sha256:1b5a0ea5c0e7b166b2f5895b91a08c14de8915afda4407fb5022a195224958ac", + "sha256:fa9e232dfa0c498bd0b8a3a73b8d8a31978304dcef0515adc859d4e096f96f4f" + ], + "markers": "sys_platform == 'linux'", + "version": "==0.7.1" + }, + "loguru": { + "hashes": [ + "sha256:b28e72ac7a98be3d28ad28570299a393dfcd32e5e3f6a353dec94675767b6319", + "sha256:f8087ac396b5ee5f67c963b495d615ebbceac2796379599820e324419d53667c" + ], + "markers": "python_version >= '3.5'", + "version": "==0.5.3" + }, + "notify-py": { + "hashes": [ + "sha256:8561c7d363eddad3b07be11405135e168c2f52e42bdbfc7f2e613b07a8e7bae0", + "sha256:9b9f689631ddba2ec1313fe4b4d19b8f1f032b38bbdc118b21cdd880c134e8a6" + ], + "index": "pypi", + "version": "==0.3.3" }, "sgmllib3k": { "hashes": [ diff --git a/README.md b/README.md index ec74eab..5eb100e 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,9 @@ Also requires at least Python `3.9`. * `animeDownloadDir` - base path where downloaded anime should be stored. *Without trailing slash*. Passed as download directory to transmission (`-w`) * `dirPerAnime` - whether to create one directory per anime. Created automatically as sub folder of `animeDownloadDir` -by replacing spaces in the anime name with underscores +by replacing spaces in the anime name with underscores (`true`/`false`) +* `notifications` - whether to send a notification, e.g. if transmission is not running or a new episode was added +(`true`/`false`) ###### Adjust `animes.json` * Add a Feed - it has to have an `ID` that's used in output. Freetext * Add the RSS URL to the feed, e.g. `https://subsplease.org/rss/?t&r=1080` for the RSS feed of the 1080p releases of the diff --git a/anime-rss.py b/anime-rss.py index 748e7d8..380cc44 100644 --- a/anime-rss.py +++ b/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)) diff --git a/config.json b/config.json index fdda36f..b729832 100644 --- a/config.json +++ b/config.json @@ -1,4 +1,5 @@ { "animeDownloadDir": "/media/ssd/temp", - "dirPerAnime": true + "dirPerAnime": true, + "notifications": true } \ No newline at end of file