From 6bde560fcb4a306be299aef45d38b2c73b1ac75d Mon Sep 17 00:00:00 2001 From: MK13 Date: Fri, 15 Jan 2021 01:20:59 +0100 Subject: [PATCH] Initial commit Signed-off-by: MK13 --- Pipfile | 14 +++++++++ Pipfile.lock | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++ anime-rss.py | 38 ++++++++++++++++++++++ config.json | 4 +++ shows.json | 54 +++++++++++++++++++++++++++++++ 5 files changed, 199 insertions(+) create mode 100644 Pipfile create mode 100644 Pipfile.lock create mode 100644 anime-rss.py create mode 100644 config.json create mode 100644 shows.json diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..e6f6468 --- /dev/null +++ b/Pipfile @@ -0,0 +1,14 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +feedparser = "*" +requests = "*" + +[dev-packages] +feedparser = "*" + +[requires] +python_version = "3.9" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..582ec8f --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,89 @@ +{ + "_meta": { + "hash": { + "sha256": "5e804f6b937bc93ae43005796f582b8623bef4948d44f7569068b9e24783e880" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.9" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "certifi": { + "hashes": [ + "sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c", + "sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830" + ], + "version": "==2020.12.5" + }, + "chardet": { + "hashes": [ + "sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa", + "sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", + "version": "==4.0.0" + }, + "feedparser": { + "hashes": [ + "sha256:1b00a105425f492f3954fd346e5b524ca9cef3a4bbf95b8809470e9857aa1074", + "sha256:f596c4b34fb3e2dc7e6ac3a8191603841e8d5d267210064e94d4238737452ddd" + ], + "index": "pypi", + "version": "==6.0.2" + }, + "idna": { + "hashes": [ + "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6", + "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==2.10" + }, + "requests": { + "hashes": [ + "sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804", + "sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e" + ], + "index": "pypi", + "version": "==2.25.1" + }, + "sgmllib3k": { + "hashes": [ + "sha256:7868fb1c8bfa764c1ac563d3cf369c381d1325d36124933a726f29fcdaa812e9" + ], + "version": "==1.0.0" + }, + "urllib3": { + "hashes": [ + "sha256:19188f96923873c92ccb987120ec4acaa12f0461fa9ce5d3d0772bc965a39e08", + "sha256:d8ff90d979214d7b4f8ce956e80f4028fc6860e4431f731ea4a8c08f23f99473" + ], + "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.2" + } + }, + "develop": { + "feedparser": { + "hashes": [ + "sha256:1b00a105425f492f3954fd346e5b524ca9cef3a4bbf95b8809470e9857aa1074", + "sha256:f596c4b34fb3e2dc7e6ac3a8191603841e8d5d267210064e94d4238737452ddd" + ], + "index": "pypi", + "version": "==6.0.2" + }, + "sgmllib3k": { + "hashes": [ + "sha256:7868fb1c8bfa764c1ac563d3cf369c381d1325d36124933a726f29fcdaa812e9" + ], + "version": "==1.0.0" + } + } +} diff --git a/anime-rss.py b/anime-rss.py new file mode 100644 index 0000000..2ef6b15 --- /dev/null +++ b/anime-rss.py @@ -0,0 +1,38 @@ +import feedparser +import json +import re +import subprocess + +feeds = [] +config = [] + +with open("shows.json", "r") as feeds: + feeds = json.load(feeds) + +with open("config.json", "r") as config: + config = json.load(config) + +for feed in feeds["Feeds"]: + print("Checking feed: " + feed["URL"]) + NewsFeed = feedparser.parse(feed["URL"]) + + for show in feed["Shows"]: + print("Checking show: " + show["Title"]) + + for entry in NewsFeed.entries: + if show["Title"] in entry.title: + regex = feed["Episode-Regex"].replace("$SHOWS$", show["Title"]) + match = re.match(regex, entry.title) + + if match: + episodeNumber = match.groups() + + if int(episodeNumber[0]) > int(show["Local"]): + print("NEW NEW NEW " + show["Title"] + episodeNumber[0]) + + subprocess.run(["transmission-remote", "-a", entry.link, "-w", config["showDownloadDir"]]) + + show["Local"] = str(int(show["Local"]) + 1).zfill(2) + +with open("shows.json", "w") as new_feeds: + new_feeds.write(json.dumps(feeds, indent=3)) diff --git a/config.json b/config.json new file mode 100644 index 0000000..18fed1c --- /dev/null +++ b/config.json @@ -0,0 +1,4 @@ +{ + "torrentDownloadDir": "/media/ssd/temp/torrents", + "showDownloadDir": "/media/ssd/temp/" +} \ No newline at end of file diff --git a/shows.json b/shows.json new file mode 100644 index 0000000..6269e13 --- /dev/null +++ b/shows.json @@ -0,0 +1,54 @@ +{ + "Feeds": [ + { + "URL": "https://subsplease.org/rss/?t&r=1080", + "Shows": [ + { + "Title": "Go-toubun no Hanayome S2", + "Local": "02" + }, + { + "Title": "Jaku-Chara Tomozaki-kun", + "Local": "01" + }, + { + "Title": "Mushoku Tensei", + "Local": "01" + }, + { + "Title": "Ore dake Haireru Kakushi Dungeon", + "Local": "01" + }, + { + "Title": "Tensei Shitara Slime Datta Ken", + "Local": "25" + }, + { + "Title": "Wonder Egg Priority", + "Local": "01" + } + ], + "Episode-Regex": "\\[SubsPlease\\] $SHOWS$ - (\\d{2,2}) \\(1080p\\) \\[[A-Z0-9]{8,8}\\].mkv" + }, + { + "URL": "https://nyaa.si/?page=rss&q=%5Bjackie%5D+Kaifuku+Jutsushi+no+Yarinaoshi+-&c=0_0&f=0", + "Shows": [ + { + "Title": "Kaifuku Jutsushi no Yarinaoshi", + "Local": "01" + } + ], + "Episode-Regex": "\\[jackie\\] $SHOWS$ - (\\d{2,2}) \\[720p x264 AAC\\]\\[[A-Z0-9]{8,8}\\].mkv \\(Uncensored\\)" + }, + { + "URL": "https://nyaa.si/?page=rss&q=%5BDameDesuYo%5D+Shingeki+no+Kyojin+%28The+Final+Season%29+-+&c=0_0&f=0", + "Shows": [ + { + "Title": "Shingeki no Kyojin", + "Local": "64" + } + ], + "Episode-Regex": "\\[DameDesuYo\\] $SHOWS$ \\(The Final Season\\) - (\\d{2,2})v0 \\(1920x1080 10bit AAC\\) \\[[A-Z0-9]{8,8}\\].mkv" + } + ] +} \ No newline at end of file