Source

TransmissionScripts / transmission-removedone.py

#!/usr/bin/env python
'''
Created on Feb 5, 2011

@author: gmoreau
'''
import transmissionrpc
from datetime import datetime

TRANS_HOST = '192.168.100.150'  # The host transmission is running on
TRANS_PORT = '9091' # The port the host is listening on
TRANS_USER =  ''    # The user id you have set
TRANS_PW = ''   # the password you have set
MAX_RATIO = 1.5
MAX_RETENTION = 5

def Main():
    tc = transmissionrpc.Client(TRANS_HOST, TRANS_PORT, TRANS_USER, TRANS_PW)
    tl = tc.info()
    nothing_processed = True
    for t in tl:
        age = datetime.now() - tl[t].date_added
        if (tl[t].status == 'stopped' and tl[t].ratio >= MAX_RATIO) or (age.days >= MAX_RETENTION ):
            nothing_processed = False
            print 'removing torrent ' + tl[t].name +' and data file.'
            tc.remove(t, True)
    if nothing_processed :
        print 'nothing due to be deleted, try again later'
            
if __name__ == '__main__':
    Main()