From 0f8c122ee322d7b5e91088f456261a0b9ad3c43d Mon Sep 17 00:00:00 2001 From: Jonathan Wong Date: Wed, 25 Nov 2015 18:12:20 -0800 Subject: [PATCH 1/6] Add video and audio decision to notification options --- data/interfaces/default/settings.html | 10 +++++++++- plexpy/notification_handler.py | 23 +++++++++++------------ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html index 2129b5aa..fd3dd1c5 100644 --- a/data/interfaces/default/settings.html +++ b/data/interfaces/default/settings.html @@ -1001,9 +1001,17 @@ available_notification_agents = sorted(notifiers.available_notification_agents() {episode_num00} The two digit episode number. + + {video_decision} + The video transcode decisions for the media item. + + + {audio_decision} + The audio transcode decisions for the media item. + {transcode_decision} - The transcode decisions for the media item. + The stream transcode decisions for the media item. {year} diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 2b91cc85..256e6d51 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -370,6 +370,8 @@ def build_notify_text(session=None, timeline=None, state=None): duration = helpers.convert_milliseconds_to_minutes(metadata['duration']) # Default values + video_decision = '' + audio_decision = '' transcode_decision = '' stream_duration = 0 view_offset = 0 @@ -381,18 +383,15 @@ def build_notify_text(session=None, timeline=None, state=None): # Session values if session: # Generate a combined transcode decision value - if session['video_decision']: - if session['video_decision'] == 'transcode': - transcode_decision = 'Transcode' - elif session['video_decision'] == 'copy' or session['audio_decision'] == 'copy': - transcode_decision = 'Direct Stream' - else: - transcode_decision = 'Direct Play' - elif session['audio_decision']: - if session['audio_decision'] == 'transcode': - transcode_decision = 'Transcode' - else: - transcode_decision = 'Direct Play' + video_decision = session['video_decision'].title() + audio_decision = session['audio_decision'].title() + + if session['video_decision'] == 'transcode' or session['audio_decision'] == 'transcode': + transcode_decision = 'Transcode' + elif session['video_decision'] == 'copy' or session['audio_decision'] == 'copy': + transcode_decision = 'Direct Stream' + else: + transcode_decision = 'Direct Play' if state != 'play': if session['paused_counter']: From fac47ee68bf7c5986542b63ca070c9a9b4488d55 Mon Sep 17 00:00:00 2001 From: Jonathan Wong Date: Wed, 25 Nov 2015 18:14:08 -0800 Subject: [PATCH 2/6] Fix log spam if notifications turned off --- plexpy/notification_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 256e6d51..5ea2f3f0 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -161,7 +161,7 @@ def notify(stream_data=None, notify_action=None): elif stream_data['media_type'] == 'clip': pass else: - logger.debug(u"PlexPy Notifier :: Notify called with unsupported media type.") + #logger.debug(u"PlexPy Notifier :: Notify called with unsupported media type.") pass else: logger.debug(u"PlexPy Notifier :: Notify called but incomplete data received.") From 908ce1ff8d50538bab8029f61110822758a20269 Mon Sep 17 00:00:00 2001 From: Jonathan Wong Date: Wed, 25 Nov 2015 19:02:59 -0800 Subject: [PATCH 3/6] Fix IP address logging --- plexpy/activity_processor.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/plexpy/activity_processor.py b/plexpy/activity_processor.py index fda00ac1..df9131cb 100644 --- a/plexpy/activity_processor.py +++ b/plexpy/activity_processor.py @@ -39,7 +39,6 @@ class ActivityProcessor(object): 'parent_title': session['parent_title'], 'grandparent_title': session['grandparent_title'], 'friendly_name': session['friendly_name'], - 'ip_address': session['ip_address'], 'player': session['player'], 'platform': session['platform'], 'parent_rating_key': session['parent_rating_key'], @@ -78,20 +77,19 @@ class ActivityProcessor(object): threading.Thread(target=notification_handler.notify, kwargs=dict(stream_data=values, notify_action='play')).start() + # If it's our first write then time stamp it. started = int(time.time()) timestamp = {'started': started} + self.db.upsert('sessions', timestamp, keys) + ip_address = {'ip_address': session['ip_address']} # Try and grab IP address from logs (fallback if not on PMS 0.9.14 and above) if not session['ip_address']: if plexpy.CONFIG.IP_LOGGING_ENABLE and plexpy.CONFIG.PMS_LOGS_FOLDER: ip_address = self.find_session_ip(rating_key=session['rating_key'], machine_id=session['machine_id']) - timestamp.update({'ip_address': ip_address}) - else: - timestamp.update({'ip_address': None}) - - # If it's our first write then time stamp it. - self.db.upsert('sessions', timestamp, keys) + ip_address = {'ip_address': ip_address} + self.db.upsert('sessions', ip_address, keys) def write_session_history(self, session=None, import_metadata=None, is_import=False, import_ignore_interval=0): from plexpy import users From 2a91ec156058dc6b46d11280d7020e0de6373299 Mon Sep 17 00:00:00 2001 From: Jonathan Wong Date: Wed, 25 Nov 2015 19:07:23 -0800 Subject: [PATCH 4/6] Fix season and episode number notification option return at least one digit --- plexpy/notification_handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 5ea2f3f0..397f786b 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -421,9 +421,9 @@ def build_notify_text(session=None, timeline=None, state=None): 'artist_name': metadata['grandparent_title'], 'album_name': metadata['parent_title'], 'track_name': metadata['title'], - 'season_num': metadata['parent_index'], + 'season_num': metadata['parent_index'].zfill(1), 'season_num00': metadata['parent_index'].zfill(2), - 'episode_num': metadata['index'], + 'episode_num': metadata['index'].zfill(1), 'episode_num00': metadata['index'].zfill(2), 'transcode_decision': transcode_decision, 'year': metadata['year'], From 30b11bce98b3b27618551b729963ca51db8d7eee Mon Sep 17 00:00:00 2001 From: Jonathan Wong Date: Wed, 25 Nov 2015 19:13:08 -0800 Subject: [PATCH 5/6] Actually add video and audio decision to notifications --- plexpy/notification_handler.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 397f786b..4dab68dc 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -425,6 +425,8 @@ def build_notify_text(session=None, timeline=None, state=None): 'season_num00': metadata['parent_index'].zfill(2), 'episode_num': metadata['index'].zfill(1), 'episode_num00': metadata['index'].zfill(2), + 'video_decision': video_decision, + 'audio_decision': audio_decision, 'transcode_decision': transcode_decision, 'year': metadata['year'], 'studio': metadata['studio'], From 090011c9a5454845ec00cc902a740b5c8065c7f2 Mon Sep 17 00:00:00 2001 From: Jonathan Wong Date: Wed, 25 Nov 2015 19:15:40 -0800 Subject: [PATCH 6/6] v1.2.5 --- CHANGELOG.md | 7 +++++++ plexpy/version.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aab09779..1a0de924 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## v1.2.5 (2015-11-25) + +* Add video_decision and audio_decision to notification options +* Fix IP address logging +* Fix log spam if notifications disabled + + ## v1.2.4 (2015-11-24) * Add filtering by media type in the history table diff --git a/plexpy/version.py b/plexpy/version.py index 2bc856a5..5060fcf0 100644 --- a/plexpy/version.py +++ b/plexpy/version.py @@ -1,2 +1,2 @@ PLEXPY_VERSION = "master" -PLEXPY_RELEASE_VERSION = "1.2.4" +PLEXPY_RELEASE_VERSION = "1.2.5"