Quick and easy way of making Chrome send bittorrent magnet links to a remote Transmission instance using its API on OSX, with PHP, Javascript, and OSX's built-in Apache.
Chrome does not handle default protocol applications without a little encouragement. But we're about to take care of that (see Step 6).
Steps:
-
Install the shell script
transmission-remote-magnet
:cp ~/src/transmission-remote-magnet.sh /usr/local/bin/transmission-remote-magnet
-
Install the php file, which is required for link handling to work, and will likely require sudo:
sudo cp ~/src/trm.php /Library/WebServer/Documents/
-
Enable PHP by uncommenting (aka deleting the
#
before) this line in/private/etc/apache2/httpd.conf
withsudo vi
or an equivalent:LoadModule php5_module libexec/apache2/libphp5.so
-
You may also want to lock Apache to the localhost for security - in the file above, change the line
Listen 80
toListen 127.0.0.1:80
-
Start the built-in webserver:
sudo apachectl start
-
Tell your Chrome to use the php file for the magnet MIME type. Navigate to http://127.0.0.1/trm.php and paste the following string in the navigation box, then hit Enter/Return:
javascript:navigator.registerProtocolHandler("magnet","http://127.0.0.1/trm.php?url=%s","TRM")
Right now, when you click a magnet:
link in Chrome, you get a readout page - X-Transmission-Session-Id, the full magnet link, and the output from Transmission that hopefully ends with "result":"success"}
, and a javascript "Go Back" button. I may or may not change this behavior so that the page doesn't print a readout and auto-returns to the previous page. It was very useful for debugging, though, so I may keep it and style it with some CSS, maybe put the return on a timer... We'll see.
I was really excited to get this working – but despite trying every possible configuration I could think of, I can't seem to get this working.
When I hit
127.0.0.1/trm.php
I get a 500 server error - "127.0.0.1 is currently unable to handle this request"I verified that my
apache2/httpd.conf
was accurate, and I tested a php file at127.0.0.1/test.php
just to make sure Apache was running properly, but no luck...Do you have any ideas? I would looove to get this working. Thanks!