mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-08 06:00:51 -07:00
Add hdr attribute to media export
This commit is contained in:
parent
d609c0daeb
commit
35cdef1340
2 changed files with 23 additions and 8 deletions
|
@ -110,6 +110,7 @@ MOVIE_ATTRS = {
|
|||
'videoProfile': None,
|
||||
'videoResolution': None,
|
||||
'width': None,
|
||||
'hdr': lambda i: get_any_hdr(i, MOVIE_ATTRS['media']),
|
||||
'parts': {
|
||||
'accessible': None,
|
||||
'audioProfile': None,
|
||||
|
@ -389,6 +390,7 @@ EPISODE_ATTRS = {
|
|||
'videoProfile': None,
|
||||
'videoResolution': None,
|
||||
'width': None,
|
||||
'hdr': lambda i: get_any_hdr(i, EPISODE_ATTRS['media']),
|
||||
'parts': {
|
||||
'accessible': None,
|
||||
'audioProfile': None,
|
||||
|
@ -876,7 +878,7 @@ MOVIE_LEVELS = {
|
|||
'locations', 'media.aspectRatio', 'media.audioChannels', 'media.audioCodec', 'media.audioProfile',
|
||||
'media.bitrate', 'media.container', 'media.duration', 'media.height', 'media.width',
|
||||
'media.videoCodec', 'media.videoFrameRate', 'media.videoProfile', 'media.videoResolution',
|
||||
'media.optimizedVersion'
|
||||
'media.optimizedVersion', 'media.hdr'
|
||||
],
|
||||
5: [
|
||||
'media.parts.accessible', 'media.parts.exists', 'media.parts.file', 'media.parts.duration',
|
||||
|
@ -944,7 +946,12 @@ MEDIA_TYPES = {
|
|||
}
|
||||
|
||||
|
||||
def export(section_id=None, rating_key=None, file_format='json', level=1):
|
||||
def get_any_hdr(obj, root):
|
||||
attrs = helpers.get_dict_value_by_path(root, 'parts.videoStreams.hdr')
|
||||
media = helpers.get_attrs_to_dict(obj, attrs)
|
||||
return any(vs.get('hdr') for p in media.get('parts', []) for vs in p.get('videoStreams', []))
|
||||
|
||||
|
||||
timestamp = helpers.timestamp()
|
||||
|
||||
level = helpers.cast_to_int(level)
|
||||
|
@ -1022,16 +1029,12 @@ def export(section_id=None, rating_key=None, file_format='json', level=1):
|
|||
|
||||
export_attrs_list = []
|
||||
for attr in export_attrs_set:
|
||||
split_attr = attr.split('.')
|
||||
try:
|
||||
value = helpers.get_by_path(media_attrs, split_attr)
|
||||
value = helpers.get_dict_value_by_path(media_attrs, attr)
|
||||
except KeyError:
|
||||
logger.warn("Tautulli Exporter :: Unknown export attribute '%s', skipping...", attr)
|
||||
continue
|
||||
|
||||
for _attr in reversed(split_attr):
|
||||
value = {_attr: value}
|
||||
|
||||
export_attrs_list.append(value)
|
||||
|
||||
export_attrs = reduce(helpers.dict_merge, export_attrs_list)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# This file is part of Tautulli.
|
||||
#
|
||||
|
@ -1267,14 +1267,26 @@ def flatten_tree(obj, key=''):
|
|||
# https://stackoverflow.com/a/14692747
|
||||
def get_by_path(root, items):
|
||||
"""Access a nested object in root by item sequence."""
|
||||
if isinstance(items, str):
|
||||
items = items.split('.')
|
||||
return reduce(operator.getitem, items, root)
|
||||
|
||||
|
||||
def set_by_path(root, items, value):
|
||||
"""Set a value in a nested object in root by item sequence."""
|
||||
if isinstance(items, str):
|
||||
items = items.split('.')
|
||||
get_by_path(root, items[:-1])[items[-1]] = value
|
||||
|
||||
|
||||
def get_dict_value_by_path(root, attr):
|
||||
split_attr = attr.split('.')
|
||||
value = get_by_path(root, split_attr)
|
||||
for _attr in reversed(split_attr):
|
||||
value = {_attr: value}
|
||||
return value
|
||||
|
||||
|
||||
# https://stackoverflow.com/a/7205107
|
||||
def dict_merge(a, b, path=None):
|
||||
if path is None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue