Source

TransmissionScripts / transmission-removedone2.py

Full commit
#!/usr/bin/env python
# encoding: utf-8
"""
untitled.py

Created by Gene Moreau on 2011-02-09.
Copyright (c) 2011 __MyCompanyName__. All rights reserved.
"""

import sys
import argparse
import transmissionrpc


help_message = '''
help me.
'''


def main(argv=None):

    options = argparse.ArgumentParser(description='options passed to progream')
    options.parse_args()
    
    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__":
    sys.exit(main())