mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-12 08:16:06 -07:00
Use default selected stream for media info in notifications
This commit is contained in:
parent
98b5cb67ca
commit
e567134ee1
4 changed files with 32 additions and 20 deletions
|
@ -633,7 +633,8 @@ class Libraries(object):
|
|||
if 'media_info' in child_metadata and len(child_metadata['media_info']) > 0:
|
||||
media_info = child_metadata['media_info'][0]
|
||||
if 'parts' in media_info and len (media_info['parts']) > 0:
|
||||
media_part_info = media_info['parts'][0]
|
||||
media_part_info = next((p for p in media_info['parts'] if p['selected']),
|
||||
media_info['parts'][0])
|
||||
|
||||
file_size += helpers.cast_to_int(media_part_info.get('file_size', 0))
|
||||
|
||||
|
|
|
@ -486,20 +486,24 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m
|
|||
if 'media_info' in notify_params and len(notify_params['media_info']) > 0:
|
||||
media_info = notify_params['media_info'][0]
|
||||
if 'parts' in media_info and len(media_info['parts']) > 0:
|
||||
media_part_info = media_info.pop('parts')[0]
|
||||
parts = media_info.pop('parts')
|
||||
media_part_info = next((p for p in parts if p['selected']), parts[0])
|
||||
|
||||
stream_video = stream_audio = stream_subtitle = False
|
||||
if 'streams' in media_part_info:
|
||||
for stream in media_part_info.pop('streams'):
|
||||
if not stream_video and stream['type'] == '1':
|
||||
media_part_info.update(stream)
|
||||
stream_video = True
|
||||
if not stream_audio and stream['type'] == '2':
|
||||
media_part_info.update(stream)
|
||||
stream_audio = True
|
||||
if not stream_subtitle and stream['type'] == '3':
|
||||
media_part_info.update(stream)
|
||||
stream_subtitle = True
|
||||
streams = media_part_info.pop('streams')
|
||||
video_streams = [s for s in streams if s['type'] == '1']
|
||||
audio_streams = [s for s in streams if s['type'] == '2']
|
||||
subtitle_streams = [s for s in streams if s['type'] == '3']
|
||||
|
||||
if video_streams:
|
||||
video_stream = next((s for s in video_streams if s['selected']), video_streams[0])
|
||||
media_part_info.update(video_stream)
|
||||
if audio_streams:
|
||||
audio_stream = next((s for s in audio_streams if s['selected']), audio_streams[0])
|
||||
media_part_info.update(audio_stream)
|
||||
if subtitle_streams:
|
||||
subtitle_stream = next((s for s in subtitle_streams if s['selected']), subtitle_streams[0])
|
||||
media_part_info.update(subtitle_stream)
|
||||
|
||||
notify_params.update(media_info)
|
||||
notify_params.update(media_part_info)
|
||||
|
|
|
@ -1213,7 +1213,8 @@ class PmsConnect(object):
|
|||
'video_width': helpers.get_xml_attr(stream, 'width'),
|
||||
'video_language': helpers.get_xml_attr(stream, 'language'),
|
||||
'video_language_code': helpers.get_xml_attr(stream, 'languageCode'),
|
||||
'video_profile': helpers.get_xml_attr(stream, 'profile')
|
||||
'video_profile': helpers.get_xml_attr(stream, 'profile'),
|
||||
'selected': int(helpers.get_xml_attr(stream, 'selected') == '1')
|
||||
})
|
||||
|
||||
elif helpers.get_xml_attr(stream, 'streamType') == '2':
|
||||
|
@ -1227,7 +1228,8 @@ class PmsConnect(object):
|
|||
'audio_sample_rate': helpers.get_xml_attr(stream, 'samplingRate'),
|
||||
'audio_language': helpers.get_xml_attr(stream, 'language'),
|
||||
'audio_language_code': helpers.get_xml_attr(stream, 'languageCode'),
|
||||
'audio_profile': helpers.get_xml_attr(stream, 'profile')
|
||||
'audio_profile': helpers.get_xml_attr(stream, 'profile'),
|
||||
'selected': int(helpers.get_xml_attr(stream, 'selected') == '1')
|
||||
})
|
||||
|
||||
elif helpers.get_xml_attr(stream, 'streamType') == '3':
|
||||
|
@ -1239,14 +1241,16 @@ class PmsConnect(object):
|
|||
'subtitle_forced': int(helpers.get_xml_attr(stream, 'forced') == '1'),
|
||||
'subtitle_location': 'external' if helpers.get_xml_attr(stream, 'key') else 'embedded',
|
||||
'subtitle_language': helpers.get_xml_attr(stream, 'language'),
|
||||
'subtitle_language_code': helpers.get_xml_attr(stream, 'languageCode')
|
||||
'subtitle_language_code': helpers.get_xml_attr(stream, 'languageCode'),
|
||||
'selected': int(helpers.get_xml_attr(stream, 'selected') == '1')
|
||||
})
|
||||
|
||||
parts.append({'id': helpers.get_xml_attr(part, 'id'),
|
||||
'file': helpers.get_xml_attr(part, 'file'),
|
||||
'file_size': helpers.get_xml_attr(part, 'size'),
|
||||
'indexes': int(helpers.get_xml_attr(part, 'indexes') == 'sd'),
|
||||
'streams': streams
|
||||
'streams': streams,
|
||||
'selected': int(helpers.get_xml_attr(part, 'selected') == '1')
|
||||
})
|
||||
|
||||
audio_channels = helpers.get_xml_attr(media, 'audioChannels')
|
||||
|
|
|
@ -4614,7 +4614,8 @@ class WebInterface(object):
|
|||
"video_language_code": "",
|
||||
"video_profile": "high",
|
||||
"video_ref_frames": "4",
|
||||
"video_width": "1920"
|
||||
"video_width": "1920",
|
||||
"selected": 0
|
||||
},
|
||||
{
|
||||
"audio_bitrate": "384",
|
||||
|
@ -4627,7 +4628,8 @@ class WebInterface(object):
|
|||
"audio_profile": "",
|
||||
"audio_sample_rate": "48000",
|
||||
"id": "511664",
|
||||
"type": "2"
|
||||
"type": "2",
|
||||
"selected": 1
|
||||
},
|
||||
{
|
||||
"id": "511953",
|
||||
|
@ -4638,7 +4640,8 @@ class WebInterface(object):
|
|||
"subtitle_language": "English",
|
||||
"subtitle_language_code": "eng",
|
||||
"subtitle_location": "external",
|
||||
"type": "3"
|
||||
"type": "3",
|
||||
"selected": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue