# A library at home


I've told a few 
[times about how](/s/61ba93ac0b/)
[to build a library](s/b3021c7414/).

But there a some extra things that must be done before you can call 
yourself a complete librarian.

1. ID-ing the books you have
2. Storing the information 
3. Marking the books
4. Sorting and shelving the books
5. Remembering who borrowed what

# ID-ing books
For this I bought a barcode reader that reads the ISBN number
of the book's backcover. With `book_get` 
([Perl code](/downloads/2009/book_get))
I can retrieve the author, title, genre and year published from Google.

    % book_get 9789024546497
    Cryptonomicon
    Neal Stephenson
    none
    2005
    #Cryptonomicon&#8206;by Neal Stephenson, Irene Ketman - 2005

Getting the genre right is a bit of a problem as Google will
not always report the correct genre (or just slightly different,
i.e. sometimes 'science' and sometimes 'computer science'). I
solved this by explicitly asking for the genre in the next step.

Also the html returned is awful, so sometimes this script looses
its way.

# Storing the information
Getting the information is the first step, now it needs to be stored
somewhere. In a SQLite database for instance. I've made a minimal
database with only one table which holds all information: title,
genre, author, isbn, and a few more items.

With `book_sql` 
([perl code](/downloads/2009/book_sql))
the information retrieved with `book_get` is 
normalized (correct the genre) and put into the SQLite db.

# Marking the books
To help with this 
[I needed a label writer](s/b3021c7414/) to
print the author, genre and title on a small label. Currently I am
not confident enough to automate the printing of the labels so 
I manually query the database and feed the rows to `labelfmt`
([Perl code](downloads/2009/labelfmt)). This
little scripts uses LaTeX to format the labels and will print the
resulting `pdf` on the labelwriter.

    % sqlite3 biblio.db
    sqlite> select * from books where title like '%crypto%';
    146|9789024546497|Cryptonomicon|Neal Stephenson, Irene Ketman|science fiction|2005|1201339561|

Now I give this text to `labelfmt` and it will print the label

    % ./labelfmt
    146|9789024546497|Cryptonomicon|Neal Stephenson, Irene Ketman|science fiction|2005|1201339561|
    ....

And the labels gets printed:

![label with print](/images/2009/label.jpg "Label with print")

Next you will needed:

* little pieces of thick paper/carton; this is where you sticker the 
labels on. Like this:

![paper with label](/images/2009/label-on-paper.jpg "Paper with label")

* little (120 x 120 mm) plastic triangles; which can be glued in each book, so that
the book's label can be put inside.

![plastic in book](/images/2009/plastic.jpg "Plastic in book")

And insert the label:

![label in book](/images/2009/label-in-book.jpg "Label in book")

And another one is ready :-)

# Sorting and storing
We decided to catalog our books based on genre. So I made
a map to tell which genres are placed where. Sorta like

* COMPUTER - left shelve in the living room 
* SCIENCE  - middle shelve in the living room
* ... - somewhere else

So there you have it a full blown library setup for you books
at home. 

# Borrowing
Now if somebody want to read one of our book it is simply a
matter of: locating the book, getting the label out, writing
the person's name on the label and storing the label in a
safe place until the book is returned.

This last step could also be automated by using the barcode reader,
but the desktop computer in our living room is not powered on
100% of the time. Booting the machine takes too long and makes
it too cumbersome if someone just wants to borrow a book.

