Replace 'assert' statements with 'if/else' and other 'try/except' statements (fixes internetarchive#191)

As described in internetarchive#191, exceptions raised when `assert` fails may be bypassed when Python is run with specific flags. This code raises `ValueError`s, caught in the same places as before, but they are logged in the `openlibrary` log instead of silently ignored.