This AppleScript runs a handler script that responds to the "magnet:" URL.  It will read in the passed URL, execute a shell script to parse the relevant content and save a torrent file into a directory specified by watch_dir property. The variable magnet_script is a terse embedded bash script that quickly parses the URL and writes the torrent file to disk.