Created
June 13, 2017 03:50
-
-
Save noah/dcc5cc89d215da71d418698033f858ea to your computer and use it in GitHub Desktop.
Cron task to delete torrents from rtorrent after 48 hours of seeding.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Close torrents in rtorrent after x hours of seeding | |
# dependencies: libxmlrpc-core-c3-dev, bc, nginx | |
# https://github.com/mdevaev/emonoda/wiki/rTorrent-XMLRPC-Reference | |
# http://elektito.com/2016/02/10/rtorrent-xmlrpc/ | |
x=48 | |
SERVER=localhost:8000 | |
now=$(date +%s) | |
xmlrpc $SERVER download_list "" complete | while read line; do | |
l="$(echo "$line" | grep Index)" | |
if [ -n "$l" ]; then | |
h="$(echo "$l"|cut -d' ' -f5 | tr -d "'" )" | |
t=$(xmlrpc $SERVER d.timestamp.finished "$h"\ | |
|grep integer\ | |
|cut -d ' ' -f3) | |
diff="$(echo "($now-$t)/3600"| bc)" | |
if [ $diff -gt $x ]; then | |
echo $h | |
xmlrpc $SERVER d.close $h | |
xmlrpc $SERVER d.erase $h | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment