Friday, November 7, 2014

Headless Calibre Server for News–RASPBMC


First of all thanks to Kovid Goyal for the wonderful software called Calibre.
One of the best features of the Calibre is to fetch news from RSS feed and send it to my Kindle in most beautiful format.

The challenge: is that I cannot keep my laptop always on so that it can send the news on the predefined time.

Solution: Using my all purpose RASPBERRY PI for the purpose.

Steps :

1. Install Calibre

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install calibre

2. Ensure that the LANG variable is set. Just because mine was not set.

export LANG=en_US.UTF-8

3. Check if it is set correctly


locale

After editing a locale file, do not forget to re-generate the locales for the changes to take effect after reboot.

The locales that can be generated are listed in the /etc/locale.gen file: their names are defined using the format [language][_TERRITORY][.CODESET][@modifier]. To generate a locale, first uncomment the corresponding line in the file (or comment to remove); when doing this, also consider the localizations that other users on the system might need. For example, for American-English uncomment en_US.UTF.8 UTF-8. When done, save the file and generate the uncommented locale(s) by executing:


# locale-gen



4. Now since we are running the headless server and calibre don’t support is by default, hence we need to use xvfb. To use this we need to first install xvfb


sudo apt-get install xvfb

5. creating email.txt file which will contain all the email to which the email will be sent and saving it to /home/pi/scripts/ (the folder which I created in my earlier posts). One email per line in file.

6. Creating a fetch_news.sh file. (Thanks to https://gist.github.com/rogeliodh/1560289). I have modified the script a little and saving it to /home/pi/scripts/ 






7. Make the script executable


chmod a+x fetch_news.sh

8. Place the latest recipe file in the same folder i.e. saving it to /home/pi/scripts/ . If you are not aware where to get the latest version go to
https://github.com/kovidgoyal/calibre/tree/master/recipes
or you may also access the same on your PC in the zip file named “builtin_recipes” on below path C:\Program Files (x86)\Calibre2\resources

9. Run the (ba)sh file to check it.


cd /scripts
sh fetch_news.sh

10. Schedule the file to run – I am setting it to 6:30 AM every morning.


crontab -e

30 6 * * * /home/pi/scripts/fetch_news.sh

press ctrl + x and y to save the file.

Tip 1: Check the date and time before setting date and time

date

if time is not correct execute below command

date +%T -s "10:13:13"

Tip 2: If you are using the same Raspberry Pi for transmission download also, then you can schedule the reduced bandwidth (for example between 60:20 - 7:00 AM as in my case) so that Calibre dont face any issue while it downloads the News RSS.

1 comment: