Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # magenetLinkTransfer.sh
- # slapped together as a more controlled method of passing magnet urls to transmission-daemon
- # when the transgui and transmission-remote apps failed to do so.
- #
- # retreive argument(s) as $LINK
- LINK=("$1")
- # if no argument is given, error out.
- if [ -z "$LINK" ]; then
- echo "ERROR: need magnet link"
- exit 1
- fi
- # DEBUG purposes, dump the argument passed into a log file.
- echo $LINK >> /tmp/magnetlinktransfer.log
- # transmission-daemon connection information. [sensored for pastebin]
- HOST=127.0.0.1
- PORT=9091
- USER="username"
- PASS="password"
- # gather authentication session identifier from transmission-daemon rpc
- SESSID=$(curl --silent --anyauth --user $USER:$PASS "http://$HOST:$PORT/transmission/rpc" | sed 's/.*<code>//g;s/<\/code>.*//g')
- # DEBUG purposes, show in terminal (the .desktop called for magnet links will show terminal when calling this)
- echo ${LINK}
- # send request to add torrent to the transmission-daemon
- curl --silent --anyauth --user $USER:$PASS --header "$SESSID" "http://$HOST:$PORT/transmission/rpc" -d "{\"method\":\"torrent-add\",\"arguments\":{\"filename\":\"${LINK}\"}}"
- # DEBUG purposes, pause the script before finishing to allow review of the terminal window.
- read -n1 -r -p 'Press any key to continue...' key
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement