May 14, 2014


A month or so ago, I was trying to figure out how to use eztv’s rss feed to automatically download new torrents to my pi. That’s when I ran across the awesome python program called flexget. (link here)With this you can specify the shows you like, and it will check for new episodes and add them to your torrent client for download. It does a lot more then this,but this is the main way I use it at the moment. So here’s some instructions on how I got it up and running on my raspberry pi First you will need python 2.7 or later and pip (a package manager for python apps). I also use transmission as the torrent client, but there are others you can use

sudo apt-get install python
sudo apt-get install python-pip

Once python is installed and working, install flexget with pip

 sudo pip install flexget

Next, you need to set up the config file for flexget. Create a folder called .flexgetin your home directory, then create a file called config.yml(yes yml, not xml) in that folder. This is the file that flexget will read by default when you run the command.

cd ~
mkdir .flexget
touch .flexget/config.yml

Open up the config file in your fav editor, and you can use the contents of mine as an example, or check out the flexget wiki for other ‘recipes’ and examples:)

vim .flexget/config.yml

And here is the contents of my config.yml. Just need to set the quality you prefer, the path where you want them downloaded (mine is to my external hard drive) and your tranmission (or deluge) configuration (flexget can only hook into these two torrent programs at the moment)

             path: /mnt/usb/Torrents/Series/{{series_name}}
         - The Big Bang Theory
         - Person of Interest
         - The Blacklist
         - Suits
         - Revolution 2012
         - Chicago Fire
         - Chicago PD
         - Grey's Anatomy
         - Wonderland
         - Wonderland.AU
         - Royal Pains

       port: 9091
       username: pi

       port: 9091
       username: pi
       finished_for: 2 hours

     priority: 2
     template: tv

 #  kat-tv2:
 #    priority: 1
 #    rss:
 #    template: tv
 #    verify_ssl_certificates: no

 #    priority: 2
 #    rss:
 #    template: tv
 #    verify_ssl_certificates: no


As I use transmission as my torrent client, I can hook straight into it with flexget. The only downfall is the rpc password for transmission is in plain text in the config file.

Anyways, now let’s run flexget for the first time (just as normal user). This will output if its succesfully added movies/tv shows to your torrent program, or it will check and output any errors in syntax in your config file (spacing has to be correct)

flexget execute

014-05-15 12:03 VERBOSE details Produced 40 entries.2014-05-15 12:03 VERBOSE task ACCEPTED: `Revolution.2012.S02E21.HDTV.x264-LOL.[eztv].torrent` \
by series plugin because matches quality

2014-05-15 12:03 VERBOSE task ACCEPTED: `Person.of.Interest.S03E23.720p.HDTV.X264-DIMENSION.[eztv].torrent`\
 by series plugin because matches quality
2014-05-15 12:03 INFO   download Downloading: \
2014-05-15 12:04 INFO   download Downloading: \
2014-05-15 12:04 VERBOSE details Summary - Accepted: 2 (Rejected: 0 Undecided: 38 Failed: 0)

Now that we know it’s working, add an entry into cron to run the command every hour

 crontab -e

and add this line at the bottom

0 * * * * flexget execute

Now you will never have to check for a new torrent manually again, just make the changes to config.yml to add/remove shows movies you like! Hope this is useful

Extra stuff

So I got this working a while ago, but forgot to add it to this post! I added the functionality so, after a torrent is completed, it will send you a pushbullet notification to your mobile (or where ever you want!) 1. So first you will need to sign up to pushbullet to get an access token (API key). Once logged in, click o the little pciture of you up the top right and go to “Account settings”. This page will list your access token for use later on 2. Next, intall it and login to it on your mobile. This will create a device in your account, and assign it a device id, for use in the script 3. Now lets find out the device id, run this command and save the device ID for your device

curl -u <your_access_token_here>: -X GET

Now lets create a new script,

chmod +x

This is what your script should look like:

deviceid=<ID of device>

/usr/bin/curl \ -u $apikey: \ -d $deviceid \
 -d type=note \ -d title="$TR_TORRENT_NAME" \
  -d body="$TR_TIME_LOCALTIME" \ -X POST >> done

Now we need to setup transmission to run this script on finishing a torrent

cd /etc/transmission-daemon/
sudo nano settings.json

and modify this line to be:

"script-torrent-done-filename": "/home/pi/",

All done! Now, not only will all your torrents automatically download, you will be notified of them when they complete!