Skip to main content

Ralsina.Me — Roberto Alsina's website

Quick Hack to Catalog your Books

If you have ac­tu­al, pa­per books and want to cat­a­log their in­fo quick­ly, this book­da­ script may be handy:

import sys
import time
import gdata.books.service
import json

def get_book_info(isbn):
    print "Looking for ISBN:", isbn
    google_books = gdata.books.service.BookService()
    result ='ISBN %s '%isbn)
    data = [x.to_dict() for x in result.entry]
    if not data:
        print "No results"
    title = data[0]['title']
    with open(title+'.json','w') as f:
    print "Guardada info de '%s' en '%s.json'" %(isbn, title)

if __name__ == "__main__":
    while True:
        isbn = sys.stdin.readline().strip()
        if isbn:

What does it do? It reads IS­BN num­bers from stan­dard in­put and saves the book's in­fo in a ti­tle.j­son file for lat­er pro­cess­ing and for­mat­ting.

If you want to ed­it that in­for­ma­tion, you can just do it or you can try do­ing a lit­tle script us­ing json­wid­get like this:

python -c 'import jsonwidget; jsonwidget.run_editor("abook.json", schemafile="gbooks.schema")'

Where abook.j­son is a file gen­er­at­ed by the pre­vi­ous script and gbook­s.schema is this file.

Oh, and if your books have bar­codes, you can just do:

zbarcam --raw | python

Show your com­put­er your books and let it do the rest :-)

PS: I would love if some­one gath­ered all this and made a nice per­son­al book cat­a­logu­ing thing.

Contents © 2000-2023 Roberto Alsina