From efa8da19ff10fc8dfa250c7d75dd80ec2853777c Mon Sep 17 00:00:00 2001 From: eric Date: Fri, 27 Jan 2012 21:44:02 -0500 Subject: [PATCH] pass isbn to add_by_googlebooks_id to address occasional missing isbns --- core/bookloader.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/core/bookloader.py b/core/bookloader.py index 4f603fcd..1806e0f5 100755 --- a/core/bookloader.py +++ b/core/bookloader.py @@ -105,7 +105,7 @@ def add_by_isbn_from_google(isbn, work=None): return None try: - return add_by_googlebooks_id(results['items'][0]['id'], work=work, results=results['items'][0]) + return add_by_googlebooks_id(results['items'][0]['id'], work=work, results=results['items'][0], isbn=isbn) except LookupFailure, e: logger.exception("failed to add edition for %s", isbn) except IntegrityError, e: @@ -127,10 +127,10 @@ def get_edition_by_id(type,value): return None -def add_by_googlebooks_id(googlebooks_id, work=None, results=None): +def add_by_googlebooks_id(googlebooks_id, work=None, results=None, isbn=None): """add a book to the UnglueIt database based on the GoogleBooks ID. The work parameter is optional, and if not supplied the edition will be - associated with a stub work. + associated with a stub work. isbn can be passed because sometimes passed data won't include it """ # don't ping google again if we already know about the edition @@ -155,12 +155,13 @@ def add_by_googlebooks_id(googlebooks_id, work=None, results=None): logger.info("not connecting %s since it is %s instead of %s" % (googlebooks_id, language, work.language)) work = None - isbn = None - for i in d.get('industryIdentifiers', []): - if i['type'] == 'ISBN_10' and not isbn: - isbn = regluit.core.isbn.convert_10_to_13(i['identifier']) - elif i['type'] == 'ISBN_13': - isbn = i['identifier'] + # isbn = None + if not isbn: + for i in d.get('industryIdentifiers', []): + if i['type'] == 'ISBN_10' and not isbn: + isbn = regluit.core.isbn.convert_10_to_13(i['identifier']) + elif i['type'] == 'ISBN_13': + isbn = i['identifier'] # now check to see if there's an existing Work if isbn and not work: