Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!

Start torrent downloads from an iPhone iPhone
I have a server that I use for, among other things, downloading files with bittorrent. I usually start these torrents by downloading them on my primary computer and then dropping them onto an alias to my server's torrents folder, which my bittorrent client (Transmission) monitors so that it can start the torrents automatically. I occasionally wanted to use my iPod Touch to start these torrents, but Mobile Safari refuses to download torrent files.

My solution was to use Javascript to alter the torrent link to send its URL to my server for download rather than trying to open it. A PHP script on the server could then download that URL to the torrents folder. With both scripts in place, and the permissions of the torrents folder modified to allow Apache to write files, all I have to do is run the Javascript as a bookmarklet before clicking the torrent link, and click the link to download the torrent file. The modified link will pass this URL to the script to download it on the server.

Bookmarklet:
function%20torrent()%20%7Bwindow.location.href%20=%20%22http://torrent.server.address/t.php?%22%20+%20this.href;%20return%20false;%7D;%20for%20(link%20=%200;%20link%20%3C%20document.links.length;%20link++)%20document.links%5Blink%5D.onclick%20=%20torrent;">torrent
PHP:
<?php
if (!($_SERVER['PHP_AUTH_USER'] == "username" && $_SERVER['PHP_AUTH_PW'] == "password")) {
 header('WWW-Authenticate: Basic realm="torrent"');
 header('HTTP/1.0 401 Unauthorized');
} else {
 passthru('curl -H "Referer: '.$_SERVER['$HTTP_REFERER'].'" -H "User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-us) AppleWebKit/523.10.3 (KHTML, like Gecko) Version/3.0.4 Safari/523.10" -o /path/to/monitored/torrents/folder/remote.torrent "'.$_SERVER['QUERY_STRING'].'"');
}
?><script type="text/javascript">history.back()</script>
Modifications required:
  • Script URL in bookmarklet
  • username in php script
  • password in php script
  • /path/to/monitored/torrents/folder path in php script
There are a few issues, like the fact that some torrent sites don't use standard links for their torrents, and I will probably update the scripts in this entry in my hacks blog.
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[25,333 views]  

Start torrent downloads from an iPhone | 6 comments | Create New Account
Click here to return to the 'Start torrent downloads from an iPhone' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Start torrent downloads from an iPhone
Authored by: fordred on Fri, Dec 28 2007 at 8:50PM PST
Nice tip here. I had trouble setting this up, but I think the following may help.
Firstly, enable php on your mac. The following page helped me with that.
http://mymacinations.com/2007/10/28/apache-php-and-mysql-on-leopard/

Secondly, Choose your torrent folder carefully. Permissions must be set correctly. To avoid hassle, I used my Drop Box. If you do use your Drop Box, it's worth remembering that you should enter ".../Drop\ Box/..." in the settings.

Thirdly, make sure Transmission trashes the torrent file once its picked it up.

On a side not, can I ask why you have the Referral code in there? I changed it match that of my iPhone but even then, I could still use Leopard safari to download the torrent with.

[ Reply to This | # ]
Start torrent downloads from an iPhone
Authored by: Koolio on Sat, Jan 19 2008 at 8:32PM PST
Hey there if you want to get fast downloads for your iphone go here http://iphone-downloads-review.blogspot.com/

[ Reply to This | # ]
Start torrent downloads from an iPhone
Authored by: hzc on Mon, Dec 31 2007 at 5:15AM PST
Or you can use Clutch (http://clutchbt.com/) which uses Transmission under the hood. Then you'll have a web interface. I've not tested this on my iPhone, but it works very well in the desktop version of Safari.

If you have a domain name set up to hit your server/desktop and open up your router appropriately, you can do this while "on the road".

[ Reply to This | # ]
Start torrent downloads from an iPhone
Authored by: svenbox on Wed, Jan 23 2008 at 3:18PM PST
I got this working after some fiddling around, but for me many torrents didnt work because of weird characters in the file names. This was solved by adding -g after curl in the PHP script. See curls documentation if you wanna know more.

This bookmarklet in combination with Clutch gives me full control over Transmission at my home computer from my iPhone!!! Thanks!!

[ Reply to This | # ]
Start torrent downloads from an iPhone
Authored by: jakdominance on Sun, Jan 4 2009 at 8:42PM PST
what is the exact method of the actual download of the torrent from the iPhone? it seems a little ambiguous.

[ Reply to This | # ]
Start torrent downloads from an iPhone
Authored by: kentyman on Sun, Jan 25 2009 at 9:26PM PST