Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # script to check for complete torrents in transmission folder, then remove them and their associated files
- ###########
- # CONFIG #
- ###########
- # Access Information for Transmission
- USERNAME=
- PASSWORD=
- #Installation directory of transmission
- INSTALLPATH="/volume1/@appstore/transmission"
- #Host on which transmission runs
- HOST=localhost
- #Port
- PORT=9091
- # use transmission-remote to get torrent list from transmission-remote list
- TORRENTLIST=`$INSTALLPATH/bin/transmission-remote $HOST:$PORT --auth=$USERNAME:$PASSWORD --list | awk '{print $1}' | grep '[0-9]'`
- # for each torrent in the list
- for TORRENTID in $TORRENTLIST
- do
- echo "* * * * * Operations on torrent ID $TORRENTID starting. * * * * *"
- # check if torrent download is completed
- DL_COMPLETED=`$INSTALLPATH/bin/transmission-remote $HOST:$PORT --auth=$USERNAME:$PASSWORD --torrent $TORRENTID --info | grep "Percent Done: 100%"`
- # check torrents current state is "Stopped", "Finished", or "Idle"
- STATE_STOPPED=`$INSTALLPATH/bin/transmission-remote $HOST:$PORT --auth=$USERNAME:$PASSWORD --torrent $TORRENTID --info | grep "State: Stopped\|Finished\|Idle"`
- # if the torrent is "Stopped", "Finished", or "Idle" after downloading 100%"
- if [ "$DL_COMPLETED" != "" ] && [ "$STATE_STOPPED" != "" ]; then
- echo "Torrent #$TORRENTID is completed."
- # remove torrent and data from Transmission
- echo "Removing torrent from list."
- $INSTALLPATH/bin/transmission-remote $HOST:$PORT --auth=$USERNAME:$PASSWORD --torrent $TORRENTID --remove-and-delete
- else
- echo "Torrent #$TORRENTID is not completed. Ignoring."
- fi
- echo "* * * * * Operations on torrent ID $TORRENTID completed. * * * * *"
- done
Advertisement
Add Comment
Please, Sign In to add comment