Skip to content

Instantly share code, notes, and snippets.

@shreve
Last active June 12, 2018 00:43
Show Gist options
  • Save shreve/2ec1cae79426ee241b44b6296b003125 to your computer and use it in GitHub Desktop.
Save shreve/2ec1cae79426ee241b44b6296b003125 to your computer and use it in GitHub Desktop.
uTorrent add script
#!/usr/bin/env bash
# This script uses HTTPie, but could easily be adapted to use cURL.
# Change the host to be the location of your uTorrent server.
# Start this script and you'll get a prompt to paste in magnet links or links to torrent files
host=http://192.168.0.111:8080
rpc=$host/gui/
token=""
add_torrent() {
http --verbose \
--session utorrent \
GET $rpc \
action==add-url \
s=="$1" \
token==$token
}
log_in() {
http --session utorrent --auth admin: GET ${rpc}web/index.html > /dev/null
token=$(http --session utorrent GET ${rpc}token.html | sed -E 's/<[^<>]+>//g')
}
log_in
while read -r -p 'add torrent -> ' link
do
add_torrent "$link"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment