Sunday, July 17, 2005

LibraryBot Overview

The library is such a great concept. Just think about it for a second: you can read books and listen to CD's for absolutely nothing! Not only that, but you don't have to wait for Amazon to ship anything to you and libraries have a much wider selection than any bookstore in town. There's also no need to invest in walls and walls of bookcases to store books that only collect dust for the next 25 years.

The problem is you have to return all these free things within a certain period of time. Does the library know when your books are about to become overdue? Absolutely. Does it ever warn you? Never. Instead, it quietly lets you rack up overdue charges.

At any one time my family can have up to 25 items checked out on two different cards. Just the other day I spent $8.25 on library fines! With that money I could have, um, well, I could have bought part of a pizza or something. To be honest I don't know what I could have done with that money, but it sure is irksome to pay fines.

Presenting LibraryBot. Once you give it your library card number and web pin, LibraryBot will automatically:
- Renew library materials on your behalf. At my library, that means a 3 week checkout will normally be auto-extended to an 8 week checkout.
- Give you two days notice on any materials it can't renew.
- Warn you about any currently overdue materials.
- Append an inspirational quote to any email it sends you. :)

It's only been tested on the Des Moines Public Library's site. I imagine it would work with little modification for any library that runs on Dynix.

Now for the code. First, thanks go out to BeautifulSoup, libgmail, and feedparser. These libraries made this project a pleasure to code. Second, this is all released under the GPL 2.0 license.

I broke the code into 3 main modules:
- LibraryBot.py handles all interaction with Dynix's web pages. In effect it puts a Python wrapper around a Dynix library's web site.
- LibraryBotClient.py controls the calls into LibraryBot.py. It decides what action to take based on the information LibraryBot.py returns. Some examples include renewing materials and sending emails.
- rssfeed.py goes out and finds a quote of the day from a randomly selected feed source.

In retrospect I should have also created a separate email module instead of embedding libgmail into LibraryBotClient. Maybe I'll do that later. Other future plans include storing this information to a database for longer term tracking. I'm also going to make it optionally post a blog entry when new materials get checked out. That will make it easy to keep an online reading journal. From a technical angle, I'd like to wrap the core LibraryBot module in a web service. I also want to dig into some C#.