1
0

Add arg parsing, fix some warnings

Signed-off-by: MK13 <marius@kleberonline.de>
This commit is contained in:
2021-01-15 23:43:11 +01:00
parent cdd177d331
commit c17299355d
2 changed files with 10 additions and 7 deletions

View File

@@ -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))

View File

@@ -18,7 +18,7 @@
},
{
"Title": "Ore dake Haireru Kakushi Dungeon",
"Local": "01"
"Local": "02"
},
{
"Title": "Tensei Shitara Slime Datta Ken",