scripts for my gemini capsule
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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)