Bash stopFinished


/ Published in: Bash
Save to your folder(s)

This is a little script to stop the torrents in Transmission that are finished downloading. You can put this in a cron job and let it run every hour or less. Essentially turning you into UBER leecher. Hey don't scowl at me, I have to pay for bandwidth!


Copy this code and paste it in your HTML
  1. #!/bin/sh
  2.  
  3. # Download dir, may contain spaces:
  4. watchdir="/share/Download/"
  5.  
  6. bin="/opt/sybhttpd/localhost.drives/HARD_DISK/Apps/Transmission/bin/transmission-remote"
  7.  
  8. # Authentication "username:password":
  9. tr_auth="nmt:1234"
  10.  
  11. # Transmission host "ip:port":
  12. tr_host="127.0.0.1:9091"
  13.  
  14. if [ -n "$tr_auth" ]; then
  15. tr_auth="--auth=$tr_auth"
  16. fi
  17.  
  18. # Ok from this point on its a bit hack and slash so apologies
  19. # But we essentially go through the transmission list of torrents
  20. # If the torrent is downloaded 100%
  21. # Then we take it out of transmission and we make .finished file
  22.  
  23. $bin "$tr_host" "$tr_auth" -l | awk '{
  24. if ($1 != "Sum:" && $1 != "ID") {
  25. print $1,$2
  26. }
  27. }' | while read id percent
  28. do
  29. if [ $percent = "100%" ]
  30. then
  31. reply="`$bin -t "$id" -i | grep -E '^ Name|^ Hash'`"
  32. name="`echo "$reply" | grep '^ Name' | cut -c 9-`"
  33. hash="`echo "$reply" | grep '^ Hash' | cut -c 9-`"
  34. touch "$watchdir$name.finished"
  35. t=`$bin -t $id -r`
  36. sleep 5
  37. fi
  38. done
  39. exit 0

URL: http://www.goingson.be

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.