Skip to content

Instantly share code, notes, and snippets.

@iamsilvio
Forked from bulljit/removecompletedtorrents.sh
Last active December 13, 2015 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamsilvio/4963027 to your computer and use it in GitHub Desktop.
Save iamsilvio/4963027 to your computer and use it in GitHub Desktop.
F: Added prowl support
#!/bin/sh
# script to check for complete torrents in transmission folder, then stop and move them
# either hard-code the MOVEDIR variable here…
MOVEDIR=/media/tc/downloads # the folder to move completed downloads to
# …or set MOVEDIR using the first command-line argument
# MOVEDIR=%1
AUTH="PWD"
USER="USER"
# And push a message to PROWL
# Fill in with your own API key here
APIKEY=fffffffffffffffffffffffffffffff
# use transmission-remote to get torrent list from transmission-remote list
# use sed to delete first / last line of output, and remove leading spaces
# use cut to get first field from each line
TORRENTLIST=`transmission-remote --auth=$USER:$AUTH -l | sed -e '1d;$d;s/^ *//' | cut -s -d ' ' -f1`
# for each torrent in the list
for TORRENTID in $TORRENTLIST
do
STARTED=`transmission-remote --auth=$USER:$AUTH -t $TORRENTID -i | grep "Id: $TORRENTID"`
COMPLETED=`transmission-remote --auth=$USER:$AUTH -t $TORRENTID -i | grep "Percent Done: 100%"`
STOPPED=`transmission-remote --auth=$USER:$AUTH -t $TORRENTID -i | grep "State: Stopped"`
NAME=`transmission-remote --auth=$USER:$AUTH -t $TORRENTID -i | grep "Name: "`
# if the torrent is "Stopped" after downloading 100% and seeding, move the files and remove the to$
if [ "$STARTED" != "" ] && [ "$COMPLETED" != "" ] && [ "$STOPPED" != "" ]; then
transmission-remote --auth=$USER:$AUTH -t $TORRENTID --move $MOVEDIR
transmission-remote --auth=$USER:$AUTH -t $TORRENTID --remove
# Post notification to Prowl using curl
curl https://api.prowlapp.com/publicapi/add \
-F apikey=$APIKEY \
-F application=transmission \
-F event="download done" \
-F description="$NAME"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment