Skip to content

Commit

Permalink
add consistency check
Browse files Browse the repository at this point in the history
  • Loading branch information
xlcnd committed Apr 21, 2015
1 parent 90aaac3 commit 333ba6a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions isbnlib/_goob.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

UA = 'isbnlib (gzip)'
SERVICE_URL = 'https://www.googleapis.com/books/v1/volumes?q=isbn+{isbn}'\
'&fields=items/volumeInfo(title,authors,publisher,publishedDate,language)'\
'&maxResults=1'
'&fields=items/volumeInfo(title,authors,publisher,publishedDate,language,'\
'industryIdentifiers)&maxResults=1'
LOGGER = logging.getLogger(__name__)


Expand Down Expand Up @@ -43,7 +43,12 @@ def _records(isbn, data):
try:
# put the selected data in records
records = data['items'][0]['volumeInfo']
except: # pragma: no cover
# consistency check (isbn request = isbn response)
ids = records.get('industryIdentifiers', '')
if isbn not in repr(ids): # pragma: no cover
LOGGER.warning('Possible not consistent data for %s (%s)',
isbn, repr(ids))
except: # pragma: no cover
try:
extra = data['stat']
LOGGER.debug('DataWrongShapeError for %s with data %s',
Expand Down

0 comments on commit 333ba6a

Please sign in to comment.