Skip to content

Instantly share code, notes, and snippets.

@roblingle
Created November 2, 2009 02:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roblingle/223897 to your computer and use it in GitHub Desktop.
Save roblingle/223897 to your computer and use it in GitHub Desktop.
(*
Folder action to queue downloaded torrents in your uTorrent web gui. With a dyndns account you can initiate downloads on your file server from wherever you happen to be.
Gotta have uTorrent with web gui (Windows, Mac, or Linux with Wine).
Gotta have growl, too.
- Paste into Script Editor
- Edit the user, password, and server url below.
- Add as a folder action on your download directory
- Grab a utorrent icon: curl -o ~/Library/Images/utorrent.png http://is.gd/bz8j
- Download some torrents (check growl prefs if you want to customize notifications)
*)
property user : "username"
property pass : "password"
property server : "http://utorrent_url"
property icon_file : "~/Library/Application Support/uTorrent/utorrent.png"
on growl_registration()
tell application "GrowlHelperApp"
set the all_notifications_list to {"torrent count", "torrent queued"}
set the enabled_notifications_list to {"torrent count"}
register as application ¬
"Downloaded torrents folder action" all notifications all_notifications_list ¬
default notifications enabled_notifications_list ¬
icon of application "Script Editor"
end tell
end growl_registration
on growl_count(the_count)
set the message to (the_count as text) & " torrent"
if the_count > 1 then
set the message to message & "s"
end if
set the message to message & " added to queue"
tell application "GrowlHelperApp"
notify with name "torrent count" title "Downloading" description message ¬
application name "Downloaded torrents folder action" image from location icon_file
end tell
end growl_count
on growl_queued(torrent)
tell application "GrowlHelperApp"
notify with name "torrent queued" title "Torrent queued" description (name of the torrent) ¬
application name "Downloaded torrents folder action" image from location icon_file
end tell
end growl_queued
on adding folder items to this_folder after receiving added_items
try
growl_registration()
tell application "Finder"
set torrent_list to every file in this_folder whose name ends with ".torrent"
end tell
repeat with torrent in torrent_list
do shell script ("curl -u " & user & ":" & pass & " -F press=OK " & server & "/gui/?action=add-file -F torrent_file=@'" & POSIX path of (torrent as alias)) & "'"
growl_queued(torrent)
delete torrent
end repeat
(*set torrent_count to the number of items in the torrent_list*)
if torrent_count > 0 then
growl_count(torrent_count)
end if
end try
end adding folder items to
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment