Updated dump template.
This will eventually be converted into a proper utility at some point.
This commit is contained in:
parent
b6164c7c57
commit
2747dfa3d2
1 changed files with 4 additions and 3 deletions
|
|
@ -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 = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue