NorthernBear Posted September 28, 2012 Report Share Posted September 28, 2012 Here is a shell script to remove completed torrents.... This works with uTorrent 3.2.Enjoy!#!/bin/bash# VARIABLESuser="USER"password="PASS"server="SERVER"port="PORT"# Don't change anything below this line (unless you know what you're doing)WGET_PARAMS_INITIAL="--save-cookies cookies.txt --keep-session-cookies"WGET_INITIAL="wget $WGET_PARAMS_INITIAL"WGET="wget --load-cookies cookies.txt"# Get the auth token.resp1=`$WGET_INITIAL --http-user=$user --http-password=$password -q -O - http://$server:$port/gui/token.html`token=`echo -e "$resp1" | awk -F'[<>]' '/<div[^>]*id=[\"'"'"']*token[\"'"'"'][^>]*>([^<]*)<\/div>/ { print $5 }'`# Get the list of finished torrentsresp2=`$WGET --http-user=$user --http-password=$password -q -O - http://$server:$port/gui/?list=1\&token=$token`# Substring it to the start of the torrents list.ndx=`echo -e "$resp2" | tr "\n" " " | awk '{ndx=match($0, /,"torrents": \[/); print ndx }'`sstr=${resp2:ndx}# Look at each line and identify the torrent listing.rx='^\[\"[^"]*\",[0-9]'IFS=""#echo Processing Line: $sstrfor line in $sstrdo # If this line matches a torrent item in the torrents property... if [[ "$line" =~ $rx ]]; then # Tokenize the fields. lineTokens=(`echo -e "$line" | sed -e 's/\[//g;s/\]//g;s/"//g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' `) torrent=${lineTokens[2]} size=${lineTokens[3]} percent=${lineTokens[4]} downloaded=${lineTokens[5]} echo TORRENT: $torrent echo " SIZE: '$size'" echo " PERCENT: '$percent'" echo " DOWNLOADED: $downloaded" # Double check that this is a torrent listing and that it's finished. if [[ "$percent" == "1000" ]]; then # Make the call to remove the torrent. TORRENT=${lineTokens[2]} resp3=`wget --load-cookies cookies.txt --http-user=$user --http-password=$password -q -O - http://$server:$port/gui/?action=$removeAction\&token=$token\&hash=${lineTokens[0]}` if [[ "$resp3" == "" ]]; then echo "Error removing torrent: ${lineTokens[2]} (id: ${lineTokens[0]})" fi fi fi done Link to comment Share on other sites More sharing options...
fourte3n Posted January 27, 2013 Report Share Posted January 27, 2013 and how does one actually use this? I made a .bat and had set it to run after download complete but it didnt seem to work. Sorry for the noob question but Im just fumbling my way through at the moment. Link to comment Share on other sites More sharing options...
ciaobaby Posted January 27, 2013 Report Share Posted January 27, 2013 .bat is a Microsoft DOS shell command script.bash (#!/bin/bash) is a Unix/Linux shell command script. Link to comment Share on other sites More sharing options...
fourte3n Posted January 27, 2013 Report Share Posted January 27, 2013 so.... barking up the wrong tree then. Link to comment Share on other sites More sharing options...
dsm1212 Posted January 26, 2014 Report Share Posted January 26, 2014 Script works with one change. Nowhere in the script does it set removeAction. So the actual wget near the end just errors because there is no action defined. Right before that wget just add this line:removeAction="remove"or use "removeData" if you want the files deleted.Maybe the author had this set in his environment or something so that he could alternate between remove and removeData?thankssteve Link to comment Share on other sites More sharing options...
eseelke Posted April 30, 2015 Report Share Posted April 30, 2015 I know this is an old post and for uTorrent 3.2, but does anyone know how to make this work with 3.3? I run the script, but all I get back is an "Error removing torrent:" message on the torrent(s) it should be removing. Thanks, Eddie Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.