Jamie Bennett Speaks

Thoughts from Jamie Bennett

Automatically download torrents with rsstorrent and rtorrent

Written by Jamie Bennett on March 11th, 2009 at 4:16 pm in Uncategorized

Have you ever wanted to automatically download torrents when they become available, not just when you manage to remember them? Have you ever wanted to have your torrents sat waiting for you when you come home from work? Do you want someone to give you a step by step rundown on how to do this? If the answer is yes to these questions, this how-to is for you.

Prerequisites: or what you need first

For this how-to you need the following software.

See the individual packages web sites for instructions on how to install them.

Setting up rtorrent

rtorrent has an excellent feature that enables you to drop .torrent files into a specified directory and it will automatically start downloading. To enable this you first need to edit the .rtorrent.rc found in your home directory,

You need to change the line that reads something like

#schedule = watch_directory,5,5,load_start=

to

schedule = watch_directory,5,5,load_start=/home/jamie/downloads/torrents_files

Obviously change the load_start directory to the one that you want to use.

rtorrent should then be run in the background all the time. It will watch the directory and any .torrent files you drop in there will be automatically downloaded. I use the screen command to have rtorrent always running. Start it with:

screen rtorrent

Type [ctrl]-a [ctrl]-d to detach the screen and go back to the command prompt. rtorrent will still be running.

Next step, setup rsstorrent.

Setting up rsstorrent

rsstorrent is a simple python script to download and check rss files that contains torrent information. It will figure out if a new torrent has been added to the feed since the last time it checked and if so, it will download the .torrent file into a directory of your choosing. Obviously when used in conjunction with rtorrent, these two are pretty powerful.

You can put the rsstorrent.py file anywhere that you have access to. I put it in my home directory at:

/home/jamie/scripts/

Edit the script with your favorite editor and change only the top few variables:

# List of url feed to be parsed.
FEEDS = [
"http://feedmytorrents.com/rss/97-lost/",
]
DOWNLOAD_DIR = "/home/jamie/downloads/torrents/"
TIMESTAMP = "/home/jamie/downloads/rsstorrent.stamp"
VERBOSE = False

FEEDS is a list of rss feed urls that contain the torrent information. From the example above I have used the popular http://www.feedmytorrents.com site to get a random feed, this one is for the tv series Lost.

A little side note here. Please do not download any illegal torrent files or any files you do not have permission to own. OK, with that out of the way, add as many feed urls as you like, in the format shown above, to the FEEDS list. You will also want to change the DOWNLOAD_DIR and TIMESTAMP variables. Change DOWNLOAD_DIR to the same directory that you used when setting up rtorrent and the TIMESTAMP path can be anywhere that rsstorrent is allowed to save it timestamp information.

Once you have this setup, your ready to go. If you just want to test it out, change the VERBOSE variable to True and run rsstorrent:

python /home/jamie/scripts/rsstorrent.py

If all went according to plan you should see ... nothing downloaded. Why? Well on first run, rsstorrent has no timestamp information so it has to use the current time as a starting point. Rest assured, if you only get the "No new torrents to download" message, everything should be working right.

If you run rsstorrent again later, it will use the timestamp file to determine if any new .torrent files need to be downloaded.

Automating the process

To completely automate the process, rsstorrent can be called from cron. Edit the /etc/crontab file and add an entry for rsstorrent, something like this.

30 */6 * * * jamie cd /home/jamie/scripts && python ./rsstorrent.py

This line means that cron will call rsstorrent every 6 hours.

Conclusion

So there you have it. cron calls rsstorrent periodically to determine if any new .torrent files are available. If they are, the files are downloaded to a directory that rtorrent 'watches'. If rtorrent see's any new .torrent files in this directory, it downloads the torrent automatically.

Now all you need to do is sit back and see your legal torrents download without lifting a finger.

2 Responses to 'Automatically download torrents with rsstorrent and rtorrent'

Subscribe to comments with RSS or TrackBack to 'Automatically download torrents with rsstorrent and rtorrent'.

  1. Say I have a feed that lists multiple shows but I only want 1 of those shows- how do I get the parser to only find the show I want?

    l2ichard

    20 Mar 10 at 5:46 am

  2. rsstorrent was only ever designed to be a very small and simple script for downloading from rss feeds. There are other applications out there that have more functionality for these kind of things.

    JamieBennett

    22 Mar 10 at 10:55 am

Leave a Reply