Commits

anothergene committed 0e06534

cleaned up the scripts a little.

Comments (0)

Files changed (1)

transmission-removedone.py

-#!/usr/bin/env python
+#!/usr/bin/env python2.7
 # encoding: utf-8
 
 import argparse
 
 def main(argv=None):
 
-    options = argparse.ArgumentParser(description='Removes all torrents on a given host that are either older then the given days or have a larger then given ratio')
-    options.add_argument('-p', '--port', default='9091', help='port to connect on. default=9091')
-    options.add_argument('-r', '--ratio', type=float, default=5.0, help='remove if ratio is larger. default=2.0')
-    options.add_argument('-d', '--days', type=int, default=10, help='remove if older then this in days. default=5')
-    options.add_argument('-u', '--user', default='', help='The user to connect as. Defaults to empty')
-    options.add_argument('-w', '--password', default='', help='The password to connect with.  Default is empty')
-    options.add_argument('host', default='localhost', help='the host to connect to. default=localhost')
+    options = argparse.ArgumentParser(description='Removes all torrents on a given host that are either older then the given days or have a larger then given ratio.')
+    options.add_argument('-p', '--port', default='9091', help='Port to connect on. Defaults to 9091.')
+    options.add_argument('-r', '--ratio', type=float, default=0, help='Remove if ratio is larger. Defaults to 0, which means don\'t use ratio.')
+    options.add_argument('-d', '--days', type=int, default=10, help='Remove if older then this in days. Defaults to 10.')
+    options.add_argument('-u', '--user', default='', help='The user to connect as. Default is empty.')
+    options.add_argument('-w', '--password', default='', help='The password to connect with.  Default is empty.')
+    options.add_argument('host', default='localhost', help='The host to connect to. defaults to localhost.')
     theargs = options.parse_args()
     
     tc = transmissionrpc.Client(theargs.host, theargs.port, theargs.user, theargs.password)
     for t in tl:
         age = datetime.datetime.now() - tl[t].date_added
         
-        if (tl[t].status == 'stopped' and tl[t].ratio >= theargs.ratio) or (age.days >= theargs.days):
+        if (theargs.ratio > 0 and tl[t].ratio >= theargs.ratio) or (age.days >= theargs.days):
             nothingprocessed = False
             print 'removing torrent ' + tl[t].name +' and data file.'
             tc.remove(t, True)