Advertisement
Rpsl

Translimit.sh Patch

Jan 23rd, 2012
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.06 KB | None | 0 0
  1. #!/bin/sh
  2. # *************
  3. # transmission-remote-queue version 0.2
  4. # Contact sam.day (at) gmail.com with suggestions, corrections, etc.
  5. # Based on wereHampster's script from http://pastie.org/357236
  6. # Modified by super-poussin
  7. # *************
  8. # Variables
  9. #
  10. # Path to transmission-remote
  11. REMOTE="/usr/local/bin/transmission-remote"
  12. # Maximum number of active torrents (downloading + seeding)
  13. MAXACTIVE="3"
  14. # Maximum number of downloading torrents
  15. MAXDOWNLOADING="2"
  16. # Download ratio at which to stop seeding
  17. DESIREDRATIO="1.3"
  18. # Options to be passed to transmission-remote
  19. TRANSOPT=" localhost:8181 -n admin:password1"
  20. # Turn on/off adding extra slots if bandwidth to spare. Boolean.
  21. # Recommend disabling if using 'turtle mode'
  22. MODSLOTS=0
  23. # Extra download slot added if download speed is below this value and MODSLOT=1
  24. DOWNLOADLIMIT="700.0"
  25. # If MAXFIRST = 1 seed torrents with Highest ratio First
  26. MAXFIRST=1
  27. # *************
  28.  
  29.  
  30. # Add extra download slot if required
  31. if [ $MODSLOTS -eq 1 ]; then
  32.     DOWNLOADSPEED="$($REMOTE -l | tail -n -1 | sed 's/^\s\+//g' | sed 's/\s\{2,\}/~/g' | cut -d '~' -f4)"
  33.     if expr $DOWNLOADSPEED \<= $DOWNLOADLIMIT > /dev/null; then
  34.         MAXDOWNLOADING=$(($MAXDOWNLOADING+1))
  35.     fi
  36.     if [ $MAXDOWNLOADING -gt $MAXACTIVE ]; then
  37.         MAXACTIVE=$MAXDOWNLOADING
  38.     fi
  39. # debugging output (3 lines)
  40. echo "Current download speed: $DOWNLOADSPEED KB/s"
  41. echo "Lower threshold before adding a slot: $DOWNLOADLIMIT KB/s"
  42. echo "Download slots: $MAXDOWNLOADING"
  43. fi
  44.  
  45. # Stop torrents upper desired ratio
  46. #LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep 100% |grep Seeding | awk '{ print $1; }')"
  47. #for ID in $LIST; do
  48. #    RATIO="$($REMOTE $TRANSOPT -t $ID -i | grep Ratio | awk '{ print $2; }')"
  49. #    if expr $RATIO \>= $DESIREDRATIO > /dev/null; then
  50. #        NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
  51. #        echo "Stop Torrent: $ID - ${NAME#*Name: } (Ratio $RATIO)"
  52. #        $REMOTE $TRANSOPT --torrent $ID --stop > /dev/null
  53. #    fi
  54. #done
  55.  
  56. # Start downloading new torrents if download slots exist
  57. DOWNLOADING="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v Stopped | grep -v 100% | wc -l)"
  58. if [ $DOWNLOADING -lt $MAXDOWNLOADING ]; then
  59.     LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v 100% | grep Stopped | head -n $(expr $MAXDOWNLOADING - $DOWNLOADING) | awk '{ print $1; }')"
  60.     for ID in $LIST; do
  61.         NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
  62.         echo "Downloading Torrent: $ID - ${NAME#*Name: }"
  63.         $REMOTE $TRANSOPT --torrent $ID --start --verify > /dev/null
  64.     done
  65. fi
  66.  
  67. # Seed torrents below desired ratio if slots exist
  68. ACTIVE="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v Stopped | wc -l)"
  69. if [ $ACTIVE -lt $MAXACTIVE ]; then
  70.     LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep 100% | tail -n $(expr $MAXACTIVE - $ACTIVE) | awk '{ print $1; }'| awk -F "*" '{ print $1}')"
  71.     RAT="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep 100% | tail -n $(expr $MAXACTIVE - $ACTIVE) | sed 's/^\s\+//g' | sed 's/\s\{2,\}/~/g' | cut -d '~' -f7)"
  72.     if [ $MAXFIRST -eq 1 ]; then
  73.      RAT2=$(echo $RAT | sed 's/ /\n/g' | sort -u -r)
  74.     fi
  75.     if [ $MAXFIRST -eq 0 ]; then
  76.      RAT2=$(echo $RAT | sed 's/ /\n/g' | sort -u)
  77.     fi
  78.     for LOWEST in $RAT2; do
  79.         for ID in $LIST; do
  80.             RATIO="$($REMOTE $TRANSOPT -t $ID -i | grep Ratio: | awk '{ print $2; }')"
  81.             if expr $RATIO \= $LOWEST  > /dev/null; then
  82.                 NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
  83.                 echo "Seeding Torrent: $ID - ${NAME#*Name: } (Ratio $RATIO)"
  84.                 $REMOTE $TRANSOPT --torrent $ID --start --verify > /dev/null
  85.                 break
  86.             fi
  87.         done
  88.     done
  89. fi
  90.  
  91. # List Active Torrents
  92. LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v Stopped | awk '{ print $1; }'| awk -F "*" '{ print $1}')"
  93. for ID in $LIST; do
  94.     NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
  95.     echo "Active: $ID - ${NAME#*Name: }"
  96. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement