def get_book_title(isbn): if not amazon.is_valid_isbn(some_isbn): return some_isbn + " is not a valid ISBN" isbn10, isbn13 = isbn.fix_isbn(some_isbn) book_info = get_book_info(isbn10) return book_info['title']
def get_book_info(some_isbn): if not amazon.is_valid_isbn(some_isbn): return some_isbn + " is not a valid ISBN" isbn10, isbn13 = isbn.fix_isbn(some_isbn) url = 'https://openlibrary.org/api/books?jscmd=data&bibkeys=ISBN:' + isbn10 response = urllib2.urlopen(url) json_object = json.loads(response.read()) return json_object
def get_book_info(some_isbn): if not amazon.is_valid_isbn(some_isbn): return some_isbn + " is not a valid ISBN" isbn10, isbn13 = amazon.fix_isbn(some_isbn) url = "http://isbndb.com/api/v2/json/" + ISBNDB_ACCOUNT_NUMBER + "/book/" + isbn13 response = urllib2.urlopen(url) book_info = json.loads(response.read()) return book_info
def get_book_title(some_isbn): if not amazon.is_valid_isbn(some_isbn): return some_isbn + " is not a valid ISBN" isbn10, isbn13 = amazon.fix_isbn(some_isbn) book_info = get_book_info(isbn13) # the following statement assumes the isbn was found. # we should probably test for error conditions. return book_info["data"][0]["title_latin"]