Tuesday, December 15, 2009

XKCD on PRS300

I recently received a new Sony PRS300 ebook reader as a gift from my employer. After grabbing a couple books from the sony ebook store and hitting up project gutenberg I downloaded the open source ebook manager Calibre and have been playing with it.

One of the neat things about Calibre is that it can create and update ebooks based on web sites. This allows you to download and read you favorite blogs and news sites on your e-reader. The way this is done is using "recipes" to do some simple (or not-so-simple) screen-scraping. This feature also includes a scheduling ability that can be set to update automatically.There are lots of recipes included when you download Calibre, just look under Fetch News -> Schedule news download.

In addition to the default recipes, there are basic and advanced recipe editors with the advanced editor being a place to put custom python scripts. For more on this see here.

One of the first news feeds I tried was an included recipe for xkcd, an excellent webcomic done by Randall Munroe and placed under a creative commons license.

What I found was that, while the comic downloaded and synced with my PRS300 the comic image was often too large for the pocket sized display and would get cut off. Fortunately since this is an open source project all the included recipes are available in the SCM repo (they are using bazaar). I was able to grab the xkcd recipe and make a couple changes to help it better fit the PRS300 screen (and add attribution to Randall in the description).

So for anyone using a PRS300 here's the modified script, play with it as you see fit (GPLv3):


To install the recipe simply select Fetch News -> Add a custom news source -> Load recipe from file and select the recipe I've included above.

If you have a full-sized reader us the recipe that comes with Calibre as it doesn't shrink the content.



Quick Update:
The included recipes can be edited by selecting "customize builtin recipies" under "add a custom news source". Saves a trip to the SCM.