import json import os #d = json.loads(open("../bsb.json").read()) d = json.loads(open("../kjv.json").read()) with open("meta.json", "wb") as fp: fp.write(json.dumps(d["translation"]).encode("utf8")) b = d["books"] for book in b: ch = 1 basepath = os.path.abspath(os.path.join(".", book["id"])) if not os.path.exists(basepath): 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.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 = { "gen": [ "Genesis", "gn" ], "exo": [ "Exodus", "ex" ], "lev": [ "Leviticus", "lv" ], "num": [ "Numbers", "nm", "numb", "nmb", "nmbs" ], "deu": [ "Deuteronomy", "dt", "deut", "deuter" ], "jos": [ "Joshua", "js", "josh" ], "jdg": [ "Judges", "jd", "jdgs", "judg", "judgs", "judge" ], "rut": [ "Ruth", "rt" ], "1sa": [ "1 Samuel", "1s", "1sam", "1 s", "1 sa", "1 sam", "1 Kingdoms", "1 Realms" ], "2sa": [ "2 Samuel", "2s", "2sam", "2 s", "2 sa", "2 sam", "2 Kingdoms", "2 Realms" ], "1ki": [ "1 Kings", "1k", "1kgs", "1king", "1 k", "1 ki", "1 kgs", "1 king", "3k", "3kgs", "3king", "3 k", "3 ki", "3 kgs", "3 king", "3 Kingdoms", "3 Realms" ], "2ki": [ "2 Kings", "2k", "2kgs", "2king", "2 k", "2 ki", "2 kgs", "2 king", "4k", "4kgs", "4king", "4 k", "4 ki", "4 kgs", "4 king", "4 Kingdoms", "4 Realms" ], "1ch": [ "1 Chronicles", "1c", "1chr", "1chron", "1 c", "1 ch", "1 chr", "1 chron" ], "2ch": [ "2 Chronicles", "2c", "2chr", "2chron", "2 c", "2 ch", "2 chr", "2 chron" ], "ezr": [ "Ezra", "ez" ], "neh": [ "Nehemiah", "nh" ], "est": [ "Esther", "es" ], "job": [ "Job", "jb" ], "psa": [ "Psalm", "ps", "psalms", "pss" ], "pro": [ "Proverbs", "pr", "prov" ], "ecc": [ "Ecclesiastes", "ec", "eccl", "eccle" ], "sng": [ "Song of Solomon", "song of songs", "sn", "son", "song", "sol" ], "isa": [ "Isaiah", "is", "isai" ], "jer": [ "Jeremiah", "jr", "jere", "jerem" ], "lam": [ "Lamentations", "lm", "lamen" ], "ezk": [ "Ezekiel", "eze", "ezek" ], "dan": [ "Daniel", "dn" ], "hos": [ "Hosea", "hs" ], "jol": [ "Joel", "jl" ], "amo": [ "Amos", "am" ], "oba": [ "Obadiah", "ob", "obd", "obad" ], "jon": [ "Jonah", "jo" ], "mic": [ "Micah", "micha", "mc" ], "nam": [ "Nahum", "na" ], "hab": [ "Habakkuk", "hb", "haba", "habak" ], "zep": [ "Zephaniah", "zf", "zef" ], "hag": [ "Haggai", "hg" ], "zec": [ "Zechariah", "ze", "zech" ], "mal": [ "Malachi", "ml", "mala" ], "mat": [ "Matthew", "mt", "matt" ], "mrk": [ "Mark", "mk" ], "luk": [ "Luke", "lk" ], "jhn": [ "John", "jn" ], "act": [ "Acts", "ac" ], "rom": [ "Romans", "rm", "rms" ], "1co": [ "1 Corinthians", "1cor", "1corin", "1 co", "1 cor", "1 corin" ], "2co": [ "2 Corinthians", "2cor", "2corin", "2 co", "2 cor", "2 corin" ], "gal": [ "Galatians", "gl" ], "eph": [ "Ephesians", "ep", "ef" ], "php": [ "Philippians", "ph", "phil" ], "col": [ "Colossians", "cl", "colo" ], "1th": [ "1 Thessalonians", "1thes", "1thess", "1 thes", "1 thess" ], "2th": [ "2 Thessalonians", "2thes", "2thess", "2 thes", "2 thess" ], "1ti": [ "1 Timothy", "1tim", "1 ti", "1 tim" ], "2ti": [ "2 Timothy", "2tim", "2 ti", "2 tim" ], "tit": [ "Titus", "ti" ], "phm": [ "Philemon", "pi", "philm", "philem" ], "heb": [ "Hebrews", "he" ], "jas": [ "James", "ja", "jam" ], "1pe": [ "1 Peter", "1p", "1pt", "1pet", "1 p", "1 pe", "1 pt", "1 pet" ], "2pe": [ "2 Peter", "2p", "2pt", "2pet", "2 p", "2 pe", "2 pt", "2 pet" ], "1jn": [ "1 John", "1jon", "1 jn", "1 jon" ], "2jn": [ "2 John", "2jon", "2 jn", "2 jon" ], "3jn": [ "3 John", "3jon", "3 jn", "3 jon" ], "jud": [ "Jude", "ju" ], "rev": [ "Revelation", "rv", "reve" ], "tob": [ "Tobit", "tb" ], "jdt": [ "Judith", "jt" ], "wis": [ "Wisdom", "wisdom of solomon", "ws", "wos" ], "sir": [ "Sirach", "sr" ], "bar": [ "Baruch", "br" ], "bel": [ "Bel and the Dragon", "bl", "bd", "batd" ], "sus": [ "Susanna", "su" ], "1ma": [ "1 Maccabees", "1mac", "1 mac" ], "2ma": [ "2 Maccabees", "2mac", "2 mac" ], "3ma": [ "3 Maccabees", "3mac", "3 mac" ], "4ma": [ "4 Maccabees", "4mac", "4 mac" ], "1es": [ "1 Esdras", "1esd", "1 esd" ], "lje": [ "Epistle of Jeremy", "ej", "eoj" ], "s3y": [ "Prayer of Ezarias", "az", "poe" ], "man": [ "Prayer of Manasses", "prayer of manasseh", "mana", "pom" ] } aliases = {i.lower(): k for k, v in alias_map.items() for i in v} for k in alias_map.keys(): aliases[k] = k