diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html index f67bdd59..bbcec5f6 100644 --- a/data/interfaces/default/settings.html +++ b/data/interfaces/default/settings.html @@ -1093,11 +1093,11 @@ available_notification_agents = sorted(notifiers.available_notification_agents() {datestamp} - The date the notification was triggered. + The date (in date format) the notification was triggered. {timestamp} - The time the notification was triggered. + The time (in time format) the notification was triggered. @@ -1134,14 +1134,26 @@ available_notification_agents = sorted(notifiers.available_notification_agents() {stream_duration} The stream duration (in minutes) for the item. + + {stream_time} + The stream duration (in time format) for the item. + {remaining_duration} The remaining duration (in minutes) for the item. - {progress} + {remaining_time} + The remaining duration (in time format) for the item. + + + {progress_duration} The last reported offset (in minutes) for the item. + + {progress_time} + The last reported offset (in time format) for the item. + {progress_percent} The last reported progress percent for the item. @@ -1222,6 +1234,10 @@ available_notification_agents = sorted(notifiers.available_notification_agents() {transcode_audio_channels} The audio channels of the transcoded media. + + {session_key} + The unique identifier for the session. + {user_id} The unique identifier for the user. diff --git a/plexpy/config.py b/plexpy/config.py index 9cc23068..45eb1c79 100644 --- a/plexpy/config.py +++ b/plexpy/config.py @@ -512,6 +512,7 @@ class Config(object): self.MOVIE_LOGGING_ENABLE = 0 self.TV_LOGGING_ENABLE = 0 self.CONFIG_VERSION = '1' + if self.CONFIG_VERSION == '1': # Change home_stats_cards to list if self.HOME_STATS_CARDS: @@ -525,4 +526,20 @@ class Config(object): if 'library_statistics' in home_library_cards: home_library_cards.remove('library_statistics') self.HOME_LIBRARY_CARDS = home_library_cards - self.CONFIG_VERSION = '2' \ No newline at end of file + self.CONFIG_VERSION = '2' + + if self.CONFIG_VERSION == '2': + self.NOTIFY_ON_START_SUBJECT_TEXT = self.NOTIFY_ON_START_SUBJECT_TEXT.replace('{progress}','{progress_duration}') + self.NOTIFY_ON_START_BODY_TEXT = self.NOTIFY_ON_START_BODY_TEXT.replace('{progress}','{progress_duration}') + self.NOTIFY_ON_STOP_SUBJECT_TEXT = self.NOTIFY_ON_STOP_SUBJECT_TEXT.replace('{progress}','{progress_duration}') + self.NOTIFY_ON_STOP_BODY_TEXT = self.NOTIFY_ON_STOP_BODY_TEXT.replace('{progress}','{progress_duration}') + self.NOTIFY_ON_PAUSE_SUBJECT_TEXT = self.NOTIFY_ON_PAUSE_SUBJECT_TEXT.replace('{progress}','{progress_duration}') + self.NOTIFY_ON_PAUSE_BODY_TEXT = self.NOTIFY_ON_PAUSE_BODY_TEXT.replace('{progress}','{progress_duration}') + self.NOTIFY_ON_RESUME_SUBJECT_TEXT = self.NOTIFY_ON_RESUME_SUBJECT_TEXT.replace('{progress}','{progress_duration}') + self.NOTIFY_ON_RESUME_BODY_TEXT = self.NOTIFY_ON_RESUME_BODY_TEXT.replace('{progress}','{progress_duration}') + self.NOTIFY_ON_BUFFER_SUBJECT_TEXT = self.NOTIFY_ON_BUFFER_SUBJECT_TEXT.replace('{progress}','{progress_duration}') + self.NOTIFY_ON_BUFFER_BODY_TEXT = self.NOTIFY_ON_BUFFER_BODY_TEXT.replace('{progress}','{progress_duration}') + self.NOTIFY_ON_WATCHED_SUBJECT_TEXT = self.NOTIFY_ON_WATCHED_SUBJECT_TEXT.replace('{progress}','{progress_duration}') + self.NOTIFY_ON_WATCHED_BODY_TEXT = self.NOTIFY_ON_WATCHED_BODY_TEXT.replace('{progress}','{progress_duration}') + self.NOTIFY_SCRIPTS_ARGS_TEXT = self.NOTIFY_SCRIPTS_ARGS_TEXT.replace('{progress}','{progress_duration}') + self.CONFIG_VERSION = '3' diff --git a/plexpy/helpers.py b/plexpy/helpers.py index cb11e87d..a5d9e2d4 100644 --- a/plexpy/helpers.py +++ b/plexpy/helpers.py @@ -135,6 +135,15 @@ def convert_seconds(s): return minutes +def convert_seconds_to_minutes(s): + + if str(s).isdigit(): + minutes = round(float(s) / 60, 0) + + return math.trunc(minutes) + + return 0 + def today(): today = datetime.date.today() diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index ab8d20f9..05e19798 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -446,14 +446,17 @@ def build_notify_text(session=None, timeline=None, state=None): transcode_decision = 'Direct Play' if state != 'play': - stream_duration = int((time.time() - helpers.cast_to_float(session.get('started', 0)) - - helpers.cast_to_float(session.get('paused_counter', 0))) / 60) + stream_duration = helpers.convert_seconds_to_minutes( + time.time() - + helpers.cast_to_float(session.get('started', 0)) - + helpers.cast_to_float(session.get('paused_counter', 0))) else: stream_duration = 0 view_offset = helpers.convert_milliseconds_to_minutes(session.get('view_offset', 0)) duration = helpers.convert_milliseconds_to_minutes(metadata['duration']) progress_percent = helpers.get_percent(view_offset, duration) + remaining_duration = duration - view_offset # Fix metadata params for notify recently added grandparent if state == 'created' and plexpy.CONFIG.NOTIFY_RECENTLY_ADDED_GRANDPARENT: @@ -468,7 +471,7 @@ def build_notify_text(session=None, timeline=None, state=None): artist_name = metadata['grandparent_title'] album_name = metadata['parent_title'] track_name = metadata['title'] - + available_params = {# Global paramaters 'server_name': server_name, 'server_uptime': server_uptime, @@ -482,8 +485,11 @@ def build_notify_text(session=None, timeline=None, state=None): 'player': session.get('player',''), 'ip_address': session.get('ip_address','N/A'), 'stream_duration': stream_duration, - 'remaining_duration': duration - view_offset, - 'progress': view_offset, + 'stream_time': arrow.get(stream_duration * 60).format(duration_format), + 'remaining_duration': remaining_duration, + 'remaining_time': arrow.get(remaining_duration * 60).format(duration_format), + 'progress_duration': view_offset, + 'progress_time': arrow.get(view_offset * 60).format(duration_format), 'progress_percent': progress_percent, 'container': session.get('container',''), 'video_codec': session.get('video_codec',''),