xlcnd / isbnlib

python library to validate, clean, transform and get metadata of ISBN strings (for devs).
Other
229 stars 30 forks source link

ISBNNotConsistentError #142

Open VBobCat opened 5 months ago

VBobCat commented 5 months ago

Code that raises the exception:

import isbnlib

data = isbnlib.meta('9780521614030', 'goob')

Exception traceback:

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2023.2\plugins\python\helpers\pydev\pydevconsole.py", line 364, in runcode
    coro = func()
           ^^^^^^
  File "<input>", line 1, in <module>
  File "F:\.venv\Lib\site-packages\isbnlib\_ext.py", line 25, in meta
    return query(isbn, service) if isbn else {}
           ^^^^^^^^^^^^^^^^^^^^
  File "F:\.venv\Lib\site-packages\isbnlib\dev\_decorators.py", line 27, in memoized_func
    value = func(*args, **kwargs)
            ^^^^^^^^^^^^^^^^^^^^^
  File "F:\.venv\Lib\site-packages\isbnlib\_metadata.py", line 33, in query
    meta = services[service](isbn)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\.venv\Lib\site-packages\isbnlib\_goob.py", line 79, in query
    return _records(isbn, data)
           ^^^^^^^^^^^^^^^^^^^^
  File "F:\.venv\Lib\site-packages\isbnlib\_goob.py", line 60, in _records
    raise ISBNNotConsistentError('{0} not in {1}'.format(
isbnlib.dev._exceptions.ISBNNotConsistentError: isbn request != isbn response (9780521614030 not in [{'type': 'ISBN_10', 'identifier': '0521693764'}, {'type': 'ISBN_13', 'identifier': '9780521693769'}])

Data returned from google books (got it in breakpoint):

{
    "title": "Advanced grammar in use",
    "subtitle": "a self-study reference and practice book for advanced students of English : with answers",
    "authors": [
        "Martin Hewings"
    ],
    "publisher": "Cambridge University Press",
    "publishedDate": "2005",
    "description": "\"The book provides coverage of those language areas advanced-level students will find most rewarding to study. ... Two-page units present grammar explanation and examples, including typical student mistakes. ... A study guide helps students find those areas most appropriate for their study. Grammar areas are cross-referenced throughout the book. There are useful appendices dealing with verb forms, and a glossary and all answers are given at the back of the book. ... Extra practice is available on a new interactive CD-ROM to accompany the book.\"--Publisher.",
    "industryIdentifiers": [
        {
            "type": "ISBN_10",
            "identifier": "0521693764"
        },
        {
            "type": "ISBN_13",
            "identifier": "9780521693769"
        }
    ],
    "imageLinks": {
        "smallThumbnail": "http://books.google.com/books/content?id=8wOOE1CeXyYC&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api",
        "thumbnail": "http://books.google.com/books/content?id=8wOOE1CeXyYC&printsec=frontcover&img=1&zoom=1&edge=curl&source=gbs_api"
    },
    "language": "en"
}