diff --git a/utils/dump.py b/utils/dump.py index 6627078..dab5507 100644 --- a/utils/dump.py +++ b/utils/dump.py @@ -1,5 +1,5 @@ -d = json.loads(open("complete.json").read()) +d = json.loads(open("../bsb.json").read()) with open("meta.json", "wb") as fp: fp.write(json.dumps(d["translation"]).encode("utf8")) @@ -10,14 +10,15 @@ for book in b: ch = 1 basepath = os.path.abspath(os.path.join(".", book["id"])) if not os.path.exists(basepath): - os.mkdir(basepath, True) + os.makedirs(basepath, exist_ok=True) with open(os.path.join(basepath, "meta.json"), "wb") as fp: fp.write(json.dumps({k: v for k, v in book.items() if k != "chapters"}).encode("utf8")) for chapter in book["chapters"]: if not os.path.exists(os.path.join(basepath, str(ch))): - os.mkdir(os.path.join(basepath, str(ch)), True) + os.makedirs(os.path.join(basepath, str(ch)), exist_ok=True) with open(os.path.join(basepath, str(ch), "chapter.json"), "wb") as fp: fp.write(json.dumps({k: v for k, v in chapter.items()}).encode("utf8")) + ch += 1 alias_map = {