Samstag, 7. Januar 2012

Reading RSS on Kindle

So I got an Amazon Kindle for Christmas. I like it for its display because epaper is much nicer to read than LCD screens. So I start my quest searching for a way to read my daily news update on my kindle.

For ordinary tables there are many offers out there (free and commercial) each using its own app to provide the content. Well this doesn't work on my Kindle as it's just a stupid e-reader.

So as a first step I want to read my favorite RSS-feeds on my Kindle every morning.
There are some commercial platforms that offer to send your favorite RSS-feeds as ebooks to your kindle.
Since I have my own little server at home, I thought, that can't be that hard to do myself.

So I created some python-scripts that would do the same without providing data to a third party service, since the server is up anyways.

I put the scripts on github to make them accessible to everybody.
There are two important scripts in this project: collect.py and main.py

The collect script is responsible for regularly polling the desired RSS-feeds and storing the article data locally. It does so by storing the data in a sqlite database. The main script takes the locally stored data, creates mobi-files from it and sends it to the configured email-address.
It converts the local data to a html-page which is then converted to an ebook.

To run the scripts in ubuntu 10.04, I installed the following packages:

  • python-feedparser (Library to parse the feed obviously)
  • python-lxml (Library to manipulate HTML)
  • calibre (ebook-software containing command-line tools to convert ebook-formats)
  • xvfb (Fake X-Server because calibre-scripts won't work without X)
So to set it all up:
# apt-get install python-feedparser python-lxml calibre xvfb
# git clone git://github.com/ChristophGr/rss4kindle.git
Then a config-files has to be created from the provided sample.
Then you may want to setup the scripts in your crontab like this:
# crontab -e 

0 * * * * /home/me/rss4kindle/collect.py
30 5 * * */home/me/rss4kindle/main.py

This way the desired feeds are polled every hour, and the result is sent to the kindle every day at 5:30 AM.
Coming closer to replace my daily newspaper ;)

Kommentare:

  1. Hi, I'm a kindler from korea.
    I found your work brilliant so that I tried to do the same.
    But when I tested your code, some error occured

    $ python rss4kindle/collect.py
    Traceback (most recent call last):
    File "rss4kindle/collect.py", line 17, in
    from configparser import *

    Would you let me know how to solve this?
    Thanks for sharing your tips, by the way :)

    AntwortenLöschen
    Antworten
    1. You'll need to create a config-file "config.py" for that to work. See config.py.sample in the repository.

      Löschen
    2. Thanks! I didn't noticed parserconfig.py.sample in the directory.
      Works fabulous!

      Löschen
  2. Dieser Kommentar wurde vom Autor entfernt.

    AntwortenLöschen
  3. Thanks for the great tip. But I was wondering this useful scripts are still available. Taking your scripts, I tried installing it on my Pogoplug - System based on Debian - but it didn't work. I have no idea why this problem happened. Because of diffrent OS? or Method of accessing Gmail had changed since then?

    All the setting have been done, I tried $ python collect.py and $ python main.py, but it showed just "Starting temporary Xserver []" and just back to the prompt. I have no slightest idea if writing this helps solving the problem, nothing but writing is my last choice.

    If you still operate this scripts and use it nicely, it would be grateful you giving me advice for this. Thanks again.

    AntwortenLöschen
  4. Solved! Since I am hardly used to configuring Linux system, I couldn't notice there is # in front of the feedurl line. How foolish I am! If I hadn't got your comment, I would wander a lot more for solving this problem, and eventually couldn't get this script working. Thanks! Thanks a lot! What ever you wanted to do in the future, I hope everything is going well with you! Thanks again!

    AntwortenLöschen