Using Automator to make your life with Transmission easier

I have two computers: a Macbook with Snow Leopard, that sometimes I carry with me, and a computer at home with an Atom processor and running Linux that is my media server and downloader. If I need to download something that will take too much time, I put this second computer to download: it has a good connection and it’s always online.

It has Transmission running with its great web interface activated. If I need to download some torrent file, I open its web interface and upload the .torrent file. Good, but… it could be easier.

If you download torrent files very often, the easiest way is to use the watch-dir feature from Transmission: every torrent that you put at some directory is automatically downloaded by Transmission. So, all I needed to do was copying the torrent files from my Macbook to my home server, using SFTP.

To configure your Transmission watch-dir, you must stop the Transmission service (I’m running the transmission-daemon version) and edit the settings.json file, inserting the following settings:

[sourcecode language=”js”]
"watch-dir": "/home/mediaserver/transmission/watch",
"watch-dir-enabled": true
[/sourcecode]

Remember: you must stop Transmission service, edit the file and start it again!

It works, but… It can be even easier, I thought. And I remembered of Automator, a good piece of software that comes with Snow Leopard, and that I knew but never used before.

The idea was: every time a new .torrent file is written at my laptop’s download directory, it should be copied to my home server.

So I opened Automator and created a new Folder Action:

At the top of the new workflow, I selected my Downloads folder:

 The next step in our flow is to create a script to copy our files via SSH to the computer that’s running Transmission. Use Utilities -> Run Shell Script to make it:

Now add the following content as the script’s source code. To make it work automatically, I allow my SSH server to receive connections using keys, not passwords. Don’t forget to change the scp’s destination to your computer’s host and directory:

[sourcecode language=”bash”]
for f in "$@"
do
ext=`basename "$f" | awk -F "." ‘{ print $NF }’`
if [ "$ext" == "torrent" ]; then
scp "$f" root@myhostname.asdf.com:/home/transmission/watch
fi
done
[/sourcecode]

That’s it! Save your workflow and test it. Now, every time you click at a torrent file and download it, Transmission will download it automatically.

Transmission

Eu estava procurando, esses dias, um bom cliente para baixar torrents.  Queria um programa mais leve: eu estava usando o Vuze, mas para uma tarefa simplória de baixar torrents usar o Vuze é matar mosca com canhão, já que ele tem muito mais recursos do que eu realmente usava. O próprio site do Vuze já o descreve como “o mais poderoso cliente BitTorrent do mundo”, mas eu não precisava de tamanha munição.

Queria um programa que pudesse rodar em background e ser controlado de outro computador, assim eu poderia, por exemplo, pôr um torrent para baixar usando o computador do trabalho e encontrar os arquivos quando chegasse em casa. No meio dessa busca, o Silveira me sugeriu o Transmission, e também me mandou um artigo do Xisberto tratando do programa.

O Transmission pode rodar de várias maneiras: como daemon, assim que o serviço inicia, ou como um programa comum, com interface gráfica (Qt, GTK e Mac). As interfaces são simples, porém funcionais. Abaixo, o screenshot da interface em GTK:

Interface GTK do Transmission

Também há uma interface web que pode controlar o daemon ou o cliente gráfico que você estiver usando. A interface é similar à do cliente gráfico, e baseada no look & feel do Mac:

Interface web do Transmission

O site do Transmission possui uma seção de add-ons que vale a pena consultar. Há várias maneiras alternativas de controlar o Transmission à distância, e um porte do Transmission para Windows a caminho.