Advertisement
DarthShadow

Deluge Reannounce

Mar 27th, 2018
1,226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.80 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # This script required the update-tracker.py from https://raw.githubusercontent.com/s0undt3ch/Deluge/master/deluge/ui/console/commands/update-tracker.py
  4.  
  5. # Change the below output location to any folder owned by your user for which you have write permissions
  6. OUTPUT="/home/darthshadow/scripts"
  7.  
  8. torrentid=$1
  9. torrentname=$2
  10. torrentpath=$3
  11.  
  12. # Update the ip & port below according to your configuration
  13. ip=127.0.0.1
  14. port=24000
  15.  
  16. x=1
  17. while [ $x -le 1000 ]
  18. do
  19.   sleep 5
  20.   echo "Running $x times" >> "${OUTPUT}/script.log"
  21.   echo "TorrentID: $torrentid" >> "${OUTPUT}/script.log"
  22.   info=$(deluge-console "connect '$ip':'$port'; info" $1)
  23.   line=$(echo "$info" | grep "Tracker status")
  24.   # echo $line >> "${OUTPUT}/script.log"
  25.   case "$line" in
  26.     *unregistered*|*Sent*|*End*of*file*|*Bad*Gateway*|*Error*)
  27.       # deluge-console "connect '$ip':'$port'; pause '$torrentid'; resume '$torrentid'" >> "${OUTPUT}/deluge.output" 2>&1
  28.       deluge-console "connect '$ip':'$port'; update-tracker '$torrentid'" >> "${OUTPUT}/deluge.output" 2>&1
  29.       ;;
  30.     *)
  31.       seeds=$(echo "$info" | grep "Seeds")
  32.       total_seeds=$(echo $seeds | awk '{print $3}' | sed -r 's/\(|\)//g')
  33.       connected_seeds=$(echo $seeds | awk '{print $2}')
  34.       echo "Seeds: $connected_seeds ($total_seeds)" >> "${OUTPUT}/script.log" 2>&1
  35.       if (( $connected_seeds > 0 )) || (( $total_seeds > 0 )); then
  36.         echo "Found working torrent: $torrentname $torrentpath $torrentid" >> "${OUTPUT}/script.log" 2>&1
  37.         exit 1
  38.       else
  39.         # deluge-console "connect '$ip':'$port'; pause '$torrentid'; resume '$torrentid'" >> "${OUTPUT}/deluge.output" 2>&1
  40.         deluge-console "connect '$ip':'$port'; update-tracker '$torrentid'" >> "${OUTPUT}/deluge.output" 2>&1
  41.       fi
  42.       ;;
  43.   esac
  44.   x=$(( $x + 1 ))
  45. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement