From 8cbdf2de55f28e7cc8cf850116addecb556374a5 Mon Sep 17 00:00:00 2001 From: Blacktwin Date: Mon, 22 Jul 2019 16:03:50 -0400 Subject: [PATCH] #179 If duration is used convert to seconds from minutes --- killstream/limiterr.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/killstream/limiterr.py b/killstream/limiterr.py index 9d1e1fa..47410e7 100644 --- a/killstream/limiterr.py +++ b/killstream/limiterr.py @@ -280,6 +280,7 @@ if __name__ == "__main__": total_limit = 0 total_jbop = 0 + duration = 0 if opts.limit: limit = dict(opts.limit) @@ -298,6 +299,10 @@ if __name__ == "__main__": sys.stderr.write("No sessionId provided! Is this synced content?\n") sys.exit(1) + if opts.duration: + # If duration is used convert to seconds from minutes + duration = opts.duration * 60 + if opts.killMessage: message = ' '.join(opts.killMessage) else: @@ -321,7 +326,7 @@ if __name__ == "__main__": print('Total {} ({}) is greater than limit ({}).' .format(opts.jbop, total_jbop, total_limit)) terminate_session(opts.sessionId, message, opts.notify, opts.username) - elif (opts.duration + total_jbop) > total_limit: + elif (duration + total_jbop) > total_limit: interval = 60 start = 0 while (start + total_jbop) < total_limit: @@ -333,12 +338,12 @@ if __name__ == "__main__": exit() print('Total {} ({} + current item duration {}) is greater than limit ({}).' - .format(opts.jbop, total_jbop, opts.duration, total_limit)) + .format(opts.jbop, total_jbop, duration, total_limit)) terminate_session(opts.sessionId, message, opts.notify, opts.username) else: - if opts.duration: + if duration: print('Total {} ({} + current item duration {}) is less than limit ({}).' - .format(opts.jbop, total_jbop, opts.duration, total_limit)) + .format(opts.jbop, total_jbop, duration, total_limit)) else: print('Total {} ({}) is less than limit ({}).' .format(opts.jbop, total_jbop, total_limit))