How to open magnet links on a remote transmission daemon with one click…

english, Hacking, OnlineLife Net Webapps

i’m using transmission for my regular bittorrent needs. it has a nice simple interface and can even be run as a daemon on a server. therefor it even offers a nice looking web interface.

Note: if you are running gentoo or a system that uses the xdg-utils with xdg-open, you might want to look at this howto.

since my working machine is not always running but my server is, this is where transmission is set up.

Transmission Web Interface


the web interface provides a nice mask to setup your torrents. you can upload a .torrent file (to your remote machine) or just an URL of a torrent or most recently a magnet link. this is very handy since you don’t need to handle any .torrent files locally. just copy that link and you are done.

when you are running a torrent client directly on the machine you pick out your torrents clicking on the magnet link will most likely start the download immediately without having to copy that link. this kind of comfort was missing with the remote version of transmission.

so i hacked around to solve that.

setup your remote transmission daemon.

then you need a little script that calls the ajax function the web interface provides to ‘upload’ the magnet link.
this is what i came up with:

#!/bin/bash
test -z $1 && echo "need magnet link!
$0 <magnet link>" && exit -1

HOST=YourRemoteHostNameOrIP
PORT=YourPort(default is 9091)
USER=User
PASS=pass

LINK="$1"
# set true if you want every torrent to be paused initially
#PAUSED="true"
PAUSED="false"
SESSID=$(curl --silent --anyauth --user $USER:$PASS "http://$HOST:$PORT/transmission/rpc" | sed 's/.*<code>//g;s/<\/code>.*//g')
curl --silent --anyauth --user $USER:$PASS --header "$SESSID" "http://$HOST:$PORT/transmission/rpc" -d "{\"method\":\"torrent-add\",\"arguments\":{\"paused\":${PAUSED},\"filename\":\"${LINK}\"}}"

the last thing you need to do is tell your system what to run when you click on a magnet link.
adapting this forum tip you need to run:

gconftool-2 -t string -s /desktop/gnome/url-handlers/magnet/command "/path/to/your/script/from/above/magnetLinkTransfer.sh %s"
gconftool-2 -s /desktop/gnome/url-handlers/magnet/needs_terminal false -t bool
gconftool-2 -t bool -s /desktop/gnome/url-handlers/magnet/enabled true

that’s it. now click on any magnet link and transmission will intercept it and will start it automatically on your remote transmission-daemon.
i used transmission-daemon version 2.31 (12441) for this. it should work on newer versions as well. have fun.

8 Comments

8 Responses

  1. Fritiof says:

    Thanks a lot!
    Worked like a charm, after I realized that I didn’t have curl installed…

  2. framboiz says:

    thank you

  3. kendon says:

    works great, thanks for this. was about to figure out the curl command when i thought “surely someone has done it and posted it” ;)

  4. [...] daemon which handles the torrents and accepts requests of all sorts of clients. you can even pass magnet links you clicked, from your desktop to the remote daemon with a little [...]

  5. Pitto says:

    I am seriously and brutally loving this!

    Can I achieve the same result when my girlfriend (windows & chrome user) clicks on her magnet links?

    • flo says:

      i don’t know how to put a custom script in the windows magnet link handler. i’m glad i don’t have to use and know windows ;)
      the call to transmissions API stays the same.

    • Marco says:

      Hey Pitto, I just set this up on Firefox using greasemonkey add-on and this javascript here: http://userscripts.org/scripts/show/68700. You will need to edit the js file and add the IP and port for your remote transmission (in my case my readyNas duo) – no transmission password seems needed.
      If all goes fine, next time you load PB for example, you will be able to click on the magnet link gif and the script will add it to your remote transmission, showing a pop-up.

  6. [...] asks for permission to open a magnet link i posted a how to on a similar solution about one and a half years ago. this time we configure xdg-open to do the [...]

Leave a Reply


3 + = twelve

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>