Created
January 12, 2020 14:45
-
-
Save cybertramp/cbc58b4895df675c0975dae13d93598e to your computer and use it in GitHub Desktop.
transmission-rpc torrent list auto cleaner.
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
| #!/usr/bin/env bash | |
| ###################################################### | |
| # | |
| # transmission finished torrent clear script. | |
| # | |
| # 20.01.12 paran_son@outlook.com | |
| ###################################################### | |
| # | |
| # 포트 => 기본 포트는 9091이며, 따로 지정한 경우는 입력 | |
| # 아이디 => rpc 접속 아이디 입력 | |
| # 패스워드 => rpc 접속 암호 입력 | |
| SERVER="127.0.0.1:포트 --auth 아이디:패스워드" | |
| TORRNET_COUNT=`transmission-remote $SERVER --list | sed -e '1d' -e '$d' | awk '{print $1}' | sed -e 's/[^0-9]*//g'` | |
| # 토렌트 개수 만큼 반복 | |
| for TORRENTID in $TORRENT_COUNT | |
| do | |
| INFO=$(transmission-remote $SERVER --torrent $TORRENTID --info) | |
| echo -e "Processing #$TORRENTID - $(echo $INFO | sed -e 's/.*Name: \(.*\) Hash.*/\1/')" | |
| # torrent 100% 확인 | |
| DL_COMPLETED=`echo $INFO | grep "Done: 100%"` | |
| # torrent 현재 상태 확인 | |
| STATE_STOPPED=`echo $INFO | grep "State: Seeding\|State: Stopped\|State: Finished\|State: Idle"` | |
| # 상태가 완료 된 경우 | |
| if [ "$DL_COMPLETED" ] && [ "$STATE_STOPPED" ]; then | |
| echo "Torrent #$TORRENTID is completed. Removing torrent from list." | |
| transmission-remote $SERVER --torrent $TORRENTID --remove | |
| else | |
| echo "Torrent #$TORRENTID is not completed. Ignoring." | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment