Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- torrentid=$1
- torrentname=$2
- torrentpath=$3
- x=1
- deluge_config="${HOME}/.config/deluge/core.conf"
- log_path="${HOME}/script.log"
- working_torrent=1 # False
- ddport=$(grep '"daemon_port": [0-9]*' "${deluge_config}" | awk -F ': ' '{print $2}' | awk -F ',' '{print $1}')
- echo "Port is $ddport" >> "${log_path}"
- while [ $x -le 100 ] && [ $working_torrent -eq 1 ]; do
- sleep 2
- echo "Execution number $x" >> "${log_path}"
- echo "TorrentID: $torrentid" >> "${log_path}"
- line=$(deluge-console "connect 127.0.0.1:$ddport; info" $1 | grep "Tracker status")
- echo $line >> "${log_path}"
- case "$line" in *unregistered*|*Unregistered*|*Sent*|*End*of*file*|*Bad*Gateway*|*Error*)
- deluge-console "connect 127.0.0.1:$ddport; pause '$torrentid'"
- sleep 2
- deluge-console "connect 127.0.0.1:$ddport; resume '$torrentid'"
- ;;
- *)
- echo "Found working torrent: $torrentname $torrentpath $torrentid" >> "${log_path}"
- # Wait to reannounce to ensure tracker is ready
- sleep 5
- deluge-console "connect 127.0.0.1:${ddport}; reannounce ${torrentid}"
- working_torrent=0 # True
- ;;
- esac
- x=$(( $x + 1 ))
- done
Add Comment
Please, Sign In to add comment