1 files changed, 11 insertions, 2 deletions
diff --git a/bsb.py b/bsb.py
index 9dcae5c..6ebc516 100755
--- a/bsb.py
+++ b/bsb.py
@@ -20,6 +20,14 @@ def main(qs):
return
print("20 text/gemini\r\n")
printbsb(passages)
+
+def filename2book(filename):
+ parsed = parse_string(filename[:3])[1]
+ # It was an error. Return a bad index so this doesn't crash (yet)
+ if type(parsed) == tuple:
+ return -1
+ return parsed.start.book
+
def printbsb(passages, title=True, plug=True):
if plug:
print('=> https://berean.bible/ This content from Berean Standard Bible (public domain)')
@@ -27,8 +35,9 @@ def printbsb(passages, title=True, plug=True):
for passage in passages:
printing = 0
inendc = False
- books=sco(["ls", "bsb/"]).strip().split(b"\n")
- fname=b"bsb/"+books[passage.start.book - 1]
+ books=sco(["ls", "bsb/"]).decode('utf-8').strip().split("\n")
+ bookmap={filename2book(filename): filename for filename in books}
+ fname="bsb/"+bookmap[passage.start.book]
if title:
print("# " + passage.format())
f = open(fname)
|