Archive for May, 2007

TurboGears meets IMDb

Thursday, May 3rd, 2007

I recently gave two guest-lectures at Nottingham University on web-programming using TurboGears. The first lecture was a general introduction to Model-View-Controller web-programming using TurboGears. The second lecture was more practical: I wanted to present a full mini-application and show the students how it was built. And I also wanted the application to be at least remotely usable and interesting – therefore I choosed to write a little movie collection web application as I thought everybody enjoys movies.

The idea was to utilize movie summaries from the Internet Movie Database (IMDb). As you might know the IMDb is a very popular online database which covers about a million movies and more than two million people. It is one of the oldest collaborative online efforts (according to Wikipedia it launched 17.10.1990 and originated from the Usenet list rec.arts.movies of the late 1980’s) which has been acquired by Amazon in 1998.

IMDb data
What you might not know is that this supposingly closed source of information always had a free interface which you are allowed to use for private reasons. This interface consists of zipped text-files which can be downloaded from FTP servers. In the mid-nineties there was a very good programm for the Commodore Amiga computers called “Movie MUI” which used those files to built a local copy of the IMDb database and then allowed you to browse the data with a very nice graphical user interface. More recently, a Python module called IMDbPy became available. Since TurboGears is written in Python, it seemed obvious to try out IMDbPY from within TurboGears.

Required Funtionality
The idea was to be able to browse movies (using IMDb data), store your favourites and possibly annotate them. Therefore the webapp should provide the following functionality:

  • Search (fuzzy, showing matching titles)
  • Browse movie details
  • Store movie to favourites (and remove as well)
  • Add/edit notes

Webapp – Main screen
View larger

You can see a list of movies that I have compiled using the application itself. From this screen you can search the movie database or pick a movie from the collection to bring up the details, including your annotations.

Webapp – Search results
View larger

The above screenshot shows a search for “Silicon Valley Story”, which is the main part of the German title of a great 1999 TV movie originally called “Pirates of Silicon Valley”. The two interesting features to note here are:

  • You have a fuzzy search, also returning similar titles
  • You can search for non-english titles

Webapp – Movie details
View larger

This is the movie details screen. It is noteworthy that the search for the German title (which is still in the search box) has correctly led us to the movie “Pirates of Silicon Valley”. From here the user can go back to his search list, go to the main menu, store the movie to his collection or refine the searchterm.

Webapp – Store movie, edit note
View larger

You can add a note when storing the movie. Note that the movie will be stored under its original title with year of release, which is the IMDb naming convention.

Webapp – Movie in collection
View larger

The movie has been added to the collection and the custom note is display at the bottom.

Note on IMDbPY

I generated the local copy of the IMDb database on a 1.7 GHz Centrino laptop with 512 MB Ram, running a modified (from the IMDbPY package) with Psyco and outputting to SQLite with option autoCommit=False (?autoCommit=&). This was a very lengthy process which obviously has to be optimized in the future. It took over 11 hours to generate the indexed database on my laptop. The resulting file was just under 2 GB in size.

Here are the last lines of output from (look at the time spent between lines 2 and 3!):

”’[..] TOTAL TIME TO INSERT DATA: 46 minutes, 34 seconds
building database indexes (this may take a while)
# TIME createIndexes() : 646 min, 17 sec.
DONE! (in 692 minutes, 52 seconds)

This was my first TurboGears project. The web application works as expected and I really enjoyed the development process. Feel free to contact me (via email or via the Xing profile provided in the sidebar) if you are interested in the sources.