Return to Snippet

Revision: 16076
at July 25, 2009 08:57 by brownrl


Updated Code
#!/bin/sh 

# Download dir, may contain spaces:
watchdir="/share/Download/"

bin="/opt/sybhttpd/localhost.drives/HARD_DISK/Apps/Transmission/bin/transmission-remote"

# Authentication "username:password":
tr_auth="nmt:1234"

# Transmission host "ip:port":
tr_host="127.0.0.1:9091"

if [ -n "$tr_auth" ]; then 
tr_auth="--auth=$tr_auth"
fi

# Ok from this point on its a bit hack and slash so apologies
# But we essentially go through the transmission list of torrents
# If the torrent is downloaded 100%
# Then we take it out of transmission and we make .finished file

$bin "$tr_host" "$tr_auth" -l | awk '{
if ($1 != "Sum:" && $1 != "ID") {
print $1,$2
}
}' | while read id percent
do
	if [ $percent = "100%" ]
	then
		reply="`$bin -t "$id" -i | grep -E '^  Name|^  Hash'`"
		name="`echo "$reply" | grep '^  Name'  | cut -c 9-`"
		hash="`echo "$reply" | grep '^  Hash'  | cut -c 9-`"
		touch "$watchdir$name.finished"
		t=`$bin -t $id -r`		
		sleep 5
	fi
done
exit 0

Revision: 16075
at July 25, 2009 08:55 by brownrl


Initial Code
#!/bin/sh 

# Watch dir, may contain spaces:
watchdir="/share/Download/"

bin="/opt/sybhttpd/localhost.drives/HARD_DISK/Apps/Transmission/bin/transmission-remote"

# Authentication "username:password":
tr_auth="nmt:1234"

# Transmission host "ip:port":
tr_host="127.0.0.1:9091"

if [ -n "$tr_auth" ]; then 
tr_auth="--auth=$tr_auth"
fi

# Ok from this point on its a bit hack and slash so apologies
# But we essentially go through the transmission list of torrents
# If the torrent is downloaded 100%
# Then we take it out of transmission and we make .finished file

$bin "$tr_host" "$tr_auth" -l | awk '{
if ($1 != "Sum:" && $1 != "ID") {
print $1,$2
}
}' | while read id percent
do
	if [ $percent = "100%" ]
	then
		reply="`$bin -t "$id" -i | grep -E '^  Name|^  Hash'`"
		name="`echo "$reply" | grep '^  Name'  | cut -c 9-`"
		hash="`echo "$reply" | grep '^  Hash'  | cut -c 9-`"
		touch "$watchdir$name.finished"
		t=`$bin -t $id -r`		
		sleep 5
	fi
done
exit 0

Initial URL
http://www.goingson.be

Initial Description
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!

Initial Title
Bash stopFinished

Initial Tags

                                

Initial Language
Bash