Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Link magnet files to a transmission deamon running rpc
on open location magnet_link
set hostname to ""
set portname to "9091"
set rpc_url to "http://" & hostname & ":" & portname & "/transmission/rpc"
set cmd to "curl --silent " & rpc_url & " | sed 's/.*<code>//g;s/<\\/code>.*//g'"
set session_id to do shell script cmd
set add_cmd to "curl --silent --header \"" & session_id & "\" " & rpc_url & " -d \"{\\\"method\\\":\\\"torrent-add\\\",\\\"arguments\\\":{\\\"paused\\\":false,\\\"filename\\\":\\\"" & magnet_link & "\\\"}}\""
set response to do shell script add_cmd
set added_index to offset of "added" in response
set duplicate_index to offset of "duplicate" in response
if added_index is not 0 then
display notification "Torrent added succesfully"
delay 1
else if duplicate_index is not 0 then
display notification "Torrent is already on the list!"
delay 1
display dialog "Error adding the torrent: " & response
end if
end open location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.