Disclaimer: Let’s get this out of the way up front. The gist of what I describe in this post is probably against Amazon’s terms of service. So don’t be an idiot.
I own about 1,000 books. For years I’ve used Delicious Library on my Mac to catalogue them all. If you’re unfamiliar with Delicious Library, it’s the best cataloguing app you can buy for the platform. To my knowledge, it was the first to let you scan the barcode of a book and then automatically download all the information, including the cover image, from Amazon. You can do the same for movies, video games and even tools.
When the iPhone was released, I waited patiently for a mobile version and Wil delivered. There was much rejoicing. But the dream was over almost as soon as it began. Amazon changed their terms of service to disallow using their information in mobile applications, the app went away, and the ability to sync to the iPhone client was removed from the desktop version.
Since then I’ve been trying to find a solution that would allow me to have access to my entire library on my iPhone. For a long time, I lived in a state of denial and kept the Delicious Library app on my phone, but it was pretty useless without the ability to add new information to it. I tried exporting flat html files from Delicious Library to Dropbox and then syncing with Good Reader. It worked, but it was impossible to search so I found myself tapping repeatedly to manually find the information I was looking for.
The ideal solution (besides a working Delicious Library app) would be to create a database on my Mac that I could sync with my iDevices. It would also allow me to add new books on the device and then sync the updates back. Bento seemed perfect for the job, since I have it everywhere, I just thought actually creating the database would be a huge pain so I never bothered. But it’s amazing the things you’ll do when you’re completely bored on a weekend. Step one was to export a .csv file from Delicious Library with just the basic information (title, author, ISBN, publisher) and then import it into a new Bento library. Easy. That wasn’t enough though. I also wanted to have the cover images and you can’t export those from Delicious Library.
So the question became how to easily obtain the cover images for almost 1,000 books. Obviously searching Google Images wasn’t going to cut it. But Google did lead me to this excellent Abusing Amazon images article by Nat Gertler that describes in awesome detail the various URLs that Amazon uses for its cover images. With that information in hand, all I needed was the Amazon item IDs for all of my books. And it turns out that the item ID is one of the many things that Delicious Library keeps in its database. Exporting a file with just that field was trivial.
Now I had all the pieces: a generic image URL and a file with all of the Amazon item IDs. The Unix utility curl comes with OS X so I could use that to download the files. All that remained was to find some glue to put it all together. And my glue of choice is Python (you could do it in perl or Ruby and probably even AppleScript, but I stick with what I know best).
After reading a little documentation and experimenting with a subset of my item ID file, my little script was ready. I let ‘er rip and after about an hour I had a folder full of book cover images. I still had to add the images to Bento manually (since it appears that AppleScript support is not a high priority for the developers), but it sure beat having to download them all manually too. It also didn’t work for every book, and the image quality varied, but all in all it saved me a lot of time. The final script, cleaned up and with some features added, can be found on my GitHub.
Another thing I found while I was working on this is Delicious Library’s Scanned UPCs Log file. It basically keeps a record of the ISBNs for the books you’ve scanned into the application. I could see eventually modifying my script to read the most recent entry in the log and automatically download the cover. That would take some time to figure out Amazon’s API and the various Python libraries for working with it.May make for another fun installment in the Weekend Project Series.
In the end, this entire process could have been avoided if Amazon would just let us use their data in mobile applications. But since they won’t, I don’t feel entirely guilty about “stealing” it. Wouldn’t it be nice if they gave us some kind of library functionality, similar to what they’re doing with Cloud Drive or even extending the current Wish List? Why couldn’t we just upload a file with a bunch of ISBNs and then have a nicely formatted list show up in say Amazon’s iOS apps? It would be awesome, but I won’t hold my breath.