scripts for my gemini capsule
bible: add tcgnt
| -rwxr-xr-x | biblestudy.py | 3 | ||||
| -rw-r--r-- | getscriptures.sh | 7 | ||||
| -rwxr-xr-x | tcgnt.py | 59 |
3 files changed, 69 insertions, 0 deletions
diff --git a/biblestudy.py b/biblestudy.py index d1061b1..b3c8a54 100755 --- a/biblestudy.py +++ b/biblestudy.py @@ -8,6 +8,7 @@ from lsv import printlsv from oeb import printoeb from webp import printwebp from bsb import printbsb +from tcgnt import printtcgnt def main(qs): if not qs: @@ -25,6 +26,8 @@ def main(qs): printoeb([passages[0]], False, False) printwebp([passages[0]], False, False) printwebp([passages[0]], False, False, printStrongs=True) + printtcgnt([passages[0]], False, False) + printtcgnt([passages[0]], False, False, printStrongs=True) diff --git a/getscriptures.sh b/getscriptures.sh index dcd38e3..1d0f843 100644 --- a/getscriptures.sh +++ b/getscriptures.sh @@ -5,6 +5,12 @@ getweb() { unzip engwebp_usfm.zip -d webp rm engwebp_usfm.zip } +gettcgnt() { + wget https://ebible.org/Scriptures/grctcgnt_usfm.zip + mkdir -p tcgnt + unzip grctcgnt_usfm.zip -d tcgnt + rm grctcgnt_usfm.zip +} getlsv() { url="$(wget -O - https://www.lsvbible.com/p/get-lsv.html | grep Plain\ Text | grep -o 'https://[^"]*' | sed 's/amp;//g')" wget -O lsv.zip "$url" @@ -21,3 +27,4 @@ getbsb() { test -d webp || getweb test -f lsv.txt || getlsv test -d bsb || getbsb +test -d tcgnt || gettcgnt diff --git a/tcgnt.py b/tcgnt.py new file mode 100755 index 0000000..3349ec0 --- /dev/null +++ b/tcgnt.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 +# pip3 install bible-passage-reference-parser +from bible import parse_string +import usfm2gmi.usfm2gmi as usfm2gmi +import os +import sys +import subprocess +from webp import printf +from webp import eprint + +def main(qs): + if not qs: + print("10 Enter a scripture reference\r\n") + return + passages = parse_string(qs) + # TODO: Also handle "john 3, tomato 2" errors? + if type(passages[0]) == tuple: + print("51 " + str(passages[0][0]) + "'\r\n") + return + print("20 text/gemini\r\n") + printtcgnt(passages) + +def printtcgnt(passages, title=True, plug=True, printStrongs=False): + books=subprocess.check_output([f"find", "tcgnt/", "-name", f'??-*.usfm']).strip().split(b"\n") + books.sort() + if plug: + print('=>https://ebible.org/find/details.php?id=grctcgnt This content from Text-Critical Greek NT (public domain)') + print('=> gemini://gemini.zachdecook.com/usfm2gmi/ and rendered with usfm2gmi') + for passage in passages: + if title: + print("# " + passage.format()) + printing = 0 + inendc = False + bookn = passage.start.book + #eprint(bookn) + f = open(books[bookn-38]) + startc = passage.start.chapter + startv= passage.start.verse + endc = passage.end.chapter + endv= passage.end.verse + for line in f: + if f'\\c ' in line and f' {startc} ' in line: + printing = 1 + if printing == 1 and (f'\\v {startv} ') in line: + printing =2 + if f'\\c ' in line and f' {endc} ' in line: + inendc = True + if inendc and (f'\\v {endv+1} ') in line: + printing =0 + if f'\\c ' in line and f' {endc+1} ' in line: + printing =0 + + if printing>=2: + printf(line, printStrongs) + print('(T-C GNT)') #end in newline + +if __name__ == '__main__': + qs = os.getenv("QUERY_STRING") or (sys.argv[1] if len(sys.argv) >= 2 else '') + main(qs) |