avendesora / pythonbible

A python library for validating, parsing, normalizing scripture references and retrieving scripture texts (for open source and public domain versions)
https://docs.python.bible
MIT License
56 stars 11 forks source link

NEW_AMERICAN_STANDARD seems to be broken #158

Closed mpenning closed 1 month ago

mpenning commented 4 months ago

Hello,

Thank you for your work on this project! This is quite nice... I don't know if this is expected, but for some reason it just does not work...

import pythonbible as bible

reference = bible.NormalizedReference(bible.Book.GENESIS, 1, 1, 1, 31)
verse_ids = bible.convert_reference_to_verse_ids(reference)
for verse_id in verse_ids:
    verse = bible.get_verse_text(verse_id, version=bible.Version.NEW_AMERICAN_STANDARD)
    print(verse)

That throws the following error...

$ python bible.py
Traceback (most recent call last):
  File "/opt/python/virtualenv/py311_test/lib/python3.11/site-packages/pythonbible/bible/bibles.py", line 54, in get_bible
    return BIBLES[version][bible_type]
           ~~~~~~^^^^^^^^^
KeyError: <Version.NEW_AMERICAN_STANDARD: 'NASB'>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/mpenning/bible.py", line 7, in <module>
    verse = bible.get_verse_text(verse_id, version=bible.Version.NEW_AMERICAN_STANDARD)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/python/virtualenv/py311_test/lib/python3.11/site-packages/pythonbible/formatter.py", line 425, in get_verse_text
    bible = get_bible(version, "plain_text_readers")
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/python/virtualenv/py311_test/lib/python3.11/site-packages/pythonbible/bible/bibles.py", line 56, in get_bible
    raise MissingVerseFileError from error
pythonbible.errors.MissingVerseFileError
(py311_test) mpenning@mudslide:~$

If there is some reason that the verse for that version cannot be retrieved, it's better to make that clear (i.e. You must do foo to support bible.Version.NEW_AMERICAN_STANDARD). FWIW, you can retrieve quite a bit of the bible for free via biblegateway

avendesora commented 4 months ago

The pythonbible does not include the actual text of the New American Standard Bible due to copyright. As far as text that is bundled with the library, we only ever plan to include open source or public domain versions. Currently, we only have ASV and KJV, though we plan to add more. We also plan to make it easier for those who use the pythonbible library and obtain the proper permission from the copyright owner of another version to more easily integrate the pythonbible library with copyrighted versions within their own code, but we do not ever plan to bundle those versions within the library itself.

That said, your suggestion to make it more clear why a verse for a version cannot be retrieved is a very good suggestion, and we will work to make the error message in cases like this clear as to why that text is not included.

Thank you for your feedback and thank you for trying out and using the pythonbible library!

mpenning commented 4 months ago

The pythonbible does not include the actual text of the New American Standard Bible due to copyright.

That makes sense... but perhaps you'd consider opening up the API a bit to use more than on-disk references. For instance, you can use meaningless to retrieve passages assuming you have an internet connection available.

My perfect world is that your API would offer the ability to automatically:

I can build a PR to do this if you'd like...

Thoughts?

avendesora commented 4 months ago

To get content the right way from Bible Gateway, we would need to use their API (scraping the content would be a violation of their terms of service). Using the API requires authentication which requires having an account with Bible Gateway. (That's manageable but would require every pythonbible user to have that additional setup of an account if they wanted to use Bible Gateway.) We would also still be subject to the content and copyright restrictions however we obtained the data. Any use of copyrighted material beyond fair use would require obtaining a license from the copyright owner or risk legal issues. Fair use, in this case, being something like:

Material from the Site may be quoted in any form (written, visual, electronic or audio), up to and inclusive of two hundred fifty (250) verses or five hundred (500) words of non-biblical text without express written permission of the Zondervan, providing the verses do not amount to a complete book of the Bible nor do the verses quoted account for twenty-five (25) percent or more of the total text of the work in which they are quoted.

I decided from the very beginning of pythonbible to:

  1. Always strictly honor copyrights.
  2. Avoid, if at all possible, introducing any technical dependencies in the pythonbible library beyond the python standard library.

Either one of those, I think, would keep me from integrating with Bible Gateway. And the final nail would be the possibility that Bible Gateway might consider pythonbible to be a competing service, in which case pythonbible would not be able to access Bible Gateway at all according to their terms of service.

I very much understand why someone would want the functionality you are requesting, and there are python libraries out there for getting content from Bible Gateway (though I would recommend evaluating them to make sure they abide by the terms of service). Maybe a combination of one of those libraries along with pythonbible might provide what you want.