reached something like a 5:1 upload/download ratio, or has been seeded for a week
That's a damn good attitude, let's try and support that...
Any idea how to do this?
Here's a slightly different approach because I use btdownloadheadless.
It should go for .*many as well as long as it uses --spew which sets the logfile.
If you "reverse cat" (tac) the logfile and grep for the first string "upload rate:" and take the 3rd value you have the most current amount for upload. Take the archive/file size from running btshowmetainfo, mangle a bit, and you get:
Code:
#!/bin/sh
# where your running torrent files and logs reside
torrentdir="/var/bittorrent"
find "${torrentdir}" -type f -maxdepth 1 -iname \*.torrent | while read t; do
if [ -f "${t%%.torrent}.log" ]; then log="${t%%.torrent}.log";
u_size=($(tac "${log}" | grep -m1 "^upload total:")); u_size=${u_size[2]};
t_size=($(btshowmetainfo.py "${t}" | grep -m1 "^[fa].*size"));
t_size=$(echo "scale=2;${t_size[2]}/1024/1024"|bc -l); f=${t//*\//}; f=${f%%.torrent};
echo "${f} uploading:$(echo "scale=2;(${u_size%%.*} / ${t_size}) * 100"|bc -l)%"
fi
done
exit 0
This is more like PoC and not what you want exactly, but it should be trivial to turn the output line in to some check-and-execute thingie.