Skip to content

Instantly share code, notes, and snippets.

@USA-RedDragon
Created March 2, 2023 06:57
Show Gist options
  • Save USA-RedDragon/57417d9f211e6af9404eb1c467ee5ed9 to your computer and use it in GitHub Desktop.
Save USA-RedDragon/57417d9f211e6af9404eb1c467ee5ed9 to your computer and use it in GitHub Desktop.
Deluge racing script
#!/bin/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}')
while [ $x -le 100 ]
do
echo "Running $x times" >> ~/script.log
echo "TorrentID: $torrentid" >> ~/script.log
line=$(deluge-console "connect 127.0.0.1:$ddport; info" $1 | grep "Tracker status")
echo $line >> ~/script.log
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" >> ~/script.log
x=101
;;
esac
x=$(( $x + 1 ))
done
avail=$(deluge-console "connect 127.0.0.1:$ddport; info '$torrentid'" | grep 'Seeds' | awk '{ print $8 }')
while (( $(echo "$avail <= 0" | bc -l) ))
do
deluge-console "connect 127.0.0.1:$ddport; pause '$torrentid'"
sleep 1
deluge-console "connect 127.0.0.1:$ddport; resume '$torrentid'"
sleep 1
echo "Calling update_tracker on torrent: $torrentname $torrentid" >> ~/script.log
deluge-console "connect 127.0.0.1:$ddport; update_tracker '$torrentid'"
avail=$(deluge-console "connect 127.0.0.1:$ddport; info '$torrentid'" | grep 'Seeds' | awk '{ print $8 }')
done
echo "Found available torrent: $torrentname $torrentpath $torrentid" >> ~/script.log
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment