diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 6e594306..5330b7e5 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -162,6 +162,7 @@ def notify(stream_data=None, notify_action=None): else: logger.debug(u"PlexPy Notifier :: Notify called but incomplete data received.") + def get_notify_state(session): monitor_db = database.MonitorDatabase() result = monitor_db.select('SELECT on_play, on_stop, on_pause, on_resume, on_buffer, on_watched, agent_id ' @@ -184,6 +185,7 @@ def get_notify_state(session): return notify_states + def set_notify_state(session, state, agent_info): if session and state and agent_info: @@ -215,6 +217,7 @@ def set_notify_state(session, state, agent_info): else: logger.error('PlexPy Notifier :: Unable to set notify state.') + def build_notify_text(session, state): from plexpy import pmsconnect, helpers import re @@ -300,11 +303,13 @@ 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']) - 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) + stream_duration = 0 + if state != 'play': + 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) @@ -483,6 +488,7 @@ def build_notify_text(session, state): else: return None + def strip_tag(data): import re