diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html
index ee43194e..5e31178f 100644
--- a/data/interfaces/default/settings.html
+++ b/data/interfaces/default/settings.html
@@ -1484,6 +1484,10 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
{user} |
+ The friendly name of the person streaming. |
+
+
+ {username} |
The username of the person streaming. |
@@ -1604,7 +1608,11 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
{session_key} |
- The unique identifier for the session. |
+ The unique identifier for the stream session. |
+
+
+ {transcode_key} |
+ The unique identifier for the transcode session. |
{user_id} |
diff --git a/plexpy/__init__.py b/plexpy/__init__.py
index fcc0bc32..95f9a72e 100644
--- a/plexpy/__init__.py
+++ b/plexpy/__init__.py
@@ -396,8 +396,8 @@ def dbcheck():
# sessions table :: This is a temp table that logs currently active sessions
c_db.execute(
- 'CREATE TABLE IF NOT EXISTS sessions (id INTEGER PRIMARY KEY AUTOINCREMENT, '
- 'session_key INTEGER, rating_key INTEGER, section_id INTEGER, media_type TEXT, started INTEGER, stopped INTEGER, '
+ 'CREATE TABLE IF NOT EXISTS sessions (id INTEGER PRIMARY KEY AUTOINCREMENT, session_key INTEGER, '
+ 'transcode_key TEXT, rating_key INTEGER, section_id INTEGER, media_type TEXT, started INTEGER, stopped INTEGER, '
'paused_counter INTEGER DEFAULT 0, state TEXT, user_id INTEGER, user TEXT, friendly_name TEXT, '
'ip_address TEXT, machine_id TEXT, player TEXT, platform TEXT, title TEXT, parent_title TEXT, '
'grandparent_title TEXT, parent_rating_key INTEGER, grandparent_rating_key INTEGER, '
@@ -630,6 +630,15 @@ def dbcheck():
'ALTER TABLE sessions ADD COLUMN stopped INTEGER'
)
+ # Upgrade sessions table from earlier versions
+ try:
+ c_db.execute('SELECT transcode_key FROM sessions')
+ except sqlite3.OperationalError:
+ logger.debug(u"Altering database. Updating database table sessions.")
+ c_db.execute(
+ 'ALTER TABLE sessions ADD COLUMN transcode_key TEXT'
+ )
+
# Upgrade session_history table from earlier versions
try:
c_db.execute('SELECT reference_id FROM session_history')
diff --git a/plexpy/activity_processor.py b/plexpy/activity_processor.py
index f280de9e..21bd92f9 100644
--- a/plexpy/activity_processor.py
+++ b/plexpy/activity_processor.py
@@ -29,6 +29,7 @@ class ActivityProcessor(object):
def write_session(self, session=None, notify=True):
if session:
values = {'session_key': session['session_key'],
+ 'transcode_key': session['transcode_key'],
'section_id': session['section_id'],
'rating_key': session['rating_key'],
'media_type': session['media_type'],
diff --git a/plexpy/config.py b/plexpy/config.py
index 00149ede..4e9c2a09 100644
--- a/plexpy/config.py
+++ b/plexpy/config.py
@@ -598,4 +598,4 @@ class Config(object):
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'
+ self.CONFIG_VERSION = '3'
\ No newline at end of file
diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py
index 7028e1cf..8bf8b337 100644
--- a/plexpy/notification_handler.py
+++ b/plexpy/notification_handler.py
@@ -660,6 +660,7 @@ def build_notify_text(session=None, timeline=None, notify_action=None, agent_id=
# Stream parameters
'streams': stream_count,
'user': session.get('friendly_name',''),
+ 'username': session.get('user',''),
'platform': session.get('platform',''),
'player': session.get('player',''),
'ip_address': session.get('ip_address','N/A'),
@@ -690,6 +691,7 @@ def build_notify_text(session=None, timeline=None, notify_action=None, agent_id=
'transcode_audio_codec': session.get('transcode_audio_codec',''),
'transcode_audio_channels': session.get('transcode_audio_channels',''),
'session_key': session.get('session_key',''),
+ 'transcode_key': session.get('transcode_key',''),
'user_id': session.get('user_id',''),
'machine_id': session.get('machine_id',''),
# Metadata parameters
diff --git a/plexpy/notifiers.py b/plexpy/notifiers.py
index f29db073..38b51d9c 100644
--- a/plexpy/notifiers.py
+++ b/plexpy/notifiers.py
@@ -1884,7 +1884,7 @@ class Scripts(object):
script_args(list): ["python2", '-p', '-zomg']
"""
logger.debug(u"PlexPy Notifiers :: Trying to run notify script, action: %s, arguments: %s" %
- (notify_action if notify_action else None, script_args if script_args else None))
+ (notify_action or None, script_args or None))
if script_args is None:
script_args = []
diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py
index 0aa76bbc..80541d52 100644
--- a/plexpy/pmsconnect.py
+++ b/plexpy/pmsconnect.py
@@ -1001,6 +1001,7 @@ class PmsConnect(object):
if session.getElementsByTagName('TranscodeSession'):
transcode_session = session.getElementsByTagName('TranscodeSession')[0]
+ transcode_key = helpers.get_xml_attr(transcode_session, 'key')
throttled = helpers.get_xml_attr(transcode_session, 'throttled')
transcode_progress = helpers.get_xml_attr(transcode_session, 'progress')
transcode_speed = helpers.get_xml_attr(transcode_session, 'speed')
@@ -1011,6 +1012,7 @@ class PmsConnect(object):
transcode_protocol = helpers.get_xml_attr(transcode_session, 'protocol')
duration = helpers.get_xml_attr(transcode_session, 'duration')
else:
+ transcode_key = ''
throttled = '0'
transcode_progress = '0'
transcode_speed = ''
@@ -1051,6 +1053,7 @@ class PmsConnect(object):
'rating_key': helpers.get_xml_attr(session, 'ratingKey'),
'parent_rating_key': helpers.get_xml_attr(session, 'parentRatingKey'),
'grandparent_rating_key': helpers.get_xml_attr(session, 'grandparentRatingKey'),
+ 'transcode_key': transcode_key,
'throttled': throttled,
'transcode_progress': int(round(helpers.cast_to_float(transcode_progress), 0)),
'transcode_speed': str(round(helpers.cast_to_float(transcode_speed), 1)),
@@ -1099,6 +1102,7 @@ class PmsConnect(object):
if session.getElementsByTagName('TranscodeSession'):
transcode_session = session.getElementsByTagName('TranscodeSession')[0]
+ transcode_key = helpers.get_xml_attr(transcode_session, 'key')
throttled = helpers.get_xml_attr(transcode_session, 'throttled')
transcode_progress = helpers.get_xml_attr(transcode_session, 'progress')
transcode_speed = helpers.get_xml_attr(transcode_session, 'speed')
@@ -1112,6 +1116,7 @@ class PmsConnect(object):
transcode_container = helpers.get_xml_attr(transcode_session, 'container')
transcode_protocol = helpers.get_xml_attr(transcode_session, 'protocol')
else:
+ transcode_key = ''
throttled = '0'
transcode_progress = '0'
transcode_speed = ''
@@ -1174,6 +1179,7 @@ class PmsConnect(object):
'rating_key': helpers.get_xml_attr(session, 'ratingKey'),
'parent_rating_key': helpers.get_xml_attr(session, 'parentRatingKey'),
'grandparent_rating_key': helpers.get_xml_attr(session, 'grandparentRatingKey'),
+ 'transcode_key': transcode_key,
'throttled': throttled,
'transcode_progress': int(round(helpers.cast_to_float(transcode_progress), 0)),
'transcode_speed': str(round(helpers.cast_to_float(transcode_speed), 1)),
@@ -1232,6 +1238,7 @@ class PmsConnect(object):
'rating_key': helpers.get_xml_attr(session, 'ratingKey'),
'parent_rating_key': helpers.get_xml_attr(session, 'parentRatingKey'),
'grandparent_rating_key': helpers.get_xml_attr(session, 'grandparentRatingKey'),
+ 'transcode_key': transcode_key,
'throttled': throttled,
'transcode_progress': int(round(helpers.cast_to_float(transcode_progress), 0)),
'transcode_speed': str(round(helpers.cast_to_float(transcode_speed), 1)),
@@ -1290,6 +1297,7 @@ class PmsConnect(object):
'rating_key': helpers.get_xml_attr(session, 'ratingKey'),
'parent_rating_key': helpers.get_xml_attr(session, 'parentRatingKey'),
'grandparent_rating_key': helpers.get_xml_attr(session, 'grandparentRatingKey'),
+ 'transcode_key': transcode_key,
'throttled': throttled,
'transcode_progress': int(round(helpers.cast_to_float(transcode_progress), 0)),
'transcode_speed': str(round(helpers.cast_to_float(transcode_speed), 1)),
@@ -1329,6 +1337,7 @@ class PmsConnect(object):
if session.getElementsByTagName('TranscodeSession'):
transcode_session = session.getElementsByTagName('TranscodeSession')[0]
+ transcode_key = helpers.get_xml_attr(transcode_session, 'key')
throttled = helpers.get_xml_attr(transcode_session, 'throttled')
transcode_progress = helpers.get_xml_attr(transcode_session, 'progress')
transcode_speed = helpers.get_xml_attr(transcode_session, 'speed')
@@ -1381,6 +1390,7 @@ class PmsConnect(object):
'rating_key': helpers.get_xml_attr(session, 'ratingKey'),
'parent_rating_key': helpers.get_xml_attr(session, 'parentRatingKey'),
'grandparent_rating_key': helpers.get_xml_attr(session, 'grandparentRatingKey'),
+ 'transcode_key': transcode_key,
'throttled': throttled,
'transcode_progress': int(round(helpers.cast_to_float(transcode_progress), 0)),
'transcode_speed': str(round(helpers.cast_to_float(transcode_speed), 1)),