Created
February 26, 2018 16:44
-
-
Save noodny/f5fe42f4f871bf9b4c804ddcbb09ccf9 to your computer and use it in GitHub Desktop.
Link magnet files to a transmission deamon running rpc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on open location magnet_link | |
set hostname to "192.168.0.6" | |
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 | |
else | |
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