scripts for my gemini capsule
biblestudy.py: new script!
| -rwxr-xr-x | biblestudy.py | 30 | ||||
| -rwxr-xr-x | lsv.py | 9 | ||||
| -rwxr-xr-x | oeb.py | 11 | ||||
| -rwxr-xr-x | webp.py | 15 |
4 files changed, 55 insertions, 10 deletions
diff --git a/biblestudy.py b/biblestudy.py new file mode 100755 index 0000000..57356eb --- /dev/null +++ b/biblestudy.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +# pip3 install bible-passage-reference-parser +from bible import parse_string +import os +import sys + +from lsv import printlsv +from oeb import printoeb +from webp import printwebp + +def main(qs): + if not qs: + print("10 Enter a scripture reference\r\n") + return + passages = parse_string(qs) + if type(passages[0]) == tuple: + print("51 " + str(passages[0][0]) + "'\r\n") + return + print("20 text/gemini\r\n") + print("# " + passages[0].format()) + # Attribution of minor citations for personal or non-commercial use can be provided as simply “LSV” or “Literal Standard Version.” Citations for commercial use, or distribution of the entire LSV Bible or entire book(s) of the LSV Bible, must be fully attributed and include both “Literal Standard Version (LSV)” and the name of our organization. + printlsv([passages[0]], False, passages[0].length() > 5) + printoeb([passages[0]], False, False) + printwebp([passages[0]], False, False) + + + +if __name__ == '__main__': + qs = os.getenv("QUERY_STRING") or (sys.argv[1] if len(sys.argv) >= 2 else '') + main(qs) @@ -26,9 +26,14 @@ def main(qs): print("51 " + str(passages[0][0]) + "'\r\n") return print("20 text/gemini\r\n") - print("=> https://www.lsvbible.com/p/get-lsv.html Literal Standard Version text from lsvbible.com (CC-BY-ND-NC)") + printlsv(passages) + +def printlsv(passages, title = True, plug=True): + if plug: + print("=> https://www.lsvbible.com/p/get-lsv.html Literal Standard Version text from lsvbible.com (CC-BY-SA)") for passage in passages: - print("# " + passage.format()) + if title: + print("# " + passage.format()) printing = False f = open('lsv.txt') startmark = passage.start.format('a')[0:3]+" "+passage.start.format('c:v') @@ -19,8 +19,12 @@ def main(qs): print("51 " + str(passages[0][0]) + "'\r\n") return print("20 text/gemini\r\n") - print('=> https://github.com/openenglishbible/Open-English-Bible This content from OpenEnglishBible (public domain)') - print('=> gemini://gemini.zachdecook.com/usfm2gmi/ and rendered with usfm2gmi') + printoeb(passages) + +def printoeb(passages, title=True,plug=True): + if plug: + print('=> https://github.com/openenglishbible/Open-English-Bible This content from OpenEnglishBible (public domain)') + print('=> gemini://gemini.zachdecook.com/usfm2gmi/ and rendered with usfm2gmi') for passage in passages: printing = 0 inendc = False @@ -30,7 +34,8 @@ def main(qs): # TODO: throw 51? print(f"{book} doesn't exist yet in the OEB\r\n") continue - print("# " + passage.format()) + if title: + print("# " + passage.format()) f = open(fname) startc = passage.start.chapter startv= passage.start.verse @@ -19,18 +19,23 @@ def main(qs): if not qs: print("10 Enter a scripture reference\r\n") return - books=subprocess.check_output([f"find", "webp/", "-name", f'??-*.usfm']).strip().split(b"\n") - books.sort() 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") - print('=>https://ebible.org/find/details.php?id=engwebp&all=1 This content from World English Bible (public domain)') - print('=> gemini://gemini.zachdecook.com/usfm2gmi/ and rendered with usfm2gmi') + printwebp(passages) + +def printwebp(passages, title=True, plug=True): + books=subprocess.check_output([f"find", "webp/", "-name", f'??-*.usfm']).strip().split(b"\n") + books.sort() + if plug: + print('=>https://ebible.org/find/details.php?id=engwebp&all=1 This content from World English Bible (public domain)') + print('=> gemini://gemini.zachdecook.com/usfm2gmi/ and rendered with usfm2gmi') for passage in passages: - print("# " + passage.format()) + if title: + print("# " + passage.format()) printing = 0 inendc = False bookn = passage.start.book |