Skip to content

Instantly share code, notes, and snippets.

@fieu
Created August 23, 2021 05:51
Show Gist options
  • Save fieu/6c4f34af5618872f1ae330079129f3d1 to your computer and use it in GitHub Desktop.
Save fieu/6c4f34af5618872f1ae330079129f3d1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
torrentid="$1"
torrentname="$2"
torrentpath="$3"
x=1
ddport=$(grep '"daemon_port": [0-9]*' ~/.config/deluge/core.conf | awk -F ': ' '{print $2}' | awk -F ',' '{print $1}')
host="127.0.0.1"
user="user"
pass="password"
logfile="$HOME/deluge-tracker-update.log"
while [ $x -le 100 ]; do
sleep 2
echo "Running $x times" >>$logfile
echo "TorrentID: $torrentid" >>$logfile
line=$(deluge-console "connect $host:$ddport $user $pass; info" $1 | grep "Tracker status")
echo $line >>$logfile
case "$line" in
*unregistered* | *Sent* | *End*of*file* | *Bad*Gateway* | *Error*)
deluge-console "connect $host:$ddport $user $pass; pause '$torrentid'"
sleep 2
deluge-console "connect $host:$ddport $user $pass; resume '$torrentid'"
;;
*)
echo "Found working torrent: $torrentname $torrentid" >>$logfile
exit 1
;;
esac
x=$(($x + 1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment