mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 07:22:37 -07:00
Add some metadata to the sessions table
This commit is contained in:
parent
9a761e7d30
commit
2b3ba8e7fa
3 changed files with 71 additions and 20 deletions
|
@ -386,9 +386,11 @@ def dbcheck():
|
||||||
'transcode_key TEXT, rating_key INTEGER, section_id INTEGER, media_type TEXT, started INTEGER, stopped 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, '
|
'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, '
|
'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, '
|
'grandparent_title TEXT, full_title TEXT, media_index INTEGER, parent_media_index INTEGER, '
|
||||||
|
'thumb TEXT, parent_thumb TEXT, grandparent_thumb TEXT, year INTEGER, '
|
||||||
|
'parent_rating_key INTEGER, grandparent_rating_key INTEGER, '
|
||||||
'view_offset INTEGER DEFAULT 0, duration INTEGER, video_decision TEXT, audio_decision TEXT, '
|
'view_offset INTEGER DEFAULT 0, duration INTEGER, video_decision TEXT, audio_decision TEXT, '
|
||||||
'width INTEGER, height INTEGER, container TEXT, video_codec TEXT, audio_codec TEXT, '
|
'transcode_decision TEXT, width INTEGER, height INTEGER, container TEXT, video_codec TEXT, audio_codec TEXT, '
|
||||||
'bitrate INTEGER, video_resolution TEXT, video_framerate TEXT, aspect_ratio TEXT, '
|
'bitrate INTEGER, video_resolution TEXT, video_framerate TEXT, aspect_ratio TEXT, '
|
||||||
'audio_channels INTEGER, transcode_protocol TEXT, transcode_container TEXT, '
|
'audio_channels INTEGER, transcode_protocol TEXT, transcode_container TEXT, '
|
||||||
'transcode_video_codec TEXT, transcode_audio_codec TEXT, transcode_audio_channels INTEGER,'
|
'transcode_video_codec TEXT, transcode_audio_codec TEXT, transcode_audio_channels INTEGER,'
|
||||||
|
@ -643,6 +645,36 @@ def dbcheck():
|
||||||
'ALTER TABLE sessions ADD COLUMN write_attempts INTEGER DEFAULT 0'
|
'ALTER TABLE sessions ADD COLUMN write_attempts INTEGER DEFAULT 0'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Upgrade sessions table from earlier versions
|
||||||
|
try:
|
||||||
|
c_db.execute('SELECT transcode_decision FROM sessions')
|
||||||
|
except sqlite3.OperationalError:
|
||||||
|
logger.debug(u"Altering database. Updating database table sessions.")
|
||||||
|
c_db.execute(
|
||||||
|
'ALTER TABLE sessions ADD COLUMN transcode_decision TEXT'
|
||||||
|
)
|
||||||
|
c_db.execute(
|
||||||
|
'ALTER TABLE sessions ADD COLUMN full_title TEXT'
|
||||||
|
)
|
||||||
|
c_db.execute(
|
||||||
|
'ALTER TABLE sessions ADD COLUMN media_index INTEGER'
|
||||||
|
)
|
||||||
|
c_db.execute(
|
||||||
|
'ALTER TABLE sessions ADD COLUMN parent_media_index INTEGER'
|
||||||
|
)
|
||||||
|
c_db.execute(
|
||||||
|
'ALTER TABLE sessions ADD COLUMN thumb TEXT'
|
||||||
|
)
|
||||||
|
c_db.execute(
|
||||||
|
'ALTER TABLE sessions ADD COLUMN parent_thumb TEXT'
|
||||||
|
)
|
||||||
|
c_db.execute(
|
||||||
|
'ALTER TABLE sessions ADD COLUMN grandparent_thumb TEXT'
|
||||||
|
)
|
||||||
|
c_db.execute(
|
||||||
|
'ALTER TABLE sessions ADD COLUMN year INTEGER'
|
||||||
|
)
|
||||||
|
|
||||||
# Upgrade session_history table from earlier versions
|
# Upgrade session_history table from earlier versions
|
||||||
try:
|
try:
|
||||||
c_db.execute('SELECT reference_id FROM session_history')
|
c_db.execute('SELECT reference_id FROM session_history')
|
||||||
|
|
|
@ -48,6 +48,13 @@ class ActivityProcessor(object):
|
||||||
'title': session['title'],
|
'title': session['title'],
|
||||||
'parent_title': session['parent_title'],
|
'parent_title': session['parent_title'],
|
||||||
'grandparent_title': session['grandparent_title'],
|
'grandparent_title': session['grandparent_title'],
|
||||||
|
'full_title': session['full_title'],
|
||||||
|
'media_index': session['media_index'],
|
||||||
|
'parent_media_index': session['parent_media_index'],
|
||||||
|
'thumb': session['thumb'],
|
||||||
|
'parent_thumb': session['parent_thumb'],
|
||||||
|
'grandparent_thumb': session['grandparent_thumb'],
|
||||||
|
'year': session['year'],
|
||||||
'friendly_name': session['friendly_name'],
|
'friendly_name': session['friendly_name'],
|
||||||
#'ip_address': session['ip_address'],
|
#'ip_address': session['ip_address'],
|
||||||
'player': session['player'],
|
'player': session['player'],
|
||||||
|
@ -58,6 +65,7 @@ class ActivityProcessor(object):
|
||||||
'duration': session['duration'],
|
'duration': session['duration'],
|
||||||
'video_decision': session['video_decision'],
|
'video_decision': session['video_decision'],
|
||||||
'audio_decision': session['audio_decision'],
|
'audio_decision': session['audio_decision'],
|
||||||
|
'transcode_decision': session['transcode_decision'],
|
||||||
'width': session['width'],
|
'width': session['width'],
|
||||||
'height': session['height'],
|
'height': session['height'],
|
||||||
'container': session['container'],
|
'container': session['container'],
|
||||||
|
@ -275,14 +283,6 @@ class ActivityProcessor(object):
|
||||||
|
|
||||||
# Write the session_history_media_info table
|
# Write the session_history_media_info table
|
||||||
|
|
||||||
# Generate a combined transcode decision value
|
|
||||||
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 = 'copy'
|
|
||||||
else:
|
|
||||||
transcode_decision = 'direct play'
|
|
||||||
|
|
||||||
# logger.debug(u"PlexPy ActivityProcessor :: Attempting to write to session_history_media_info table...")
|
# logger.debug(u"PlexPy ActivityProcessor :: Attempting to write to session_history_media_info table...")
|
||||||
query = 'INSERT INTO session_history_media_info (id, rating_key, video_decision, audio_decision, ' \
|
query = 'INSERT INTO session_history_media_info (id, rating_key, video_decision, audio_decision, ' \
|
||||||
'duration, width, height, container, video_codec, audio_codec, bitrate, video_resolution, ' \
|
'duration, width, height, container, video_codec, audio_codec, bitrate, video_resolution, ' \
|
||||||
|
@ -298,7 +298,7 @@ class ActivityProcessor(object):
|
||||||
session['audio_channels'], session['transcode_protocol'], session['transcode_container'],
|
session['audio_channels'], session['transcode_protocol'], session['transcode_container'],
|
||||||
session['transcode_video_codec'], session['transcode_audio_codec'],
|
session['transcode_video_codec'], session['transcode_audio_codec'],
|
||||||
session['transcode_audio_channels'], session['transcode_width'], session['transcode_height'],
|
session['transcode_audio_channels'], session['transcode_width'], session['transcode_height'],
|
||||||
transcode_decision]
|
session['transcode_decision']]
|
||||||
|
|
||||||
# logger.debug(u"PlexPy ActivityProcessor :: Writing session_history_media_info transaction...")
|
# logger.debug(u"PlexPy ActivityProcessor :: Writing session_history_media_info transaction...")
|
||||||
self.db.action(query=query, args=args)
|
self.db.action(query=query, args=args)
|
||||||
|
@ -310,14 +310,6 @@ class ActivityProcessor(object):
|
||||||
genres = ";".join(metadata['genres'])
|
genres = ";".join(metadata['genres'])
|
||||||
labels = ";".join(metadata['labels'])
|
labels = ";".join(metadata['labels'])
|
||||||
|
|
||||||
# Build media item title
|
|
||||||
if session['media_type'] == 'episode' or session['media_type'] == 'track':
|
|
||||||
full_title = '%s - %s' % (metadata['grandparent_title'], metadata['title'])
|
|
||||||
elif session['media_type'] == 'movie':
|
|
||||||
full_title = metadata['title']
|
|
||||||
else:
|
|
||||||
full_title = metadata['title']
|
|
||||||
|
|
||||||
# logger.debug(u"PlexPy ActivityProcessor :: Attempting to write to session_history_metadata table...")
|
# logger.debug(u"PlexPy ActivityProcessor :: Attempting to write to session_history_metadata table...")
|
||||||
query = 'INSERT INTO session_history_metadata (id, rating_key, parent_rating_key, ' \
|
query = 'INSERT INTO session_history_metadata (id, rating_key, parent_rating_key, ' \
|
||||||
'grandparent_rating_key, title, parent_title, grandparent_title, full_title, media_index, ' \
|
'grandparent_rating_key, title, parent_title, grandparent_title, full_title, media_index, ' \
|
||||||
|
@ -328,7 +320,7 @@ class ActivityProcessor(object):
|
||||||
'?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'
|
'?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'
|
||||||
|
|
||||||
args = [session['rating_key'], session['parent_rating_key'], session['grandparent_rating_key'],
|
args = [session['rating_key'], session['parent_rating_key'], session['grandparent_rating_key'],
|
||||||
session['title'], session['parent_title'], session['grandparent_title'], full_title,
|
session['title'], session['parent_title'], session['grandparent_title'], session['full_title'],
|
||||||
metadata['media_index'], metadata['parent_media_index'], metadata['section_id'], metadata['thumb'],
|
metadata['media_index'], metadata['parent_media_index'], metadata['section_id'], metadata['thumb'],
|
||||||
metadata['parent_thumb'], metadata['grandparent_thumb'], metadata['art'], session['media_type'],
|
metadata['parent_thumb'], metadata['grandparent_thumb'], metadata['art'], session['media_type'],
|
||||||
metadata['year'], metadata['originally_available_at'], metadata['added_at'], metadata['updated_at'],
|
metadata['year'], metadata['originally_available_at'], metadata['added_at'], metadata['updated_at'],
|
||||||
|
|
|
@ -1075,6 +1075,9 @@ class PmsConnect(object):
|
||||||
transcode_container = ''
|
transcode_container = ''
|
||||||
transcode_protocol = ''
|
transcode_protocol = ''
|
||||||
|
|
||||||
|
# Generate a combined transcode decision value
|
||||||
|
transcode_decision = audio_decision
|
||||||
|
|
||||||
user_details = user_data.get_details(
|
user_details = user_data.get_details(
|
||||||
user=helpers.get_xml_attr(session.getElementsByTagName('User')[0], 'title'))
|
user=helpers.get_xml_attr(session.getElementsByTagName('User')[0], 'title'))
|
||||||
|
|
||||||
|
@ -1109,6 +1112,8 @@ class PmsConnect(object):
|
||||||
'grandparent_title': helpers.get_xml_attr(session, 'grandparentTitle'),
|
'grandparent_title': helpers.get_xml_attr(session, 'grandparentTitle'),
|
||||||
'parent_title': helpers.get_xml_attr(session, 'parentTitle'),
|
'parent_title': helpers.get_xml_attr(session, 'parentTitle'),
|
||||||
'title': helpers.get_xml_attr(session, 'title'),
|
'title': helpers.get_xml_attr(session, 'title'),
|
||||||
|
'full_title': '%s - %s' % (helpers.get_xml_attr(session, 'grandparentTitle'),
|
||||||
|
helpers.get_xml_attr(session, 'title')),
|
||||||
'year': helpers.get_xml_attr(session, 'year'),
|
'year': helpers.get_xml_attr(session, 'year'),
|
||||||
'rating_key': helpers.get_xml_attr(session, 'ratingKey'),
|
'rating_key': helpers.get_xml_attr(session, 'ratingKey'),
|
||||||
'parent_rating_key': helpers.get_xml_attr(session, 'parentRatingKey'),
|
'parent_rating_key': helpers.get_xml_attr(session, 'parentRatingKey'),
|
||||||
|
@ -1131,6 +1136,7 @@ class PmsConnect(object):
|
||||||
'video_resolution': '',
|
'video_resolution': '',
|
||||||
'video_framerate': '',
|
'video_framerate': '',
|
||||||
'aspect_ratio': '',
|
'aspect_ratio': '',
|
||||||
|
'transcode_decision': transcode_decision,
|
||||||
'transcode_audio_channels': transcode_audio_channels,
|
'transcode_audio_channels': transcode_audio_channels,
|
||||||
'transcode_audio_codec': transcode_audio_codec,
|
'transcode_audio_codec': transcode_audio_codec,
|
||||||
'transcode_video_codec': '',
|
'transcode_video_codec': '',
|
||||||
|
@ -1190,6 +1196,14 @@ class PmsConnect(object):
|
||||||
transcode_container = ''
|
transcode_container = ''
|
||||||
transcode_protocol = ''
|
transcode_protocol = ''
|
||||||
|
|
||||||
|
# Generate a combined transcode decision value
|
||||||
|
if video_decision == 'transcode' or audio_decision == 'transcode':
|
||||||
|
transcode_decision = 'transcode'
|
||||||
|
elif video_decision == 'copy' or audio_decision == 'copy':
|
||||||
|
transcode_decision = 'copy'
|
||||||
|
else:
|
||||||
|
transcode_decision = 'direct play'
|
||||||
|
|
||||||
if media_info.getElementsByTagName('Part'):
|
if media_info.getElementsByTagName('Part'):
|
||||||
indexes = helpers.get_xml_attr(media_info.getElementsByTagName('Part')[0], 'indexes')
|
indexes = helpers.get_xml_attr(media_info.getElementsByTagName('Part')[0], 'indexes')
|
||||||
part_id = helpers.get_xml_attr(media_info.getElementsByTagName('Part')[0], 'id')
|
part_id = helpers.get_xml_attr(media_info.getElementsByTagName('Part')[0], 'id')
|
||||||
|
@ -1241,6 +1255,8 @@ class PmsConnect(object):
|
||||||
'grandparent_title': helpers.get_xml_attr(session, 'grandparentTitle'),
|
'grandparent_title': helpers.get_xml_attr(session, 'grandparentTitle'),
|
||||||
'parent_title': helpers.get_xml_attr(session, 'parentTitle'),
|
'parent_title': helpers.get_xml_attr(session, 'parentTitle'),
|
||||||
'title': helpers.get_xml_attr(session, 'title'),
|
'title': helpers.get_xml_attr(session, 'title'),
|
||||||
|
'full_title': '%s - %s' % (helpers.get_xml_attr(session, 'grandparentTitle'),
|
||||||
|
helpers.get_xml_attr(session, 'title')),
|
||||||
'year': helpers.get_xml_attr(session, 'year'),
|
'year': helpers.get_xml_attr(session, 'year'),
|
||||||
'rating_key': helpers.get_xml_attr(session, 'ratingKey'),
|
'rating_key': helpers.get_xml_attr(session, 'ratingKey'),
|
||||||
'parent_rating_key': helpers.get_xml_attr(session, 'parentRatingKey'),
|
'parent_rating_key': helpers.get_xml_attr(session, 'parentRatingKey'),
|
||||||
|
@ -1263,6 +1279,7 @@ class PmsConnect(object):
|
||||||
'video_resolution': video_resolution,
|
'video_resolution': video_resolution,
|
||||||
'video_framerate': video_framerate,
|
'video_framerate': video_framerate,
|
||||||
'aspect_ratio': aspect_ratio,
|
'aspect_ratio': aspect_ratio,
|
||||||
|
'transcode_decision': transcode_decision,
|
||||||
'transcode_audio_channels': transcode_audio_channels,
|
'transcode_audio_channels': transcode_audio_channels,
|
||||||
'transcode_audio_codec': transcode_audio_codec,
|
'transcode_audio_codec': transcode_audio_codec,
|
||||||
'transcode_video_codec': transcode_video_codec,
|
'transcode_video_codec': transcode_video_codec,
|
||||||
|
@ -1302,6 +1319,7 @@ class PmsConnect(object):
|
||||||
'grandparent_title': helpers.get_xml_attr(session, 'grandparentTitle'),
|
'grandparent_title': helpers.get_xml_attr(session, 'grandparentTitle'),
|
||||||
'parent_title': helpers.get_xml_attr(session, 'parentTitle'),
|
'parent_title': helpers.get_xml_attr(session, 'parentTitle'),
|
||||||
'title': helpers.get_xml_attr(session, 'title'),
|
'title': helpers.get_xml_attr(session, 'title'),
|
||||||
|
'full_title': helpers.get_xml_attr(session, 'title'),
|
||||||
'year': helpers.get_xml_attr(session, 'year'),
|
'year': helpers.get_xml_attr(session, 'year'),
|
||||||
'rating_key': helpers.get_xml_attr(session, 'ratingKey'),
|
'rating_key': helpers.get_xml_attr(session, 'ratingKey'),
|
||||||
'parent_rating_key': helpers.get_xml_attr(session, 'parentRatingKey'),
|
'parent_rating_key': helpers.get_xml_attr(session, 'parentRatingKey'),
|
||||||
|
@ -1324,6 +1342,7 @@ class PmsConnect(object):
|
||||||
'video_resolution': video_resolution,
|
'video_resolution': video_resolution,
|
||||||
'video_framerate': video_framerate,
|
'video_framerate': video_framerate,
|
||||||
'aspect_ratio': aspect_ratio,
|
'aspect_ratio': aspect_ratio,
|
||||||
|
'transcode_decision': transcode_decision,
|
||||||
'transcode_audio_channels': transcode_audio_channels,
|
'transcode_audio_channels': transcode_audio_channels,
|
||||||
'transcode_audio_codec': transcode_audio_codec,
|
'transcode_audio_codec': transcode_audio_codec,
|
||||||
'transcode_video_codec': transcode_video_codec,
|
'transcode_video_codec': transcode_video_codec,
|
||||||
|
@ -1363,6 +1382,7 @@ class PmsConnect(object):
|
||||||
'grandparent_title': helpers.get_xml_attr(session, 'grandparentTitle'),
|
'grandparent_title': helpers.get_xml_attr(session, 'grandparentTitle'),
|
||||||
'parent_title': helpers.get_xml_attr(session, 'parentTitle'),
|
'parent_title': helpers.get_xml_attr(session, 'parentTitle'),
|
||||||
'title': helpers.get_xml_attr(session, 'title'),
|
'title': helpers.get_xml_attr(session, 'title'),
|
||||||
|
'full_title': helpers.get_xml_attr(session, 'title'),
|
||||||
'year': helpers.get_xml_attr(session, 'year'),
|
'year': helpers.get_xml_attr(session, 'year'),
|
||||||
'rating_key': helpers.get_xml_attr(session, 'ratingKey'),
|
'rating_key': helpers.get_xml_attr(session, 'ratingKey'),
|
||||||
'parent_rating_key': helpers.get_xml_attr(session, 'parentRatingKey'),
|
'parent_rating_key': helpers.get_xml_attr(session, 'parentRatingKey'),
|
||||||
|
@ -1385,6 +1405,7 @@ class PmsConnect(object):
|
||||||
'video_resolution': video_resolution,
|
'video_resolution': video_resolution,
|
||||||
'video_framerate': video_framerate,
|
'video_framerate': video_framerate,
|
||||||
'aspect_ratio': aspect_ratio,
|
'aspect_ratio': aspect_ratio,
|
||||||
|
'transcode_decision': transcode_decision,
|
||||||
'transcode_audio_channels': transcode_audio_channels,
|
'transcode_audio_channels': transcode_audio_channels,
|
||||||
'transcode_audio_codec': transcode_audio_codec,
|
'transcode_audio_codec': transcode_audio_codec,
|
||||||
'transcode_video_codec': transcode_video_codec,
|
'transcode_video_codec': transcode_video_codec,
|
||||||
|
@ -1430,6 +1451,9 @@ class PmsConnect(object):
|
||||||
transcode_container = ''
|
transcode_container = ''
|
||||||
transcode_protocol = ''
|
transcode_protocol = ''
|
||||||
|
|
||||||
|
# Generate a combined transcode decision value
|
||||||
|
transcode_decision = video_decision
|
||||||
|
|
||||||
user_details = user_data.get_details(
|
user_details = user_data.get_details(
|
||||||
user=helpers.get_xml_attr(session.getElementsByTagName('User')[0], 'title'))
|
user=helpers.get_xml_attr(session.getElementsByTagName('User')[0], 'title'))
|
||||||
|
|
||||||
|
@ -1464,6 +1488,8 @@ class PmsConnect(object):
|
||||||
'grandparent_title': helpers.get_xml_attr(session, 'grandparentTitle'),
|
'grandparent_title': helpers.get_xml_attr(session, 'grandparentTitle'),
|
||||||
'parent_title': helpers.get_xml_attr(session, 'parentTitle'),
|
'parent_title': helpers.get_xml_attr(session, 'parentTitle'),
|
||||||
'title': helpers.get_xml_attr(session, 'title'),
|
'title': helpers.get_xml_attr(session, 'title'),
|
||||||
|
'full_title': '%s - %s' % (helpers.get_xml_attr(session, 'grandparentTitle'),
|
||||||
|
helpers.get_xml_attr(session, 'title')),
|
||||||
'year': helpers.get_xml_attr(session, 'year'),
|
'year': helpers.get_xml_attr(session, 'year'),
|
||||||
'rating_key': helpers.get_xml_attr(session, 'ratingKey'),
|
'rating_key': helpers.get_xml_attr(session, 'ratingKey'),
|
||||||
'parent_rating_key': helpers.get_xml_attr(session, 'parentRatingKey'),
|
'parent_rating_key': helpers.get_xml_attr(session, 'parentRatingKey'),
|
||||||
|
@ -1486,6 +1512,7 @@ class PmsConnect(object):
|
||||||
'video_resolution': '',
|
'video_resolution': '',
|
||||||
'video_framerate': '',
|
'video_framerate': '',
|
||||||
'aspect_ratio': aspect_ratio,
|
'aspect_ratio': aspect_ratio,
|
||||||
|
'transcode_decision': transcode_decision,
|
||||||
'transcode_audio_channels': '',
|
'transcode_audio_channels': '',
|
||||||
'transcode_audio_codec': '',
|
'transcode_audio_codec': '',
|
||||||
'transcode_video_codec': transcode_video_codec,
|
'transcode_video_codec': transcode_video_codec,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue