From ac9a8b85ec419b5ef3cd21eaa9bee850f4cce36d Mon Sep 17 00:00:00 2001 From: Tim Date: Sat, 22 Aug 2015 22:11:47 +0200 Subject: [PATCH] Fix stream_duration if no paused_duration and format correctly. --- plexpy/notification_handler.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 0429bb30..6e594306 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -300,7 +300,11 @@ def build_notify_text(session, state): duration = helpers.convert_milliseconds_to_minutes(item_metadata['duration']) view_offset = helpers.convert_milliseconds_to_minutes(session['view_offset']) - stream_duration = 0 if state == 'play' else int((time.time() - helpers.cast_to_float(session['started']) - helpers.cast_to_float(session['paused_counter'])) / 60) + if session['paused_counter']: + stream_duration = int((time.time() - helpers.cast_to_float(session['started']) - + helpers.cast_to_float(session['paused_counter'])) / 60) + else: + stream_duration = int((time.time() - helpers.cast_to_float(session['started'])) / 60) progress_percent = helpers.get_percent(view_offset, duration)