mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-12 08:16:06 -07:00
Add media info metadata params for notifications
This commit is contained in:
parent
94ddf041aa
commit
0e58369873
4 changed files with 100 additions and 65 deletions
|
@ -1482,46 +1482,6 @@
|
|||
<td><strong>{progress_percent}</strong></td>
|
||||
<td>The last reported progress percent for the item.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{container}</strong></td>
|
||||
<td>The media container of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{video_codec}</strong></td>
|
||||
<td>The video codec of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{video_bitrate}</strong></td>
|
||||
<td>The video bitrate of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{video_width}</strong></td>
|
||||
<td>The video width of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{video_height}</strong></td>
|
||||
<td>The video height of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{video_resolution}</strong></td>
|
||||
<td>The video resolution of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{video_framerate}</strong></td>
|
||||
<td>The video framerate of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{aspect_ratio}</strong></td>
|
||||
<td>The aspect ratio of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{audio_codec}</strong></td>
|
||||
<td>The audio codec of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{audio_channels}</strong></td>
|
||||
<td>The audio channels of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{transcode_decision}</strong></td>
|
||||
<td>The stream transcode decisions for the media item.</td>
|
||||
|
@ -1589,13 +1549,53 @@
|
|||
<td><strong>{media_type}</strong></td>
|
||||
<td>The type of media. <span class="small-muted">(movie, episode, track)</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{container}</strong></td>
|
||||
<td>The media container of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{video_codec}</strong></td>
|
||||
<td>The video codec of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{video_bitrate}</strong></td>
|
||||
<td>The video bitrate of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{video_width}</strong></td>
|
||||
<td>The video width of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{video_height}</strong></td>
|
||||
<td>The video height of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{video_resolution}</strong></td>
|
||||
<td>The video resolution of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{video_framerate}</strong></td>
|
||||
<td>The video framerate of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{aspect_ratio}</strong></td>
|
||||
<td>The aspect ratio of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{audio_codec}</strong></td>
|
||||
<td>The audio codec of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{audio_channels}</strong></td>
|
||||
<td>The audio channels of the original media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{title}</strong></td>
|
||||
<td>The full title of the item.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{library_name}</strong></td>
|
||||
<td>The library title of the media item.</td>
|
||||
<td>The library name of the item.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{show_name}</strong></td>
|
||||
|
@ -1752,6 +1752,14 @@
|
|||
<td><strong>{trakt_url}</strong></td>
|
||||
<td>The trakt.tv URL for the movie or TV show.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{file}</strong></td>
|
||||
<td>The file path to the item.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{file_size}</strong></td>
|
||||
<td>The file size of the item.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{section_id}</strong></td>
|
||||
<td>The unique identifier for the library.</td>
|
||||
|
|
|
@ -768,3 +768,26 @@ def build_datatables_json(kwargs, dt_columns, default_sort_col=None):
|
|||
"search": {"value": kwargs.pop("search", "")}
|
||||
}
|
||||
return json.dumps(json_data)
|
||||
|
||||
def humanFileSize(bytes, si=False):
|
||||
if str(bytes).isdigit():
|
||||
bytes = int(bytes)
|
||||
else:
|
||||
return bytes
|
||||
|
||||
thresh = 1000 if si else 1024
|
||||
if bytes < thresh:
|
||||
return str(bytes) + ' B'
|
||||
|
||||
if si:
|
||||
units = ('kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB')
|
||||
else:
|
||||
units = ('KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB')
|
||||
|
||||
u = -1
|
||||
|
||||
while bytes >= thresh and u < len(units):
|
||||
bytes /= thresh
|
||||
u += 1
|
||||
|
||||
return "{0:.1f} {1}".format(bytes, units[u])
|
||||
|
|
|
@ -259,7 +259,7 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, *
|
|||
rating_key = timeline['rating_key']
|
||||
|
||||
pms_connect = pmsconnect.PmsConnect()
|
||||
metadata_list = pms_connect.get_metadata_details(rating_key=rating_key)
|
||||
metadata_list = pms_connect.get_metadata_details(rating_key=rating_key, get_media_info=True)
|
||||
|
||||
if metadata_list:
|
||||
metadata = metadata_list['metadata']
|
||||
|
@ -476,16 +476,6 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, *
|
|||
'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',''),
|
||||
'video_bitrate': session.get('bitrate',''),
|
||||
'video_width': session.get('width',''),
|
||||
'video_height': session.get('height',''),
|
||||
'video_resolution': session.get('video_resolution',''),
|
||||
'video_framerate': session.get('video_framerate',''),
|
||||
'aspect_ratio': session.get('aspect_ratio',''),
|
||||
'audio_codec': session.get('audio_codec',''),
|
||||
'audio_channels': session.get('audio_channels',''),
|
||||
'transcode_decision': transcode_decision,
|
||||
'video_decision': session.get('video_decision','').title(),
|
||||
'audio_decision': session.get('audio_decision','').title(),
|
||||
|
@ -501,6 +491,16 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, *
|
|||
'machine_id': session.get('machine_id',''),
|
||||
# Metadata parameters
|
||||
'media_type': metadata['media_type'],
|
||||
'container': session.get('container', metadata.get('container','')),
|
||||
'video_codec': session.get('video_codec', metadata.get('video_codec','')),
|
||||
'video_bitrate': session.get('bitrate', metadata.get('bitrate','')),
|
||||
'video_width': session.get('width', metadata.get('width','')),
|
||||
'video_height': session.get('height', metadata.get('height','')),
|
||||
'video_resolution': session.get('video_resolution', metadata.get('video_resolution','')),
|
||||
'video_framerate': session.get('video_framerate', metadata.get('video_framerate','')),
|
||||
'aspect_ratio': session.get('aspect_ratio', metadata.get('aspect_ratio','')),
|
||||
'audio_codec': session.get('audio_codec', metadata.get('audio_codec','')),
|
||||
'audio_channels': session.get('audio_channels', metadata.get('audio_channels','')),
|
||||
'title': full_title,
|
||||
'library_name': metadata['library_name'],
|
||||
'show_name': show_name,
|
||||
|
@ -545,6 +545,8 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, *
|
|||
'themoviedb_url': metadata.get('themoviedb_url',''),
|
||||
'lastfm_url': metadata.get('lastfm_url',''),
|
||||
'trakt_url': metadata.get('trakt_url',''),
|
||||
'file': metadata.get('file',''),
|
||||
'file_size': helpers.humanFileSize(metadata.get('file_size','')),
|
||||
'section_id': metadata['section_id'],
|
||||
'rating_key': metadata['rating_key'],
|
||||
'parent_rating_key': metadata['parent_rating_key'],
|
||||
|
|
|
@ -872,17 +872,19 @@ class PmsConnect(object):
|
|||
return None
|
||||
|
||||
if get_media_info:
|
||||
item_media = metadata_main.getElementsByTagName('Media')
|
||||
for media in item_media:
|
||||
media_info = {'container': helpers.get_xml_attr(media, 'container'),
|
||||
'bitrate': helpers.get_xml_attr(media, 'bitrate'),
|
||||
'video_codec': helpers.get_xml_attr(media, 'videoCodec'),
|
||||
'video_resolution': helpers.get_xml_attr(media, 'videoResolution'),
|
||||
'video_framerate': helpers.get_xml_attr(media, 'videoFrameRate'),
|
||||
'audio_codec': helpers.get_xml_attr(media, 'audioCodec'),
|
||||
'audio_channels': helpers.get_xml_attr(media, 'audioChannels'),
|
||||
'file': helpers.get_xml_attr(media.getElementsByTagName('Part')[0], 'file'),
|
||||
'file_size': helpers.get_xml_attr(media.getElementsByTagName('Part')[0], 'size'),
|
||||
item_media = metadata_main.getElementsByTagName('Media')[0]
|
||||
media_info = {'container': helpers.get_xml_attr(item_media, 'container'),
|
||||
'bitrate': helpers.get_xml_attr(item_media, 'bitrate'),
|
||||
'height': helpers.get_xml_attr(item_media, 'height'),
|
||||
'width': helpers.get_xml_attr(item_media, 'width'),
|
||||
'aspect_ratio': helpers.get_xml_attr(item_media, 'aspectRatio'),
|
||||
'video_codec': helpers.get_xml_attr(item_media, 'videoCodec'),
|
||||
'video_resolution': helpers.get_xml_attr(item_media, 'videoResolution'),
|
||||
'video_framerate': helpers.get_xml_attr(item_media, 'videoFrameRate'),
|
||||
'audio_codec': helpers.get_xml_attr(item_media, 'audioCodec'),
|
||||
'audio_channels': helpers.get_xml_attr(item_media, 'audioChannels'),
|
||||
'file': helpers.get_xml_attr(item_media.getElementsByTagName('Part')[0], 'file'),
|
||||
'file_size': helpers.get_xml_attr(item_media.getElementsByTagName('Part')[0], 'size'),
|
||||
}
|
||||
metadata.update(media_info)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue