The Pug Automatic

Torrent Forwarder

Written March 27, 2008. Tagged OS X, AppleScript.

I wrote this script a while back, but I haven't gotten around to blog it until now.

This is my set-up at home: I have a Mac Mini as HTPC and as server for various things. I also use it as my BitTorrent machine.

So the Mini handles torrent downloads. The Mini is always on because it is a web server, because it might need to record a tv show in the middle of the night etc. This is, of course, nice for downloads as well. I can put my notebook to sleep and take it with me somewhere and my downloads will be uninterrupted.

Also, most of the time I want the downloads on that machine after completion, if they're movies/shows/music. Saves me having to copy them over.

To facilitate this, I made a Folder Action script so I can click a torrent file on my notebook and have it start on the Mini. A web page showing torrent progress is also opened on my notebook.

On the Mini

The Mini runs the Transmission BitTorrent client.

In the Transmission preferences, under the "Transfers" pane, "Auto add" is activated and set to watch for torrent files in ~htpc/Public/Torrent drop.

It also runs Clutch, a web interface to Transmission.

On the notebook

I wrote a Folder Action script that is attached to my Downloads folder. Download the script (source) and attach it. I've put the script in ~/Library/Scripts/Folder Action Scripts/Torrent Forwarder.scpt.

You will need to modify the script for your setup. The script will by default scp to hyper:Public/Torrent drop. I can use hyper because ~/.ssh/config contains

~/.ssh/config
Host hyper
Hostname hyperion.local
User htpc

There's no need to specify a password since SSH public key authentication is used.

The script uses "http://torrent" for Clutch: I have an /etc/hosts entry mapping "torrent" to the IP address of the Mini, and a nginx proxy rule so I don't have to specify the port. Change the URL to whatever works for you.

I realize this is all pretty user-unfriendly. I'm sharing it as inspiration for intrepid hackers, rather than as a simple tutorial for the newbie. Nevertheless, feel free to ask if you get stuck, and I'll try to help.