Forked from PizzaPete/removecompletedtorrents.sh
Last active
December 2, 2015 01:51
-
-
Save darxtorm/e80be63e8fd4b2c201fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## Made by JD from these two scripts, good for outputting results to a file as a scheduled task | |
## lacks the --auth=user:password as i don't use auth on my server | |
## http://goedonthouden.com/2013/04/21/transmission-daemon-auto-remove-torrents/ | |
## https://gist.github.com/bulljit/791609 | |
TORRENTLIST=`transmission-remote --list | sed -e '1d;$d;s/^ *//' | cut --only-delimited --delimiter=' ' --fields=1` | |
echo "Getting torrent list from transmission" | |
for TORRENTID in $TORRENTLIST | |
do | |
## found these too noisy for output | |
#echo "* * * * * Operations on torrent ID $TORRENTID starting. * * * * *" | |
NAME_IRREGARDLESS=`transmission-remote --torrent $TORRENTID --info | grep "Name:"` | |
DL_IRREGARDLESS=`transmission-remote --torrent $TORRENTID --info | grep "Percent Done:"` | |
DL_COMPLETED=`transmission-remote --torrent $TORRENTID --info | grep "Percent Done: 100%"` | |
STATE_IRREGARDLESS=`transmission-remote --torrent $TORRENTID --info | grep "State:"` | |
## commented out and replaced below as i only want finished torrents, you may edit accordingly | |
#STATE_STOPPED=`transmission-remote --torrent $TORRENTID --info | grep "State: Stopped\|Finished\|Idle"` | |
STATE_STOPPED=`transmission-remote --torrent $TORRENTID --info | grep "State: Finished"` | |
echo "#$TORRENTID $NAME_IRREGARDLESS" | |
if [ "$DL_COMPLETED" != "" ] && [ "$STATE_STOPPED" != "" ]; then | |
echo "Torrent #$TORRENTID is $DL_COMPLETED and $STATE_STOPPED." | |
echo "Removing torrent #$TORRENTID from list." | |
#transmission-remote --torrent $TORRENTID --remove | |
echo "JOKES NOT REALLY, UNCOMMENT LINE ABOVE TO GIVE ME TEETH" | |
else | |
echo "Torrent #$TORRENTID is not completed. $DL_IRREGARDLESS $STATE_IRREGARDLESS" | |
fi | |
## found these too noisy for output | |
#echo "* * * * * Operations on torrent ID $TORRENTID completed. * * * * *" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
doesn't yet remove the torrents as i wish to test it correctly with a torrent that has 'finished' due to inactivity rather than seeding completion. needs no extra user documentation so, just make it executable and run or schedule it