gofireworks

Untitled

May 27th, 2022 (edited)
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. torrentid=$1
  4. torrentname=$2
  5. torrentpath=$3
  6. x=1
  7.  
  8. deluge_config="${HOME}/.config/deluge/core.conf"
  9. log_path="${HOME}/script.log"
  10. working_torrent=1 # False
  11. ddport=$(grep '"daemon_port": [0-9]*' "${deluge_config}" | awk -F ': ' '{print $2}' | awk -F ',' '{print $1}')
  12.  
  13. echo "Port is $ddport" >> "${log_path}"
  14. while [ $x -le 100 ] && [ $working_torrent -eq 1 ]; do
  15.  
  16. sleep 2
  17.  
  18. echo "Execution number $x" >> "${log_path}"
  19. echo "TorrentID: $torrentid" >> "${log_path}"
  20.  
  21. line=$(deluge-console "connect 127.0.0.1:$ddport; info" $1 | grep "Tracker status")
  22. echo $line >> "${log_path}"
  23.  
  24. case "$line" in *unregistered*|*Unregistered*|*Sent*|*End*of*file*|*Bad*Gateway*|*Error*)
  25. deluge-console "connect 127.0.0.1:$ddport; pause '$torrentid'"
  26. sleep 2
  27. deluge-console "connect 127.0.0.1:$ddport; resume '$torrentid'"
  28. ;;
  29.  
  30. *)
  31. echo "Found working torrent: $torrentname $torrentpath $torrentid" >> "${log_path}"
  32.  
  33. # Wait to reannounce to ensure tracker is ready
  34. sleep 5
  35.  
  36. deluge-console "connect 127.0.0.1:${ddport}; reannounce ${torrentid}"
  37.  
  38. working_torrent=0 # True
  39. ;;
  40.  
  41. esac
  42.  
  43. x=$(( $x + 1 ))
  44. done
  45.  
Add Comment
Please, Sign In to add comment