scripts for my gemini capsule
biblestudy: add hboWLC
Zach DeCook 2023-12-11
parent c07fe9c · commit 6e07db4
-rw-r--r--.gitignore2
m---------Open-English-Bible0
-rwxr-xr-xbiblestudy.py4
-rw-r--r--getscriptures.sh7
-rwxr-xr-xhboWLC.py61
m---------usfm2gmi0
6 files changed, 73 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index e786896..aca85cb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,5 @@ __pycache__
webp
lsv.txt
bsb
+tcgnt
+hboWLC
diff --git a/Open-English-Bible b/Open-English-Bible
-Subproject 7a6ba3802d9d1281a4e330892ffdac226208518
+Subproject 2370ba8b161fff645b22a9501c33ba7a603c62c
diff --git a/biblestudy.py b/biblestudy.py
index 71cea74..65f55e2 100755
--- a/biblestudy.py
+++ b/biblestudy.py
@@ -9,6 +9,7 @@ from oeb import printoeb
from webp import printwebp
from bsb import printbsb
from tcgnt import printtcgnt
+from hboWLC import printhboWLC
def main(qs):
if not qs:
@@ -29,7 +30,8 @@ def main(qs):
print()
printtcgnt([passages[0]], False, False)
printtcgnt([passages[0]], False, False, printStrongs=True)
-
+ printhboWLC([passages[0]], False, False)
+ printhboWLC([passages[0]], False, False, printStrongs=True)
diff --git a/getscriptures.sh b/getscriptures.sh
index 1d0f843..2c1e8e8 100644
--- a/getscriptures.sh
+++ b/getscriptures.sh
@@ -11,6 +11,12 @@ gettcgnt() {
unzip grctcgnt_usfm.zip -d tcgnt
rm grctcgnt_usfm.zip
}
+gethboWLC() {
+ wget https://ebible.org/Scriptures/hboWLC_usfm.zip
+ mkdir -p hboWLC
+ unzip hboWLC_usfm.zip -d hboWLC
+ rm hboWLC_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"
@@ -28,3 +34,4 @@ test -d webp || getweb
test -f lsv.txt || getlsv
test -d bsb || getbsb
test -d tcgnt || gettcgnt
+test -d hboWLC || gethboWLC
diff --git a/hboWLC.py b/hboWLC.py
new file mode 100755
index 0000000..ecdb9e1
--- /dev/null
+++ b/hboWLC.py
@@ -0,0 +1,61 @@
+#!/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")
+ printhboWLC(passages)
+
+def printhboWLC(passages, title=True, plug=True, printStrongs=False):
+ books=subprocess.check_output([f"find", "hboWLC/", "-name", f'??-*.usfm']).strip().split(b"\n")
+ books.sort()
+ if plug:
+ print('=>https://ebible.org/find/details.php?id=grctcgnt This content from Westminster Leningrad Codex Hebrew OT (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)
+ if bookn > 66-27:
+ return
+ f = open(books[bookn-1])
+ 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('(hboWLC)') #end in newline
+
+if __name__ == '__main__':
+ qs = os.getenv("QUERY_STRING") or (sys.argv[1] if len(sys.argv) >= 2 else '')
+ main(qs)
diff --git a/usfm2gmi b/usfm2gmi
-Subproject 55ed7b33bb8f11aafe68167e310b8df7b6b0641
+Subproject a9e497dbee245754bceed9bc773485309986845