[REL] transmission-remote-queue v0.2

Discussion of Transmission that doesn't fit in the other categories
disc0rd
Posts: 4
Joined: Wed Dec 02, 2009 9:37 am

[REL] transmission-remote-queue v0.2

Postby disc0rd » Wed Dec 02, 2009 9:49 am

Hey folks

I decided to write a bash script designed to run as a cron job to handle queuing. It's in its infancy, but please check it out and let me know what you think :)

Edit:
Found the orignal. Big Thanks to wereHamster :D
http://pastie.org/357236

Edit 2010.01.23:
Version 0.2 released
Incorporated changes from super-poussin and Kirbo - awesome work, guys

Code: Select all

#!/bin/sh
# *************
# transmission-remote-queue version 0.2
# Contact sam.day (at) gmail.com with suggestions, corrections, etc.
# Based on wereHampster's script from http://pastie.org/357236
# *************
# Variables
#
# Path to transmission-remote
REMOTE="/usr/local/bin/transmission-remote"
# Maximum number of active torrents (downloading + seeding)
MAXACTIVE="3"
# Maximum number of downloading torrents
MAXDOWNLOADING="2"
# Download ratio at which to stop seeding
DESIREDRATIO="1.5"
# Options to be passed to transmission-remote
TRANSOPT=" localhost:9091"
# Turn on/off adding extra slots if bandwidth to spare. Boolean.
# Recommend disabling if using 'turtle mode'
MODSLOTS=0
# Extra download slot added if download speed is below this value and MODSLOT=1
DOWNLOADLIMIT="700.0"
# *************

# Add extra download slot if required
if [ $MODSLOTS -eq 1 ]; then
    DOWNLOADSPEED="$($REMOTE -l | tail -n -1 | awk '{ print $5; }')"
    if expr $DOWNLOADSPEED \<= $DOWNLOADLIMIT > /dev/null; then
        MAXDOWNLOADING=$(($MAXDOWNLOADING+1))
    fi
    if [ $MAXDOWNLOADING -gt $MAXACTIVE ]; then
        MAXACTIVE=$MAXDOWNLOADING
    fi
# debugging output (3 lines)
echo "Current download speed: $DOWNLOADSPEED KB/s"
echo "Lower threshold before adding a slot: $DOWNLOADLIMIT KB/s"
echo "Download slots: $MAXDOWNLOADING"
fi

# Stop torrents upper desired ratio
LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep 100% |grep Seeding | awk '{ print $1; }')"
for ID in $LIST; do
    RATIO="$($REMOTE $TRANSOPT -t $ID -i | grep Ratio | awk '{ print $2; }')"
    if expr $RATIO \>= $DESIREDRATIO > /dev/null; then
        NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
        echo "Stop Torrent: $ID - ${NAME#*Name: } (Ratio $RATIO)"
        $REMOTE $TRANSOPT --torrent $ID --stop > /dev/null
    fi
done

# Start downloading new torrents if download slots exist
DOWNLOADING="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v Stopped | grep -v 100% | wc -l)"
if [ $DOWNLOADING -lt $MAXDOWNLOADING ]; then
    LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v 100% | grep Stopped | head -n $(expr $MAXDOWNLOADING - $DOWNLOADING) | awk '{ print $1; }')"
    for ID in $LIST; do
        NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
        echo "Downloading Torrent: $ID - ${NAME#*Name: }"
        $REMOTE $TRANSOPT --torrent $ID --start --verify > /dev/null
    done
fi

# Seed torrents below desired ratio if slots exist
ACTIVE="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v Stopped | wc -l)"
if [ $ACTIVE -lt $MAXACTIVE ]; then
    LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep 100% | tail -n $(expr $MAXACTIVE - $ACTIVE) | awk '{ print $1; }')"
    RAT="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep 100% | tail -n $(expr $MAXACTIVE - $ACTIVE) | awk '{ print $8; }')"
    RAT2=$(echo $RAT | sed 's/ /\n/g' | sort -u)
    for LOWEST in $RAT2; do
        for ID in $LIST; do
            RATIO="$($REMOTE $TRANSOPT -t $ID -i | grep Ratio | awk '{ print $2; }')"
            if expr $RATIO \= $LOWEST > /dev/null; then
                NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
                echo "Seeding Torrent: $ID - ${NAME#*Name: } (Ratio $RATIO)"
                $REMOTE $TRANSOPT --torrent $ID --start --verify > /dev/null
                break
            fi
        done
    done
fi

# List Active Torrents
LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v Stopped | awk '{ print $1; }')"
for ID in $LIST; do
    NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
    echo "Active: $ID - ${NAME#*Name: }"
done
Last edited by disc0rd on Sat Jan 23, 2010 7:31 am, edited 2 times in total.

super-poussin
Posts: 74
Joined: Sun Mar 15, 2009 8:04 pm

Re: [REL] transmission-remote-queue v0.1

Postby super-poussin » Sat Jan 16, 2010 8:47 am

#!/bin/bash
# *************
# transmission-remote-queue version 0.1
# Contact sam.day (at) gmail.com with suggestions, corrections, etc.
# Based on wereHampster's script from http://pastie.org/357236
# Modified by super-poussin to handle authentification
# also take care of ratio
# and no more stop all torrent at startup
# *************
# Variables
#
# Path to transmission-remote
REMOTE="/usr/local/bin/transmission-remote"
MAXACTIVE="3"
MAXDOWNLOADING="2"
DESIREDRATIO="1.5"
TRANSOPT=" localhost:8181 -n admin:password1"
# *************

# Stop torrents that have finished downloading
#LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep 100% | grep -v Stopped | awk '{ print $1; }')"
#for ID in $LIST; do
# NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
# echo "Stopping Torrent: $ID - ${NAME#*Name: }"
# $REMOTE $TRANSOPT --torrent $ID --stop >/dev/null
#done

# Stop torrents upper desired ratio

LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep 100% |grep Seeding | awk '{ print $1; }')"
for ID in $LIST; do
RATIO="$($REMOTE $TRANSOPT -t $ID -i | grep Ratio | awk '{ print $2; }')"
if expr $RATIO \>= $DESIREDRATIO > /dev/null; then
NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
#echo "Stop Torrent: $ID - ${NAME#*Name: } (Ratio $RATIO)"
$REMOTE $TRANSOPT --torrent $ID --stop >/dev/null
fi
done




# Start downloading new torrents if download slots exist
DOWNLOADING="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v Stopped | grep -v 100% | wc -l)"
if [ $DOWNLOADING -lt $MAXDOWNLOADING ]; then
LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v 100% | grep Stopped | head -n $(expr $MAXDOWNLOADING - $DOWNLOADING) | awk '{ print $1; }')"
for ID in $LIST; do
NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
#echo "Downloading Torrent: $ID - ${NAME#*Name: }"
$REMOTE $TRANSOPT --torrent $ID --start --verify >/dev/null
done
fi

# Seed torrents below desired ratio if slots exist

ACTIVE="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v Stopped | wc -l)"
if [ $ACTIVE -lt $MAXACTIVE ]; then
LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep 100% | tail -n $(expr $MAXACTIVE - $ACTIVE) | awk '{ print $1; }')"
RAT="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep 100% | tail -n $(expr $MAXACTIVE - $ACTIVE) | awk '{ print $8; }')"
RAT2=$(echo $RAT | sed 's/ /\n/g' | sort -u)
for LOWEST in $RAT2 ; do
for ID in $LIST; do
RATIO="$($REMOTE $TRANSOPT -t $ID -i | grep Ratio | awk '{ print $2; }')"
if expr $RATIO \= $LOWEST > /dev/null; then
NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
# echo "Seeding Torrent: $ID - ${NAME#*Name: } (Ratio $RATIO)"
$REMOTE $TRANSOPT --torrent $ID --start --verify >/dev/null
break
fi
done
done
fi

# List Active Torrents
#LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v Stopped | awk '{ print $1; }')"
#for ID in $LIST; do
# NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
# echo "Active: $ID - ${NAME#*Name: }"
#done

super-poussin
Posts: 74
Joined: Sun Mar 15, 2009 8:04 pm

Re: [REL] transmission-remote-queue v0.1

Postby super-poussin » Sat Jan 16, 2010 12:21 pm

updated another time :)

disc0rd
Posts: 4
Joined: Wed Dec 02, 2009 9:37 am

Re: [REL] transmission-remote-queue v0.2

Postby disc0rd » Sat Jan 23, 2010 2:59 am

Finally found some time to work on this...
Big thanks to super-poussin and Kirbo (via email) for some great changes/fixes and of course to wereHampster for the original.

Changelog
----------------
* Changed the hash-bang from /bin/bash to /bin/sh
* Torrents now correctly do not seed if they've reached the desired ratio
* No more unnecessary stopping of downloading torrents
* Added option to add an extra download slot if there's bandwidth to spare
* Added ability to pass options to transmission-remote (ie password, port, etc.)
* Torrents with lowest ratio now given seeding priority
* Tidied code and added extra comments


TODO
----------------
* Expand the dynamic adding of slots if there's bandwidth to spare function.



I hope this is coming in handy for people, I know it's made life easier for me...
I'd really love some feedback from people on high-speed connections - it occurred to me that cron-hourly might not be running this often enough in some cases and there may be other issues arising... I wouldn't know, I have Australian broadband :(
I'd prefer feedback/questions to go in this thread instead of email if possible, but email is fine.

-- disc0rd

Longinus00
Posts: 137
Joined: Fri Aug 21, 2009 5:46 am

Re: [REL] transmission-remote-queue v0.2

Postby Longinus00 » Sat Jan 23, 2010 2:36 pm

The problem with using AWK the way you do is that the indices for things you want to match will change because of the spaces that get introduced into the formatting.

Consider the following two lines:

Code: Select all

   1   100%     1.4 GB  7 hrs        70.0     0.0   0.73  Seeding      Torrent 1
   2   100%     3.4 GB  Unknown       0.0     0.0   0.73  Seeding      Torrent 2


Code: Select all

awk '{ print $8; }'

will give 0.0 for the first line and 0.73 for the second.

A better choice might be

Code: Select all

sed 's/^\s\+//g' | sed 's/\s\{2,\}/~/g' | cut -d '~' -f7

super-poussin
Posts: 74
Joined: Sun Mar 15, 2009 8:04 pm

Re: [REL] transmission-remote-queue v0.2

Postby super-poussin » Sun Jan 24, 2010 4:07 pm

I do this new version
clean some result sent by transmission remote in particular the * in the index
add longinus00 tweak
add a variable to choose it you sort in reverse order or not for seeding


Code: Select all

#!/bin/sh
# *************
# transmission-remote-queue version 0.2
# Contact sam.day (at) gmail.com with suggestions, corrections, etc.
# Based on wereHampster's script from http://pastie.org/357236
# Modified by super-poussin
# *************
# Variables
#
# Path to transmission-remote
REMOTE="/usr/local/bin/transmission-remote"
# Maximum number of active torrents (downloading + seeding)
MAXACTIVE="3"
# Maximum number of downloading torrents
MAXDOWNLOADING="2"
# Download ratio at which to stop seeding
DESIREDRATIO="1.5"
# Options to be passed to transmission-remote
TRANSOPT=" localhost:8181 -n admin:password1"
# Turn on/off adding extra slots if bandwidth to spare. Boolean.
# Recommend disabling if using 'turtle mode'
MODSLOTS=0
# Extra download slot added if download speed is below this value and MODSLOT=1
DOWNLOADLIMIT="700.0"
# If MAXFIRST = 1 seed torrents with Highest ratio First
MAXFIRST=1
# *************


# Add extra download slot if required
if [ $MODSLOTS -eq 1 ]; then
    DOWNLOADSPEED="$($REMOTE -l | tail -n -1 | awk '{ print $5; }')"
    if expr $DOWNLOADSPEED \<= $DOWNLOADLIMIT > /dev/null; then
        MAXDOWNLOADING=$(($MAXDOWNLOADING+1))
    fi
    if [ $MAXDOWNLOADING -gt $MAXACTIVE ]; then
        MAXACTIVE=$MAXDOWNLOADING
    fi
# debugging output (3 lines)
#echo "Current download speed: $DOWNLOADSPEED KB/s"
#echo "Lower threshold before adding a slot: $DOWNLOADLIMIT KB/s"
#echo "Download slots: $MAXDOWNLOADING"
fi

# Stop torrents upper desired ratio
LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep 100% |grep Seeding | awk '{ print $1; }')"
for ID in $LIST; do
    RATIO="$($REMOTE $TRANSOPT -t $ID -i | grep Ratio | awk '{ print $2; }')"
    if expr $RATIO \>= $DESIREDRATIO > /dev/null; then
        NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
        #echo "Stop Torrent: $ID - ${NAME#*Name: } (Ratio $RATIO)"
        $REMOTE $TRANSOPT --torrent $ID --stop > /dev/null
    fi
done

# Start downloading new torrents if download slots exist
DOWNLOADING="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v Stopped | grep -v 100% | wc -l)"
if [ $DOWNLOADING -lt $MAXDOWNLOADING ]; then
    LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v 100% | grep Stopped | head -n $(expr $MAXDOWNLOADING - $DOWNLOADING) | awk '{ print $1; }')"
    for ID in $LIST; do
        NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
        #echo "Downloading Torrent: $ID - ${NAME#*Name: }"
        $REMOTE $TRANSOPT --torrent $ID --start --verify > /dev/null
    done
fi

# Seed torrents below desired ratio if slots exist
ACTIVE="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v Stopped | wc -l)"
if [ $ACTIVE -lt $MAXACTIVE ]; then
    LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep 100% | tail -n $(expr $MAXACTIVE - $ACTIVE) | awk '{ print $1; }'| awk -F "*" '{ print $1}')"
    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)"
    if [ $MAXFIRST -eq 1 ]; then
     RAT2=$(echo $RAT | sed 's/ /\n/g' | sort -u -r)
    fi
    if [ $MAXFIRST -eq 0 ]; then
     RAT2=$(echo $RAT | sed 's/ /\n/g' | sort -u)
    fi
    for LOWEST in $RAT2; do
        for ID in $LIST; do
            RATIO="$($REMOTE $TRANSOPT -t $ID -i | grep Ratio | awk '{ print $2; }')"
            if expr $RATIO \= $LOWEST > /dev/null; then
                NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
                #echo "Seeding Torrent: $ID - ${NAME#*Name: } (Ratio $RATIO)"
                $REMOTE $TRANSOPT --torrent $ID --start --verify > /dev/null
                break
            fi
        done
    done
fi

# List Active Torrents
LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v Stopped | awk '{ print $1; }'| awk -F "*" '{ print $1}')"
for ID in $LIST; do
    NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
    #echo "Active: $ID - ${NAME#*Name: }"
done



Longinus00
Posts: 137
Joined: Fri Aug 21, 2009 5:46 am

Re: [REL] transmission-remote-queue v0.2

Postby Longinus00 » Mon Jan 25, 2010 9:19 am

super-poussin wrote:I do this new version
clean some result sent by transmission remote in particular the * in the index
add longinus00 tweak
add a variable to choose it you sort in reverse order or not for seeding


Perhaps I wasn't being clear, but you need to do my 'fix' every time you using awk for anything past the first 3 columns. This is because the size column can introduce a space depending on it's return value, it either returns 'None' or "XXX.X XB". The time remaining column also introduces a space in a similar manner. Basically, you still have to modify this line:

Code: Select all

DOWNLOADSPEED="$($REMOTE -l | tail -n -1 | awk '{ print $5; }')"

There may be a way to split by only two or more repeating spaces in awk but I don't know awk very well.

I also find it odd that you are stopping torrents when they seed past a certain ratio. I suspect that's code left over from the script that you are basing your work on. Transmission can now auto stop torrents when they are over a given ratio that you can set via the gui or in settings.json:

Code: Select all

    "ratio-limit": 1.0000,
    "ratio-limit-enabled": true,

super-poussin
Posts: 74
Joined: Sun Mar 15, 2009 8:04 pm

Re: [REL] transmission-remote-queue v0.2

Postby super-poussin » Mon Jan 25, 2010 5:36 pm

Longinus00 wrote:
super-poussin wrote:I do this new version
clean some result sent by transmission remote in particular the * in the index
add longinus00 tweak
add a variable to choose it you sort in reverse order or not for seeding


Perhaps I wasn't being clear, but you need to do my 'fix' every time you using awk for anything past the first 3 columns. This is because the size column can introduce a space depending on it's return value, it either returns 'None' or "XXX.X XB". The time remaining column also introduces a space in a similar manner. Basically, you still have to modify this line:

Code: Select all

DOWNLOADSPEED="$($REMOTE -l | tail -n -1 | awk '{ print $5; }')"

There may be a way to split by only two or more repeating spaces in awk but I don't know awk very well.

I also find it odd that you are stopping torrents when they seed past a certain ratio. I suspect that's code left over from the script that you are basing your work on. Transmission can now auto stop torrents when they are over a given ratio that you can set via the gui or in settings.json:

Code: Select all

    "ratio-limit": 1.0000,
    "ratio-limit-enabled": true,


your right for seeding

super-poussin
Posts: 74
Joined: Sun Mar 15, 2009 8:04 pm

Re: [REL] transmission-remote-queue v0.2

Postby super-poussin » Mon Jan 25, 2010 5:44 pm

Code: Select all

#!/bin/sh
# *************
# transmission-remote-queue version 0.2
# Contact sam.day (at) gmail.com with suggestions, corrections, etc.
# Based on wereHampster's script from http://pastie.org/357236
# Modified by super-poussin
# *************
# Variables
#
# Path to transmission-remote
REMOTE="/usr/local/bin/transmission-remote"
# Maximum number of active torrents (downloading + seeding)
MAXACTIVE="3"
# Maximum number of downloading torrents
MAXDOWNLOADING="2"
# Download ratio at which to stop seeding
DESIREDRATIO="1.3"
# Options to be passed to transmission-remote
TRANSOPT=" localhost:8181 -n admin:password1"
# Turn on/off adding extra slots if bandwidth to spare. Boolean.
# Recommend disabling if using 'turtle mode'
MODSLOTS=0
# Extra download slot added if download speed is below this value and MODSLOT=1
DOWNLOADLIMIT="700.0"
# If MAXFIRST = 1 seed torrents with Highest ratio First
MAXFIRST=1
# *************


# Add extra download slot if required
if [ $MODSLOTS -eq 1 ]; then
    DOWNLOADSPEED="$($REMOTE -l | tail -n -1 | sed 's/^\s\+//g' | sed 's/\s\{2,\}/~/g' | cut -d '~' -f4)"
    if expr $DOWNLOADSPEED \<= $DOWNLOADLIMIT > /dev/null; then
        MAXDOWNLOADING=$(($MAXDOWNLOADING+1))
    fi
    if [ $MAXDOWNLOADING -gt $MAXACTIVE ]; then
        MAXACTIVE=$MAXDOWNLOADING
    fi
# debugging output (3 lines)
echo "Current download speed: $DOWNLOADSPEED KB/s"
echo "Lower threshold before adding a slot: $DOWNLOADLIMIT KB/s"
echo "Download slots: $MAXDOWNLOADING"
fi

# Stop torrents upper desired ratio
#LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep 100% |grep Seeding | awk '{ print $1; }')"
#for ID in $LIST; do
#    RATIO="$($REMOTE $TRANSOPT -t $ID -i | grep Ratio | awk '{ print $2; }')"
#    if expr $RATIO \>= $DESIREDRATIO > /dev/null; then
#        NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
#        echo "Stop Torrent: $ID - ${NAME#*Name: } (Ratio $RATIO)"
#        $REMOTE $TRANSOPT --torrent $ID --stop > /dev/null
#    fi
#done

# Start downloading new torrents if download slots exist
DOWNLOADING="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v Stopped | grep -v 100% | wc -l)"
if [ $DOWNLOADING -lt $MAXDOWNLOADING ]; then
    LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v 100% | grep Stopped | head -n $(expr $MAXDOWNLOADING - $DOWNLOADING) | awk '{ print $1; }')"
    for ID in $LIST; do
        NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
        echo "Downloading Torrent: $ID - ${NAME#*Name: }"
        $REMOTE $TRANSOPT --torrent $ID --start --verify > /dev/null
    done
fi

# Seed torrents below desired ratio if slots exist
ACTIVE="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v Stopped | wc -l)"
if [ $ACTIVE -lt $MAXACTIVE ]; then
    LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep 100% | tail -n $(expr $MAXACTIVE - $ACTIVE) | awk '{ print $1; }'| awk -F "*" '{ print $1}')"
    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)"
    if [ $MAXFIRST -eq 1 ]; then
     RAT2=$(echo $RAT | sed 's/ /\n/g' | sort -u -r)
    fi
    if [ $MAXFIRST -eq 0 ]; then
     RAT2=$(echo $RAT | sed 's/ /\n/g' | sort -u)
    fi
    for LOWEST in $RAT2; do
        for ID in $LIST; do
            RATIO="$($REMOTE $TRANSOPT -t $ID -i | grep Ratio | awk '{ print $2; }')"
            if expr $RATIO \= $LOWEST > /dev/null; then
                NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
                echo "Seeding Torrent: $ID - ${NAME#*Name: } (Ratio $RATIO)"
                $REMOTE $TRANSOPT --torrent $ID --start --verify > /dev/null
                break
            fi
        done
    done
fi

# List Active Torrents
LIST="$($REMOTE $TRANSOPT -l | tail -n +2 | head -n -1 | grep -v Stopped | awk '{ print $1; }'| awk -F "*" '{ print $1}')"
for ID in $LIST; do
    NAME="$($REMOTE $TRANSOPT --torrent $ID --info | grep Name:)"
    echo "Active: $ID - ${NAME#*Name: }"
done



wereHamster
Posts: 21
Joined: Sun Dec 09, 2007 2:18 pm

Re: [REL] transmission-remote-queue v0.2

Postby wereHamster » Thu Jan 28, 2010 2:14 pm

disc0rd wrote:

Code: Select all

#!/bin/sh
# *************
# transmission-remote-queue version 0.2
# Contact sam.day (at) gmail.com with suggestions, corrections, etc.
# Based on wereHampster's script from http://pastie.org/357236
# *************


It's written 'wereHamster' - I don't know where you people get the 'p' from ...

sfera
Posts: 2
Joined: Sat May 22, 2010 1:58 pm

Re: [REL] transmission-remote-queue v0.2

Postby sfera » Wed May 26, 2010 9:57 pm

i was just about to test the script but then i had a problem with this:

Code: Select all

RATIO="$($REMOTE $TRANSOPT -t $ID -i | grep Ratio | awk '{ print $2; }')"

because grep matched 2 lines, the following expr failed. adding an -m 1 to the grep call fixed it for me:

Code: Select all

RATIO="$($REMOTE $TRANSOPT -t $ID -i | grep -m 1 Ratio | awk '{ print $2; }')"


Return to “General”