So, I decided to go with ISBNdb because I quickly stumbled on Python module for it. Additionally, I realized that Calibre uses this library, too. This turned out to be a mistake. I lost more than hour trying to make it work, just for a single search by ISBN. Googling for some example code didn't bring a lot. So, here is what I learned, maybe it helps someone out there.
First, let me say that there is a bug in the code in subversion. If you checked out version 41, then the bug is certainly there. You need to open file keys.py and change line 22 that reads like this:
_KEYS.append(k)into:
_KEYS[key] = kNext, you also have to change line 62 in the same line that reads like this:
into this:def __new__(cls, key, force_=False):
def __new__(cls, key, name, force_=False):
Also, to use this library, and ISBNdb in general, you have to register in order to get a key. Key is a string of 8 characters.
Now, we are ready to try the library. The easiest way is to position yourself into directory that contains isbndb/ directory from subversion (that way Python interpreter will be able to find the module, otherwise, you need to move it into some "system" place, or manipulate sys.path array.
The commands are:
And that's enough to get you started. The rest you can find by youself using Python's introspection features and some code browsing.>>> import isbndb>>> isbndb.addKey('12345678')
Got from isbndb:
<?xml version="1.0" encoding="UTF-8"?>
<ISBNdb server_time="2012-08-21T14:16:45Z">
<KeyStats granted="9" access_key="12345678" requests="9" limit="0" />:
<BookList total_results="0" page_size="10" page_number="1" shown_results="0"></BookList>
</ISBNdb>
True
>>> books=isbndb.IsbndbSearch(searchValue='0071378596')>>> book=books[0]>>> book.Title
'Mastering technical mathematics'
In the end, I think that this library isn't mature enough, it also has debug statements embedded into it and the documentation is poor, at best!
No comments:
Post a Comment