#155 adding duration into total time check
This commit is contained in:
@ -235,7 +235,6 @@ def terminate_session(session_id, message, notifier=None, username=None):
|
|||||||
req = sess.post(TAUTULLI_URL.rstrip('/') + '/api/v2', params=payload)
|
req = sess.post(TAUTULLI_URL.rstrip('/') + '/api/v2', params=payload)
|
||||||
response = req.json()
|
response = req.json()
|
||||||
|
|
||||||
print(response)
|
|
||||||
if response['response']['result'] == 'success':
|
if response['response']['result'] == 'success':
|
||||||
sys.stdout.write(
|
sys.stdout.write(
|
||||||
"Successfully killed Plex session: {0}.\n".format(session_id))
|
"Successfully killed Plex session: {0}.\n".format(session_id))
|
||||||
@ -284,6 +283,9 @@ if __name__ == "__main__":
|
|||||||
parser.add_argument('--today', default=False, action='store_true',
|
parser.add_argument('--today', default=False, action='store_true',
|
||||||
help='Search history only for today. \n'
|
help='Search history only for today. \n'
|
||||||
'Default: %(default)s')
|
'Default: %(default)s')
|
||||||
|
parser.add_argument('--duration', type=int,
|
||||||
|
help='Duration of item that triggered script agent.')
|
||||||
|
|
||||||
opts = parser.parse_args()
|
opts = parser.parse_args()
|
||||||
|
|
||||||
total_limit = 0
|
total_limit = 0
|
||||||
@ -329,6 +331,14 @@ if __name__ == "__main__":
|
|||||||
print('Total {} ({}) is greater than limit ({}).'
|
print('Total {} ({}) is greater than limit ({}).'
|
||||||
.format(opts.jbop, total_jbop, total_limit))
|
.format(opts.jbop, total_jbop, total_limit))
|
||||||
terminate_session(opts.sessionId, message, opts.notify, opts.username)
|
terminate_session(opts.sessionId, message, opts.notify, opts.username)
|
||||||
|
elif (opts.duration + total_jbop) > total_limit:
|
||||||
|
print('Total {} ({} + current item duration {}) is greater than limit ({}).'
|
||||||
|
.format(opts.jbop, total_jbop, opts.duration, total_limit))
|
||||||
|
terminate_session(opts.sessionId, message, opts.notify, opts.username)
|
||||||
|
else:
|
||||||
|
if opts.duration:
|
||||||
|
print('Total {} ({} + current item duration {}) is less than limit ({}).'
|
||||||
|
.format(opts.jbop, total_jbop, opts.duration, total_limit))
|
||||||
else:
|
else:
|
||||||
print('Total {} ({}) is less than limit ({}).'
|
print('Total {} ({}) is less than limit ({}).'
|
||||||
.format(opts.jbop, total_jbop, total_limit))
|
.format(opts.jbop, total_jbop, total_limit))
|
||||||
|
Reference in New Issue
Block a user