about summary refs log tree commit diff
path: root/lsv.py
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2021-02-27 22:00:46 -0500
committerZach DeCook <zachdecook@librem.one>2021-02-27 22:03:19 -0500
commit9313d9755690c49901153897f61b981a95aee33b (patch)
treedd32ec0b5353357ee5dcea3183d8029be8f14172 /lsv.py
parent87e55508ab3abe19e4e7dac85c0800df9bd4717e (diff)
downloadcgi-bin-9313d9755690c49901153897f61b981a95aee33b.tar.gz
lsv: Add script to get this text
Diffstat (limited to 'lsv.py')
-rwxr-xr-xlsv.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/lsv.py b/lsv.py
new file mode 100755
index 0000000..2e66ea2
--- /dev/null
+++ b/lsv.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python3
+# pip3 install bible-passage-reference-parser
+from bible import parse_string
+import os
+import sys
+
+def printf(line):
+  if line:
+    print(' '.join(line.split(' ')[2:]),end= ' ')
+  else:
+    print('')
+
+def eprint(*args, **kwargs):
+    print(*args, file=sys.stderr, **kwargs)
+
+def main(qs):
+  if not qs:
+    print("10 Enter a scripture reference\r\n")
+    return
+
+  passages = parse_string(qs)
+  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)")
+  for passage in passages:
+    print("# " + passage.format())
+    printing = False
+    f = open('lsv.txt')
+    startmark = passage.start.format('a c:v')
+    eprint(startmark)
+    endmark = passage.end.format('a c:v')
+    for line in f:
+      if startmark in line:
+        printing = True
+      elif endmark in line:
+        printf(line)
+        printing = False
+      if printing:
+        printf(line)
+
+if __name__ == '__main__':
+  qs = os.getenv("QUERY_STRING") or (sys.argv[1] if len(sys.argv) >= 2 else '')
+  main(qs)