Last active
June 10, 2024 14:29
-
-
Save josedacosta/1569fc24fb8742759e1139cf30c17a3c to your computer and use it in GitHub Desktop.
transmission script torrent done
This file contains 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 | |
RED='\033[0;31m' | |
ORANGE='\033[0;33m' | |
GREEN='\033[0;32m' | |
CYAN='\033[0;36m' | |
NC='\033[0m' # no color | |
TRANSMISSION_REMOTE='/transmission-remote' # your transmission-remote path | |
TRANSMISSION_REMOTE_HOST_PORT='localhost:9091' # localhost:9091 or http://:9091 | |
TRANSMISSION_REMOTE_OPTIONS='--auth :' # --auth <user:pw> set username and password | |
TRANSMISSION="$TRANSMISSION_REMOTE $TRANSMISSION_REMOTE_HOST_PORT $TRANSMISSION_REMOTE_OPTIONS" | |
TORRENT_LIST=`$TRANSMISSION --list | sed -e '1d' -e '$d' | awk '{print $1}' | sed -e 's/[^0-9]*//g'` | |
for TORRENT_ID in $TORRENT_LIST | |
do | |
TORRENT_INFO=$($TRANSMISSION --torrent $TORRENT_ID --info) | |
echo -e "Processing ID:$TORRENT_ID [$(echo $TORRENT_INFO | sed -e 's/.*Name: \(.*\) Hash.*/\1/')]" | |
PERCENT_DONE=`echo $TORRENT_INFO | grep "Done: 100%"` | |
STATE=`echo $TORRENT_INFO | grep "State: Seeding\|State: Stopped\|State: Finished\|State: Idle"` | |
if [ "$PERCENT_DONE" ] && [ "$STATE" ]; then | |
printf " Torrent ID:$TORRENT_ID ${ORANGE}is completed${NC}. ${RED}[!REMOVING! (from list)]${NC}" | |
$TRANSMISSION --torrent $TORRENT_ID --remove | |
else | |
printf " Torrent ID:$TORRENT_ID ${CYAN}is not completed${NC}. ${GREEN}[IGNORING]${NC}" | |
fi | |
echo -e "\n" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment