#!/usr/bin/env python3 import json import requests 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'], 'rut': ['ruth', 'rt'], '1sa': ['1 samuel', '1s', '1sam', '1 s', '1 sa', '1 sam', # Apocrypha '1 kingdoms', '1 realms', ], '2sa': ['2 samuel', '2s', '2sam', '2 s', '2 sa', '2 sam' # Apocrypha '2 kingdoms', '2 realms', ], '1ki': ['1 kings', '1k', '1kgs', '1king', '1 k', '1 ki', '1 kgs', '1 king' # Apocrypha '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' # Apocrypha '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': ['psalms', 'ps', 'psalm', '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'], # Apocrypha. 'tob': ['tobit', 'tb'], 'jdt': ['judith', 'jt'], 'wis': ['wisdom', 'wisdom of solomon', 'ws'], 'sir': ['sirach', 'sr'], 'bar': ['baruch', 'br'], 'bel': ['bel and the dragon', 'bl', 'bd'], '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'], # Not present in all LXX. 'lje': ['epistle of jeremy', 'ej'], 's3y': ['prayer of azarias', 'az'], 'man': ['prayer of manasses', 'prayer of manasseh', 'mana'], } aliases = {i: k for k, v in alias_map.items() for i in v} for k in alias_map.keys(): aliases[k] = k use_translations = [ "AAB", # Accessible Ancients Bible AAB "BSB", # Berean Standard Bible BSB "ENGWEBP", # World English Bible WEB "GHT", # Garth's Hyper-literal Translation GHT "eng_abt", # American Standard Version Byzantine Text ASVBT "eng_asv", # American Standard Version (1901) ASV #"eng_bbe", # Bible in Basic English BBE "eng_boy", # Updated Brenton English Septuagint UBES "eng_bre", # Brenton Septuagint Translation BST "eng_emtv", # English Majority Text Version EMTV #"eng_f35", # The New Testament with Commentary TNTC "eng_fbv", # Free Bible Version FBV "eng_glw", # God's Living Word GLW #"eng_gnv", # Geneva Bible 1599 GNV "eng_kja", # King James Version + Apocrypha KJVA "eng_kjv", # King James (Authorized) Version KJAV "eng_lsv", # Literal Standard Version LSV "eng_lxx", # LXX2012: Septuagint in American English 2012 LXXSA "eng_msb", # Majority Standard Bible MSB "eng_net", # NET Bible NETB "eng_pev", # Plain English Version PEV "eng_rv5", # Revised Version with Apocrypha (1895) RVA "eng_t4t", # Translation for Translators T4T "eng_tce", # Text-Critical English New Testament TCENT #"eng_tnt", # Tyndale New Testament TNT "eng_ulb", # Unlocked Literal Bible ULB "eng_w88", # Wycliffe Bible W88 "eng_wbs", # Noah Webster Bible NWB "eng_web", # World English Bible Classic WEBC "eng_webu", # World English Bible Updated WEBU "eng_wyc2017", # Wycliffe's Bible with Modern Spelling WBMS "eng_wyc2018", # Wycliffe's Bible with Modern Spelling (Enhanced) WBMSE "eng_ylt", # Young's Literal Translation YLT ] bookmeta = { 'gen': {'t': 'BSB'}, 'exo': {'t': 'BSB'}, 'lev': {'t': 'BSB'}, 'num': {'t': 'BSB'}, 'deu': {'t': 'BSB'}, 'jos': {'t': 'BSB'}, 'jdg': {'t': 'BSB'}, 'rut': {'t': 'BSB'}, '1sa': {'t': 'BSB'}, '2sa': {'t': 'BSB'}, '1ki': {'t': 'BSB'}, '2ki': {'t': 'BSB'}, '1ch': {'t': 'BSB'}, '2ch': {'t': 'BSB'}, 'ezr': {'t': 'BSB'}, 'neh': {'t': 'BSB'}, 'est': {'t': 'BSB'}, 'job': {'t': 'BSB'}, 'psa': {'t': 'BSB'}, 'pro': {'t': 'BSB'}, 'ecc': {'t': 'BSB'}, 'sng': {'t': 'BSB'}, 'isa': {'t': 'BSB'}, 'jer': {'t': 'BSB'}, 'lam': {'t': 'BSB'}, 'ezk': {'t': 'BSB'}, 'dan': {'t': 'BSB'}, 'hos': {'t': 'BSB'}, 'jol': {'t': 'BSB'}, 'amo': {'t': 'BSB'}, 'oba': {'t': 'BSB'}, 'jon': {'t': 'BSB'}, 'mic': {'t': 'BSB'}, 'nam': {'t': 'BSB'}, 'hab': {'t': 'BSB'}, 'zep': {'t': 'BSB'}, 'hag': {'t': 'BSB'}, 'zec': {'t': 'BSB'}, 'mal': {'t': 'BSB'}, 'mat': {'t': 'BSB'}, 'mrk': {'t': 'BSB'}, 'luk': {'t': 'BSB'}, 'jhn': {'t': 'BSB'}, 'act': {'t': 'BSB'}, 'rom': {'t': 'BSB'}, '1co': {'t': 'BSB'}, '2co': {'t': 'BSB'}, 'gal': {'t': 'BSB'}, 'eph': {'t': 'BSB'}, 'php': {'t': 'BSB'}, 'col': {'t': 'BSB'}, '1th': {'t': 'BSB'}, '2th': {'t': 'BSB'}, '1ti': {'t': 'BSB'}, '2ti': {'t': 'BSB'}, 'tit': {'t': 'BSB'}, 'phm': {'t': 'BSB'}, 'heb': {'t': 'BSB'}, 'jas': {'t': 'BSB'}, '1pe': {'t': 'BSB'}, '2pe': {'t': 'BSB'}, '1jn': {'t': 'BSB'}, '2jn': {'t': 'BSB'}, '3jn': {'t': 'BSB'}, 'jud': {'t': 'BSB'}, 'rev': {'t': 'BSB'}, # Apocrypha. 'tob': {'t': 'eng_lxx'}, 'jdt': {'t': 'eng_lxx'}, 'wis': {'t': 'eng_lxx'}, 'sir': {'t': 'eng_lxx'}, 'bar': {'t': 'eng_lxx'}, 'bel': {'t': 'eng_lxx'}, 'sus': {'t': 'eng_lxx'}, '1ma': {'t': 'eng_lxx'}, '2ma': {'t': 'eng_lxx'}, '3ma': {'t': 'eng_lxx'}, '4ma': {'t': 'eng_lxx'}, '1es': {'t': 'eng_lxx'}, # Not present in all LXX. 'lje': {'t': 'eng_lxx'}, 's3y': {'t': 'eng_lxx'}, 'man': {'t': 'eng_lxx'}, } def get_translations(): req = requests.get("https://bible.helloao.org/api/available_translations.json") t = req.json() return [x for x in filter(lambda x: "language" in x and x["language"] == "eng", t["translations"])] def filter_translations(t=None): tx = [] if t is None: t = get_translations() for translation in t: if "id" in translation and translation["id"] in use_translations: tx.append(translation) return {x["id"]: x for x in tx} def get_translation_meta(t): req = requests.get(f"https://bible.helloao.org{t["listOfBooksApiLink"]}") return req.json() def write_meta(file="meta.js"): with open(file, 'wb') as fp: fp.write(b"// Translation meta\n\n") fp.write(f"export const aliases = {json.dumps(aliases)};\n\n".encode("utf8")) fp.write(f"export const translations = {json.dumps(use_translations)};\n\n".encode("utf8")) fp.write(f"export const meta = {json.dumps(bookmeta)};\n".encode("utf8")) if __name__ == "__main__": pass