So… I’ve been using rtorrent as my main torrent client for a couple of years now. I have it running on my server and I’m usually adding torrents either by placing them in a watchdir or by adding them through a web interface (rutorrent, in case you’re wondering).
One of the things I’ve always wanted was to have rtorrent handle multiple categories. I wanted games I downloaded to go into a “games” directory, comics into a “comics” directory, and so on. I’ve been looking for solutions for a few years now, and all I’ve found online are people in the same boat. So today I decided to spend a few hours experimenting… And this is the result.
My way of doing this uses two lines of code in .rtorrent.rc:
# Add new method to get finished dir system.method.insert = d.get_finished_dir,simple,"cat=[folder]/finished/,$d.get_custom1="
system.method.set_key = event.download.finished,move_complete,"d.set_directory=$d.get_finished_dir=;execute=mkdir,-p,$d.get_finished_dir=;execute=mv,-u,$d.get_base_path=,$d.get_finished_dir="
The first line, the system.method.insert thing, basically says that each torrent object should be able to return a string which is the concatenation of “[folder]/finished/” and the torrent’s label. So a torrent with the label “tvshows” will return “[folder]/finished/tvshows”. Change the first part to whatever you want your base “finished torrents” directory to be. I haven’t tried this with any directories containing spaces, but I’m guessing escaping would be the way to go.
The second line basically says that the torrent should set its internally defined directory to whatever get_finished_dir returns, then create the directory if it doesn’t already exist, and finally move the torrent to the same directory.
- Torrents without labels will be placed in the base dir.
- Torrents with labels corresponding to already existing folders will be moved to those folders.
- Torrents with labels corresponding to folders that don’t already exist will have the folder created for them, then they’ll be moved to that folder.
It’s a bit complex, but hopefully my explanation makes thing a bit clearer =)
TL;DR: Insert the lines in your .rtorrent.rc, replace [folder]/finished/ with your base directory for finished torrents.
I have set up several watch directories, each corresponding to a category or label.
# TV shows schedule = watch_directory_1,5,60,"load_start=[folder]/input/tvshows/*.torrent,d.set_custom1=tvshows" # Movies schedule = watch_directory_1,5,60,"load_start=[folder]/input/movies/*.torrent,d.set_custom1=movies" # Comics schedule = watch_directory_1,5,60,"load_start=[folder]/input/comics/*.torrent,d.set_custom1=comics" # Music schedule = watch_directory_1,5,60,"load_start=[folder]/input/music/*.torrent,d.set_custom1=music"
There are two important parts of each of these lines. The [folder]/input/x part is the directory to be watched. The last part, after set_custom1=, is the label torrents found in the directory will be assigned.
This means when I’m downloading a movie, say, then I put the torrent in the [folder]/input/movies folder. It’s automatically added to rtorrent, with the label “movies”. When finished, it’s placed in [folder]/finished/movies.
Next step for me will be to add some automatic fetching of subtitles for downloaded movies and tv shows, but I’m pretty happy with this setup…
I recently upgraded to rTorrent 0.6.9. Slight change as shown below:
# Add new method to get finished dir method.insert = d.get_finished_dir,simple,"cat=[folder]/finished/,$d.get_custom1="
method.set_key = event.download.finished,move_complete,"d.set_directory=$d.get_finished_dir=;execute=mkdir,-p,$d.get_finished_dir=;execute=mv,-u,$d.get_base_path=,$d.get_finished_dir="
I haven’t tested this extensively, though. I might come back to revise this further.
I borrowed the method.insert stuff from this recipe.
The custom1 and label stuff I found in several places, but this solution is basically what I based mine on. I can’t seem to find the page where I found the information that the rutorrent labels are the same as d.get_current1 though.
I know there are addons for rutorrent (like autotools) that do similar things, but I wanted a server-based solution.
Got a better solution? Let me know and I’ll update this post & give credit!