Transmission: set download speed from script

To all whom it may concern:

#!/bin/bash
USER=yourUserName
PASS=yourPassword
server=http://yourTransmissionHostIP
speed=$1

curlout=$(curl -u $USER:$PASS ${server}:9091/transmission/rpc 2>/dev/null)
regex='(X-Transmission-Session-Id\: )([^<]*)'

if [[ $curlout =~ $regex ]]; then
    sessionid=${BASH_REMATCH[2]}
else
    exit 1
fi

if [ $# -eq 0 ] ; then
	data='{"method": "session-set", "arguments": { "speed-limit-down-enabled" : false } }'
else
	data='{"method": "session-set", "arguments": { "speed-limit-down-enabled" : true, "speed-limit-down" :'
	data="$data ${speed} } }"
fi

curl -u $USER:$PASS ${server}:9091/transmission/rpc -d "$data" -H "X-Transmission-Session-Id: $sessionid"  > /dev/null 2>&1

One thought on “Transmission: set download speed from script

  1. Pingback: JSON adatbányászat shellben | eFi.blog

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.