Updated dump template.

This will eventually be converted into a proper utility at some point.
This commit is contained in:
Benjamin A. Shelton 2026-09-22 13:57:45 -06:00
commit 2747dfa3d2
Signed by: zancarius
GPG key ID: 8BD42DBD6C337E01

View file

@ -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 = {