Get srouce video_full_resolution from Plex metadata

This commit is contained in:
JonnyWong16 2019-09-27 13:26:55 -07:00
parent 57eb57d4d7
commit fd7b4ec7e3
3 changed files with 26 additions and 10 deletions

2
API.md
View file

@ -1154,6 +1154,7 @@ Returns:
"video_language_code": "", "video_language_code": "",
"video_profile": "high", "video_profile": "high",
"video_ref_frames": "4", "video_ref_frames": "4",
"video_scan_type": "progressive",
"video_width": "1920", "video_width": "1920",
"selected": 0 "selected": 0
}, },
@ -1188,6 +1189,7 @@ Returns:
], ],
"video_codec": "h264", "video_codec": "h264",
"video_framerate": "24p", "video_framerate": "24p",
"video_full_resolution": "1080p",
"video_profile": "high", "video_profile": "high",
"video_resolution": "1080", "video_resolution": "1080",
"width": "1920" "width": "1920"

View file

@ -1220,6 +1220,7 @@ class PmsConnect(object):
medias = [] medias = []
media_items = metadata_main.getElementsByTagName('Media') media_items = metadata_main.getElementsByTagName('Media')
for media in media_items: for media in media_items:
video_full_resolution_scan_type = None
parts = [] parts = []
part_items = media.getElementsByTagName('Part') part_items = media.getElementsByTagName('Part')
@ -1229,6 +1230,10 @@ class PmsConnect(object):
stream_items = part.getElementsByTagName('Stream') stream_items = part.getElementsByTagName('Stream')
for stream in stream_items: for stream in stream_items:
if helpers.get_xml_attr(stream, 'streamType') == '1': if helpers.get_xml_attr(stream, 'streamType') == '1':
video_scan_type = helpers.get_xml_attr(stream, 'scanType')
if video_full_resolution_scan_type is None:
video_full_resolution_scan_type = video_scan_type
streams.append({'id': helpers.get_xml_attr(stream, 'id'), streams.append({'id': helpers.get_xml_attr(stream, 'id'),
'type': helpers.get_xml_attr(stream, 'streamType'), 'type': helpers.get_xml_attr(stream, 'streamType'),
'video_codec': helpers.get_xml_attr(stream, 'codec'), 'video_codec': helpers.get_xml_attr(stream, 'codec'),
@ -1282,6 +1287,13 @@ class PmsConnect(object):
'selected': int(helpers.get_xml_attr(part, 'selected') == '1') 'selected': int(helpers.get_xml_attr(part, 'selected') == '1')
}) })
video_resolution = helpers.get_xml_attr(media, 'videoResolution').lower()
video_full_resolution = ''
if video_full_resolution_scan_type is not None:
video_full_resolution = common.VIDEO_RESOLUTION_OVERRIDES.get(
video_resolution, video_resolution + (video_full_resolution_scan_type[:1] or 'p')
)
audio_channels = helpers.get_xml_attr(media, 'audioChannels') audio_channels = helpers.get_xml_attr(media, 'audioChannels')
medias.append({'id': helpers.get_xml_attr(media, 'id'), medias.append({'id': helpers.get_xml_attr(media, 'id'),
@ -1291,7 +1303,8 @@ class PmsConnect(object):
'width': helpers.get_xml_attr(media, 'width'), 'width': helpers.get_xml_attr(media, 'width'),
'aspect_ratio': helpers.get_xml_attr(media, 'aspectRatio'), 'aspect_ratio': helpers.get_xml_attr(media, 'aspectRatio'),
'video_codec': helpers.get_xml_attr(media, 'videoCodec'), 'video_codec': helpers.get_xml_attr(media, 'videoCodec'),
'video_resolution': helpers.get_xml_attr(media, 'videoResolution').lower(), 'video_resolution': video_resolution,
'video_full_resolution': video_full_resolution,
'video_framerate': helpers.get_xml_attr(media, 'videoFrameRate'), 'video_framerate': helpers.get_xml_attr(media, 'videoFrameRate'),
'video_profile': helpers.get_xml_attr(media, 'videoProfile'), 'video_profile': helpers.get_xml_attr(media, 'videoProfile'),
'audio_codec': helpers.get_xml_attr(media, 'audioCodec'), 'audio_codec': helpers.get_xml_attr(media, 'audioCodec'),
@ -1302,6 +1315,8 @@ class PmsConnect(object):
'parts': parts 'parts': parts
}) })
video_full_resolution = helpers.get_xml_attr(media, 'videoResolution').lower()
metadata['media_info'] = medias metadata['media_info'] = medias
if metadata: if metadata:
@ -1926,12 +1941,9 @@ class PmsConnect(object):
if transcode_details['transcode_video_codec'] == '*': if transcode_details['transcode_video_codec'] == '*':
transcode_details['transcode_video_codec'] = source_video_details['video_codec'] transcode_details['transcode_video_codec'] = source_video_details['video_codec']
# Set the full resolution by combining video_resolution and video_scan_type if media_type in ('movie', 'episode', 'clip'):
source_media_details['video_full_resolution'] = plexpy.common.VIDEO_RESOLUTION_OVERRIDES.get(
source_media_details['video_resolution'],
source_media_details['video_resolution'] + (source_video_details['video_scan_type'][:1] or 'p'))
# Set the full resolution by combining stream_video_resolution and stream_video_scan_type # Set the full resolution by combining stream_video_resolution and stream_video_scan_type
stream_details['stream_video_full_resolution'] = plexpy.common.VIDEO_RESOLUTION_OVERRIDES.get( stream_details['stream_video_full_resolution'] = common.VIDEO_RESOLUTION_OVERRIDES.get(
stream_details['stream_video_resolution'], stream_details['stream_video_resolution'],
stream_details['stream_video_resolution'] + (video_details['stream_video_scan_type'][:1] or 'p')) stream_details['stream_video_resolution'] + (video_details['stream_video_scan_type'][:1] or 'p'))

View file

@ -4599,6 +4599,7 @@ class WebInterface(object):
"video_language_code": "", "video_language_code": "",
"video_profile": "high", "video_profile": "high",
"video_ref_frames": "4", "video_ref_frames": "4",
"video_scan_type": "progressive",
"video_width": "1920", "video_width": "1920",
"selected": 0 "selected": 0
}, },
@ -4633,6 +4634,7 @@ class WebInterface(object):
], ],
"video_codec": "h264", "video_codec": "h264",
"video_framerate": "24p", "video_framerate": "24p",
"video_full_resolution": "1080p",
"video_profile": "high", "video_profile": "high",
"video_resolution": "1080", "video_resolution": "1080",
"width": "1920" "width": "1920"