about summary refs log tree commit diff
diff options
context:
space:
mode:
-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)