Skip to content

Instantly share code, notes, and snippets.

@Sakurina
Created March 13, 2012 21:15
Show Gist options
  • Save Sakurina/2031664 to your computer and use it in GitHub Desktop.
Save Sakurina/2031664 to your computer and use it in GitHub Desktop.
seaside - quickly start torrents in transmission from your iOS devices

seaside

seaside is a script that lets you quickly start torrents on Transmission on your home computer from an iOS device. How quickly? As quickly as copying the URL to the torrent file or a magnet link to the clipboard.

Requirements

  • Transmission with the Web server enabled
  • MyScripts on your iOS device
  • You must be on the same LAN as your computer or have port forwarding and whatnot configured. Currently, this does not work with password-protected servers.

How to Use

  • Add seaside to MyScripts. Launch this page on your iOS device to set it up.
  • When you want to add torrents, launch MyScripts tick the checkbox for seaside on the right side of the screen. This will enable clipboard monitoring in the background for ten minutes.
  • In the browser of your choice, copy a URL to a torrent file or a magnet link to the clipboard. seaside will attempt to start the torrent on your home computer in the background and send you a notification on whether or not it succeeded.
    • Bonus tip: You can copy a list of several URLs/magnet links separated by line breaks and seaside will start all of them at once.
# seaside - quickly start torrents in transmission from your iOS devices
# by Yanik Magnan - http://r-ch.net
# OPTIONS
HOST = "JESUISDOUZEETQUELESTCECI" # change this to the root of your Transmission Web server
RPC_URL = "#{HOST}/transmission/rpc"
# HELPERS
rpc_json_params = (method, args) ->
JSON.stringify(method: method, arguments: args)
send_rpc_call = (method, args, callback) ->
qs = rpc_json_params method, args
xhr = new XMLHttpRequest()
xhr.open "POST", RPC_URL, false
xhr.setRequestHeader "X-Transmission-Session-Id", LOAD_JSON "session_id"
xhr.onreadystatechange = () ->
if xhr.readyState == 4
if xhr.status == 200
response_obj = JSON.parse xhr.responseText
callback response_obj
else if xhr.status == 409
session_id = xhr.getResponseHeader "X-Transmission-Session-Id"
SAVE_JSON "session_id", session_id
send_rpc_call method, args, callback
xhr.send qs
add_torrent = (url, callback) ->
send_rpc_call "torrent-add", filename: url, callback
# MAIN
main = () ->
OUT = "Failed to add torrent."
urls = TEXT.split "\n"
if urls.length == 1
add_torrent urls[0], (response) ->
OUT = "Torrent successfully added." if response.result == "success"
else
total_count = urls.length
success_count = 0
for url in urls
add_torrent url, (response) ->
success_count += 1 if response.result == "success"
OUT = "#{success_count}/#{total_count} torrents successfully added." if success_count >= 1
OUT
return main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment