Automagically organising your bittorrent downloads with deluge
I, as most people, like to have my video files ordered. After I’ve finished downloading a torrent I manually move it to my media dir, under a directory for the series it belongs to, or no directory at all, but it’s a hard and unnecesary process.
I’ll explain here (and provide an script for it) how to make deluge automagically handle our files.
I’ve chosen deluge bittorrent client for this guide (blame it on enver555), but you should be able to use my script (with maybe, a few modifications about the argument handling) anywhere.
Getting the script
First, you will need to download the shorting script, it’s a single 5-liner bash script, with lots of magic and power, for that reason, I’ve called it the torrent shorting hat.
|1 2 3 4 5||
Installing it system-wide or locally
You might want all your users to have access to this script, for that, as with any other linux program, you should copy it to path and give it executable permissions, that’s, as root:
wget https://raw.github.com/gist/1705151/540fd4445ca4e0f540ddf82decba3ffc421c46ab/gistfile1.sh -O /usr/local/bin/torrent_shorting_hat chmod +x /usr/local/bin/torrent_shorting_hat
I personally recoment this method, but if you prefer, you can get it at your local home, you could, for example, do something like this:
wget https://raw.github.com/gist/1705151/540fd4445ca4e0f540ddf82decba3ffc421c46ab/gistfile1.sh -O .torrent_shorting_hat chmod +x .torrent_shorting_hat
We enable the execute plugin
Then, we add an execute action for a “finished torrent download” handler. If you’ve added your script locally, you had to reference it as its full path, otherwise you have just to use “torrent_shorting_hat” as scrpit:
Configuring the sorting hat
The sorting hat will read a file in your home called .torrent-aliases, more exactly its regexes variable, it’s basically a shell script with associative arrays, like this:
This will get everything containing “42″ to a folder in ~/Media/(mimetype)/hitchicker, being mimetype the file’s mimetype. Wich, by the way, means that even if you don’t have anything configured, the script will organize files by its type.