mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-08 14:10:52 -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,
|
'videoProfile': None,
|
||||||
'videoResolution': None,
|
'videoResolution': None,
|
||||||
'width': None,
|
'width': None,
|
||||||
|
'hdr': lambda i: get_any_hdr(i, MOVIE_ATTRS['media']),
|
||||||
'parts': {
|
'parts': {
|
||||||
'accessible': None,
|
'accessible': None,
|
||||||
'audioProfile': None,
|
'audioProfile': None,
|
||||||
|
@ -389,6 +390,7 @@ EPISODE_ATTRS = {
|
||||||
'videoProfile': None,
|
'videoProfile': None,
|
||||||
'videoResolution': None,
|
'videoResolution': None,
|
||||||
'width': None,
|
'width': None,
|
||||||
|
'hdr': lambda i: get_any_hdr(i, EPISODE_ATTRS['media']),
|
||||||
'parts': {
|
'parts': {
|
||||||
'accessible': None,
|
'accessible': None,
|
||||||
'audioProfile': None,
|
'audioProfile': None,
|
||||||
|
@ -876,7 +878,7 @@ MOVIE_LEVELS = {
|
||||||
'locations', 'media.aspectRatio', 'media.audioChannels', 'media.audioCodec', 'media.audioProfile',
|
'locations', 'media.aspectRatio', 'media.audioChannels', 'media.audioCodec', 'media.audioProfile',
|
||||||
'media.bitrate', 'media.container', 'media.duration', 'media.height', 'media.width',
|
'media.bitrate', 'media.container', 'media.duration', 'media.height', 'media.width',
|
||||||
'media.videoCodec', 'media.videoFrameRate', 'media.videoProfile', 'media.videoResolution',
|
'media.videoCodec', 'media.videoFrameRate', 'media.videoProfile', 'media.videoResolution',
|
||||||
'media.optimizedVersion'
|
'media.optimizedVersion', 'media.hdr'
|
||||||
],
|
],
|
||||||
5: [
|
5: [
|
||||||
'media.parts.accessible', 'media.parts.exists', 'media.parts.file', 'media.parts.duration',
|
'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()
|
timestamp = helpers.timestamp()
|
||||||
|
|
||||||
level = helpers.cast_to_int(level)
|
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 = []
|
export_attrs_list = []
|
||||||
for attr in export_attrs_set:
|
for attr in export_attrs_set:
|
||||||
split_attr = attr.split('.')
|
|
||||||
try:
|
try:
|
||||||
value = helpers.get_by_path(media_attrs, split_attr)
|
value = helpers.get_dict_value_by_path(media_attrs, attr)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.warn("Tautulli Exporter :: Unknown export attribute '%s', skipping...", attr)
|
logger.warn("Tautulli Exporter :: Unknown export attribute '%s', skipping...", attr)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for _attr in reversed(split_attr):
|
|
||||||
value = {_attr: value}
|
|
||||||
|
|
||||||
export_attrs_list.append(value)
|
export_attrs_list.append(value)
|
||||||
|
|
||||||
export_attrs = reduce(helpers.dict_merge, export_attrs_list)
|
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.
|
# This file is part of Tautulli.
|
||||||
#
|
#
|
||||||
|
@ -1267,14 +1267,26 @@ def flatten_tree(obj, key=''):
|
||||||
# https://stackoverflow.com/a/14692747
|
# https://stackoverflow.com/a/14692747
|
||||||
def get_by_path(root, items):
|
def get_by_path(root, items):
|
||||||
"""Access a nested object in root by item sequence."""
|
"""Access a nested object in root by item sequence."""
|
||||||
|
if isinstance(items, str):
|
||||||
|
items = items.split('.')
|
||||||
return reduce(operator.getitem, items, root)
|
return reduce(operator.getitem, items, root)
|
||||||
|
|
||||||
|
|
||||||
def set_by_path(root, items, value):
|
def set_by_path(root, items, value):
|
||||||
"""Set a value in a nested object in root by item sequence."""
|
"""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
|
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
|
# https://stackoverflow.com/a/7205107
|
||||||
def dict_merge(a, b, path=None):
|
def dict_merge(a, b, path=None):
|
||||||
if path is None:
|
if path is None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue