Build a Media Server - Background

How to configure RSS for Deluge using FlexGet in Ubuntu

The classic way to download files using torrents is as follows:

  1. Go to your favourite torrent site

  2. Search for the torrent you want

  3. Once you've found it, download the torrent file manually

  4. Add the downloaded torrent file to your favourite torrent client

  5. Once it has finished downloading, manually move the file to its final location. (although some torrent clients can do this step for you)

There is a better way, a fully automated way, and that is to use RSS functionality. So for example, let's say you're a Lost fan and you currently manually download each episode of Lost as and when it becomes available. Using RSS you can automate this task meaning you can get Deluge to automatically download each episode for you as and when it becomes available. And then, once it's downloaded it will automatically move the file to the location you specify. And this final location can be different for each and every series you download.

There is a truly excellent tool called FlexGet which can do this, and indeed much more. However, FlexGet can be a little tricky to get up and running and so I've explained how I did it below:

IMPORTANT: Downloading TV shows and the like from the internet can have questionable legality in many countries. So, if you're not familiar with the particular law in your part of the world then let you conscience be your guide as to what you do and do not download!

NOTE: These instructions have been written for Lucid Lynx 10.04 and Karmic Koala 9.10. The version of FlexGet referenced in these instructions relies on either Deluge v1.1.9 being installed or, to gain extra functionality from the tool then you should install Deluge v1.2.x.

Install easy_install

First off we need to install a python setup tool called easy_install. So type or paste the following two commands into a Putty session or directly into the command line of your Ubuntu installation:

sudo apt-get update

sudo apt-get install python-setuptools

Download and install FlexGet

We now want to download and install FlexGet itself. So, create a temporary download location and switch into it:

mkdir tmp

cd tmp

Next download FlexGet by typing or pasting the following command:

wget http://download.flexget.com/unstable/FlexGet-1.0r1359-py2.6.egg

Now install FlexGet:

sudo easy_install FlexGet-1.0r1359-py2.6.egg

Next, switch back out of the temporary download location and then delete this folder and the file within it as we no longer need it:

cd ..

rm -r tmp

TIP: If you go to the FlexGet download location then you will find there are later versions than the one I'm using here. However, as each of these versions are "beta" versions then you might find that you download one which doesn't quite work properly. So, I'd recommend downloading the FlexGet version in this guide and get everything up and running nicely first. Then, when it's all working fine, by all means download a later version of FlexGet. Then, if you hit problems with its operation it's likely to be a problem with the particular release you've installed rather than a problem with the installation procedure itself.

Create the FlexGet working area

Often scripts and applications are run as the default Ubuntu User. However, the recommendation with FlexGet is to run FlexGet using the "deluge" user. The deluge user is the username the Deluge daemon runs under. If we don't do so then we will hit permission problems since the two parts of the setup (Deluge and FlexGet) will be creating files and folders using different usernames and thus will be using different file/folder permissions.

So we first need to create the working area which FlexGet will use:

sudo -u deluge mkdir /var/lib/deluge/.flexget

Next we need to add the deluge user as a valid user for the deluge API. So:

sudo -u deluge vim /var/lib/deluge/auth

This will open a file called auth which lives in the /var/lib/deluge folder.

There is already one line in this file but we need to insert an extra line. So press the [Insert] key once (to go into "edit" mode) and insert a new blank line. Next type or paste the following string into this new blank line:

deluge:deluge

Now press the [Esc] key once and type the following:

:wq

This should save your changes and bring you back to the command line. If you make a mistake editing the file then issue :q! instead of :wq to abort your changes.

Create the FlexGet configuration file

Now we need to create the FlexGet configuration file. The configuration file is where we'll store all the instructions for FlexGet. ie. What to download and from where. So type the following command to create the file and to open it:

sudo -u deluge vim /var/lib/deluge/.flexget/config.yml

Enter the configuration parameters as required. See the FlexGet website for configuration examples.

I've included a working example to allow you to test the process is working correctly: Sample config.yml file

Running FlexGet as the "deluge" user

To run the FlexGet script we've just created type the following:

sudo -H -u deluge flexget

Run FlexGet as a cron job using Webmin

FlexGet will execute your script each time it runs and pull down any new torrent files it finds. It is therefore desirable to run this script regularly and the best way to do this is via the use of a cron job. I use Webmin to administer my server and creating cron jobs using Webmin is an absolute breeze.

So, launch Webmin then click on System and then Scheduled Cron Jobs. Then click Create a new scheduled cron job at the top of the screen that opens.

Click the button next to the Execute cron job as and choose the "deluge" user.

Type the full path of FlexGet into the Command box. So: /usr/local/bin/flexget

In the When to Execute section select Simple Schedule and choose Hourly from the drop down list.

Then click the Create button.

FlexGet will now check every hour for new torrent files and download them for you. Deluge will then take over and start downloading the actual files themselves for you.

How to wipe the Flexget database and start over

FlexGet keeps a record of what files it has and has not downloaded in an SQL database. If you ever want to wipe everything and start over then issue the following command:

sudo -u deluge rm /var/lib/deluge/.flexget/db-config.sqlite

Bookmark and Share