Created
February 8, 2015 12:35
-
-
Save rolfvreijdenberger/6b6c9b269d0bb30183be to your computer and use it in GitHub Desktop.
cleaning up torrents from transmission-daemon
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/bash | |
#set username and password for authentication | |
user=transmission | |
password=transmission | |
host=127.0.0.1 | |
port=9091 | |
# get the list of 100% Done and Stopped or Finished torrents. the last sed command removes the * from a torrent id that indicates an error. | |
list=$(transmission-remote $host:$port --auth=$user:$password --list | sed -e '1d;$d;s/^ *//' | grep -e '100%.*Done.*\(Stopped\|Finished\)' | cut --only-delimited --delimiter=' ' --field=1 | sed 's/*//') | |
logger -p cron.info "removing finished torrents: "$list | |
for i in $list ; do | |
logger -p cron.info "removing finished torrent with id: $i"; | |
#remove torrent, keep files | |
transmission-remote --auth=$user:$password --torrent $i --remove | |
logger -p cron.info "torrent $i removed" | |
done; | |
# get the list of Failed torrents, OR those with an error (assume it's non recoverable). | |
# an error in the output means | |
list=$(transmission-remote $host:$port --auth=$user:$password --list | sed -e '1d;$d;s/^ *//' | grep -e '\([[:space:]]+Failed[[:space:]]+\|^[[:space:]]*[[:digit:]]*\*.*Stopped\)' | cut --only-delimited --delimiter=' ' --field=1 | sed 's/*//') | |
logger -p cron.info "removing failed torrents: "$list | |
for i in $list ; do | |
logger -p cron.info "removing failed torrent and files with id: $i"; | |
transmission-remote --auth=$user:$password --torrent $i --remove-and-delete | |
logger -p cron.info "torrent $i removed with files" | |
done; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment