Save torrent attachments

October 14, 2007

Mail.app
For a while we’ve been using our fileserver as a torrent box. It runs Azureus 2.4.0 headless: without the über slow java GUI. To control it we use the very simple and elegant Azureus widget. This is also the reason it runs 2.4.0; it’s the only version working nicely with the widget.

This is great when you’re at home, but how to add torrents to the download queue when you’re not? Of course you can open your network and work with a web based interface, but it’s a security hazard and not everybody knows how dyndns works. This is how I fixed it: send e-mails with .torrent attachments to a dedicated e-mail address. Let Mail.app check this dedicated e-mail address every 5 minutes or so and when it detects a .torrent file, save it to the Azureus dropbox. After the break I’ll show you the Applescript code and the Mail.app rules.

First you’ll need to create the Applescript for saving the .torrent file:

using terms from application "Mail"

on perform mail action with messages theMessages for rule theRule

tell application "Mail"

repeat with oneMessage in theMessages

set {mail attachment:theAttachments} to oneMessage

repeat with oneAttachment in mail attachments of oneMessage

save oneAttachment in ("Macintosh HD:Your drop box folder:") & (name of oneAttachment)

-- please change the location above, otherwise it'll never work.

end repeat

end repeat

end tell

end perform mail action with messages

end using terms from

Now setup the proper rules in Mail.app (click thumbnail):

rules

For a dedicated e-mail address you can create a gmail account for free.

Good luck!

Tags: , ,

3 Responses to “Save torrent attachments”

  1. markpith Says:

    PS
    Look out for the wordpress “smart quotes” and hyphens when directly copy-pasted from your browser.

    Now that Gmail supports IMAP IDLE, it might be a better option than checking the e-mail every 5 minutes.

  2. John Fowler Says:

    Thank you for this script. I’ve tried it and it works smoothly. Having tried other published scripts to download mail attachments I have been frustrated in that they don’t appear to work and when I try troubleshooting them by adding some “dialogs” to track progress, Mail seems to crash, usually at the step where I get the attachment or its properties. While I don’t understand the syntax in the statement,

    set {mail attachment:theAttachments} to oneMessage

    it must be a peculiarity of Mail syntax because it works. (it seems to me that you would use, set theAttachments to mail attachment of oneMessage- but this step is where my previous efforts consistently foundered and your version works.)

    This is very helpful and it seems to me that enough users would want to be able to auto-download selected attachments that it would even be useful for Apple to make a Mail Rule option for this. They may be concerned about security issues I guess….


  3. Thanks for this script, excellent! I used this in conjunction with Hazel and an iPhone app: http://www.noodlesoft.com/forums/viewtopic.php?f=3&t=607


Leave a Reply