Add arg parsing, fix some warnings
Signed-off-by: MK13 <marius@kleberonline.de>
This commit is contained in:
15
anime-rss.py
15
anime-rss.py
@@ -2,6 +2,7 @@ import feedparser
|
||||
import json
|
||||
import re
|
||||
import subprocess
|
||||
import argparse
|
||||
|
||||
feedparser.USER_AGENT = "anime-rss/1.0"
|
||||
|
||||
@@ -14,21 +15,23 @@ GREEN = CSI + "92;49m"
|
||||
BOLD_RED = BOLD + RED
|
||||
BOLD_GREEN = BOLD + GREEN
|
||||
|
||||
feeds = []
|
||||
config = []
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("c", help="path to the config.json file", type=str, default="config.json", nargs='?')
|
||||
parser.add_argument("a", help="path to the animes.json file", type=str, default="animes.json", nargs='?')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
def build_target_folder():
|
||||
if config["dirPerAnime"]:
|
||||
return config["animeDownloadDir"] + "/" + anime["Title"].replace(" ", "_");
|
||||
return config["animeDownloadDir"] + "/" + anime["Title"].replace(" ", "_")
|
||||
else:
|
||||
return config["animeDownloadDir"]
|
||||
|
||||
|
||||
with open("animes.json", "r") as feeds:
|
||||
with open(args.a, "r") as feeds:
|
||||
feeds = json.load(feeds)
|
||||
|
||||
with open("config.json", "r") as config:
|
||||
with open(args.c, "r") as config:
|
||||
config = json.load(config)
|
||||
|
||||
for feed in feeds["Feeds"]:
|
||||
@@ -53,5 +56,5 @@ for feed in feeds["Feeds"]:
|
||||
|
||||
anime["Local"] = str(int(anime["Local"]) + 1).zfill(2)
|
||||
|
||||
with open("animes.json", "w") as new_feeds:
|
||||
with open(args.a, "w") as new_feeds:
|
||||
new_feeds.write(json.dumps(feeds, indent=3))
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
},
|
||||
{
|
||||
"Title": "Ore dake Haireru Kakushi Dungeon",
|
||||
"Local": "01"
|
||||
"Local": "02"
|
||||
},
|
||||
{
|
||||
"Title": "Tensei Shitara Slime Datta Ken",
|
||||
|
||||
Reference in New Issue
Block a user