From 2db328ac31482158cc0815e721935824dfab4c33 Mon Sep 17 00:00:00 2001 From: samwiseg0 Date: Thu, 19 Sep 2019 20:45:53 -0400 Subject: [PATCH 1/9] Standardize videoResolution to be lowercase --- plexpy/pmsconnect.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index 68445627..63001785 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -1290,7 +1290,7 @@ class PmsConnect(object): 'width': helpers.get_xml_attr(media, 'width'), 'aspect_ratio': helpers.get_xml_attr(media, 'aspectRatio'), 'video_codec': helpers.get_xml_attr(media, 'videoCodec'), - 'video_resolution': helpers.get_xml_attr(media, 'videoResolution'), + 'video_resolution': helpers.get_xml_attr(media, 'videoResolution').lower(), 'video_framerate': helpers.get_xml_attr(media, 'videoFrameRate'), 'video_profile': helpers.get_xml_attr(media, 'videoProfile'), 'audio_codec': helpers.get_xml_attr(media, 'audioCodec'), @@ -1730,7 +1730,7 @@ class PmsConnect(object): if helpers.cast_to_int(stream_video_width) >= 3840: stream_video_resolution = '4k' else: - stream_video_resolution = helpers.get_xml_attr(stream_media_info, 'videoResolution').rstrip('p') + stream_video_resolution = helpers.get_xml_attr(stream_media_info, 'videoResolution').rstrip('p').lower() stream_audio_channels = helpers.get_xml_attr(stream_media_info, 'audioChannels') @@ -1810,7 +1810,7 @@ class PmsConnect(object): 'height': helpers.get_xml_attr(stream_media_info, 'height'), 'width': helpers.get_xml_attr(stream_media_info, 'width'), 'video_codec': helpers.get_xml_attr(stream_media_info, 'videoCodec'), - 'video_resolution': helpers.get_xml_attr(stream_media_info, 'videoResolution'), + 'video_resolution': helpers.get_xml_attr(stream_media_info, 'videoResolution').lower(), 'audio_codec': helpers.get_xml_attr(stream_media_info, 'audioCodec'), 'audio_channels': audio_channels, 'audio_channel_layout': common.AUDIO_CHANNELS.get(audio_channels, audio_channels), @@ -2467,7 +2467,7 @@ class PmsConnect(object): 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_resolution': helpers.get_xml_attr(media, 'videoResolution').lower(), 'video_framerate': helpers.get_xml_attr(media, 'videoFrameRate'), 'audio_codec': helpers.get_xml_attr(media, 'audioCodec'), 'audio_channels': helpers.get_xml_attr(media, 'audioChannels'), From 0ac1ad4386c76bcbb75204a47e2fe2e8b65c6ecd Mon Sep 17 00:00:00 2001 From: samwiseg0 Date: Thu, 19 Sep 2019 20:46:38 -0400 Subject: [PATCH 2/9] Create video_scan_type and stream_video_scan_type --- plexpy/pmsconnect.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index 63001785..90c7b106 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -1242,6 +1242,7 @@ class PmsConnect(object): '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_scan_type': helpers.get_xml_attr(stream, 'scanType'), 'selected': int(helpers.get_xml_attr(stream, 'selected') == '1') }) @@ -1661,6 +1662,7 @@ class PmsConnect(object): 'stream_video_ref_frames': helpers.get_xml_attr(video_stream_info, 'refFrames'), 'stream_video_language': helpers.get_xml_attr(video_stream_info, 'language'), 'stream_video_language_code': helpers.get_xml_attr(video_stream_info, 'languageCode'), + 'stream_video_scan_type': helpers.get_xml_attr(video_stream_info, 'scanType'), 'stream_video_decision': helpers.get_xml_attr(video_stream_info, 'decision') or 'direct play' } else: @@ -1670,6 +1672,7 @@ class PmsConnect(object): 'stream_video_ref_frames': '', 'stream_video_language': '', 'stream_video_language_code': '', + 'stream_video_scan_type': '', 'stream_video_decision': '' } @@ -1849,6 +1852,7 @@ class PmsConnect(object): 'video_width': '', 'video_language': '', 'video_language_code': '', + 'video_scan_type': '', 'video_profile': '' } source_audio_details = {'id': '', From 2737d52279723e5799c55ba7164fd28e46d989fd Mon Sep 17 00:00:00 2001 From: samwiseg0 Date: Thu, 19 Sep 2019 20:47:39 -0400 Subject: [PATCH 3/9] Set the full resolution of the source video and stream video --- plexpy/pmsconnect.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index 90c7b106..273b235a 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -1925,6 +1925,14 @@ class PmsConnect(object): # Get the quality profile if media_type in ('movie', 'episode', 'clip') and 'stream_bitrate' in stream_details: + # Set the full resolution by combining video_resolution and video_scan_type + 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 + stream_details['stream_video_full_resolution'] = plexpy.common.VIDEO_RESOLUTION_OVERRIDES.get( + stream_details['stream_video_resolution'], + stream_details['stream_video_resolution'] + (video_details['stream_video_scan_type'][:1] or 'p')) if sync_id: quality_profile = 'Original' From a59e8298fdd302f2d9c564a666e16feeb0608276 Mon Sep 17 00:00:00 2001 From: samwiseg0 Date: Thu, 19 Sep 2019 20:50:17 -0400 Subject: [PATCH 4/9] Use video_full_resolution for optimized versions in the activity card --- plexpy/pmsconnect.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index 273b235a..aa73ebde 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -1957,8 +1957,7 @@ class PmsConnect(object): if stream_details['optimized_version']: source_bitrate = helpers.cast_to_int(source_media_details.get('bitrate')) optimized_version_profile = '{} Mbps {}'.format(round(source_bitrate / 1000.0, 1), - plexpy.common.VIDEO_RESOLUTION_OVERRIDES.get(source_media_details['video_resolution'], - source_media_details['video_resolution'])) + source_media_details['video_full_resolution']) else: optimized_version_profile = '' From 7095fa6ac62a541b8728187de4c0377ab9e1e180 Mon Sep 17 00:00:00 2001 From: samwiseg0 Date: Thu, 19 Sep 2019 20:53:18 -0400 Subject: [PATCH 5/9] Remove overrides --- plexpy/common.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/plexpy/common.py b/plexpy/common.py index 1ef38a5a..8e50e800 100644 --- a/plexpy/common.py +++ b/plexpy/common.py @@ -119,11 +119,6 @@ AUDIO_CODEC_OVERRIDES = { VIDEO_RESOLUTION_OVERRIDES = { 'sd': 'SD', - '480': '480p', - '540': '540p', - '576': '576p', - '720': '720p', - '1080': '1080p', '4k': '4k' } From de69945ebe0bf1e91dd2fc0ddf8862ddfeb18f50 Mon Sep 17 00:00:00 2001 From: samwiseg0 Date: Thu, 19 Sep 2019 20:57:08 -0400 Subject: [PATCH 6/9] Define notification parameters --- plexpy/common.py | 4 ++++ plexpy/notification_handler.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/plexpy/common.py b/plexpy/common.py index 8e50e800..05144ac8 100644 --- a/plexpy/common.py +++ b/plexpy/common.py @@ -361,8 +361,10 @@ NOTIFICATION_PARAMETERS = [ {'name': 'Stream Video Bitrate', 'type': 'int', 'value': 'stream_video_bitrate', 'description': 'The video bitrate (in kbps) of the stream.'}, {'name': 'Stream Video Bit Depth', 'type': 'int', 'value': 'stream_video_bit_depth', 'description': 'The video bit depth of the stream.'}, {'name': 'Stream Video Framerate', 'type': 'str', 'value': 'stream_video_framerate', 'description': 'The video framerate of the stream.'}, + {'name': 'Stream Video Full Resolution', 'type': 'str', 'value': 'stream_video_full_resolution', 'description': 'The video resolution of the stream with scan type.'}, {'name': 'Stream Video Ref Frames', 'type': 'int', 'value': 'stream_video_ref_frames', 'description': 'The video reference frames of the stream.'}, {'name': 'Stream Video Resolution', 'type': 'str', 'value': 'stream_video_resolution', 'description': 'The video resolution of the stream.'}, + {'name': 'Stream Video Scan Type', 'type': 'str', 'value': 'stream_video_scan_type', 'description': 'The video scan type of the stream.'}, {'name': 'Stream Video Height', 'type': 'int', 'value': 'stream_video_height', 'description': 'The video height of the stream.'}, {'name': 'Stream Video Width', 'type': 'int', 'value': 'stream_video_width', 'description': 'The video width of the stream.'}, {'name': 'Stream Video Language', 'type': 'str', 'value': 'stream_video_language', 'description': 'The video language of the stream.'}, @@ -464,8 +466,10 @@ NOTIFICATION_PARAMETERS = [ {'name': 'Video Bitrate', 'type': 'int', 'value': 'video_bitrate', 'description': 'The video bitrate of the original media.'}, {'name': 'Video Bit Depth', 'type': 'int', 'value': 'video_bit_depth', 'description': 'The video bit depth of the original media.'}, {'name': 'Video Framerate', 'type': 'str', 'value': 'video_framerate', 'description': 'The video framerate of the original media.'}, + {'name': 'Video Full Resolution', 'type': 'str', 'value': 'video_full_resolution', 'description': 'The video resolution of the original media with scan type.'}, {'name': 'Video Ref Frames', 'type': 'int', 'value': 'video_ref_frames', 'description': 'The video reference frames of the original media.'}, {'name': 'Video Resolution', 'type': 'str', 'value': 'video_resolution', 'description': 'The video resolution of the original media.'}, + {'name': 'Video Scan Tpye', 'type': 'str', 'value': 'video_scan_type', 'description': 'The video scan type of the original media.'}, {'name': 'Video Height', 'type': 'int', 'value': 'video_height', 'description': 'The video height of the original media.'}, {'name': 'Video Width', 'type': 'int', 'value': 'video_width', 'description': 'The video width of the original media.'}, {'name': 'Video Language', 'type': 'str', 'value': 'video_language', 'description': 'The video language of the original media.'}, diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 0bba9a9c..3b910c74 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -784,8 +784,10 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m 'stream_video_bitrate': notify_params['stream_video_bitrate'], 'stream_video_bit_depth': notify_params['stream_video_bit_depth'], 'stream_video_framerate': notify_params['stream_video_framerate'], + 'stream_video_full_resolution': notify_params['stream_video_full_resolution'], 'stream_video_ref_frames': notify_params['stream_video_ref_frames'], 'stream_video_resolution': notify_params['stream_video_resolution'], + 'stream_video_scan_type': notify_params['stream_video_scan_type'], 'stream_video_height': notify_params['stream_video_height'], 'stream_video_width': notify_params['stream_video_width'], 'stream_video_language': notify_params['stream_video_language'], @@ -890,8 +892,10 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m 'video_bitrate': notify_params['video_bitrate'], 'video_bit_depth': notify_params['video_bit_depth'], 'video_framerate': notify_params['video_framerate'], + 'video_full_resolution': notify_params['video_full_resolution'], 'video_ref_frames': notify_params['video_ref_frames'], 'video_resolution': notify_params['video_resolution'], + 'video_scan_type': notify_params['video_scan_type'], 'video_height': notify_params['height'], 'video_width': notify_params['width'], 'video_language': notify_params['video_language'], From 623a1e8a91f4b7495689d1b238f9d27502204769 Mon Sep 17 00:00:00 2001 From: samwiseg0 Date: Thu, 19 Sep 2019 21:22:02 -0400 Subject: [PATCH 7/9] Update webui to utilize video full resolution --- data/interfaces/default/current_activity_instance.html | 6 +++--- data/interfaces/default/index.html | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/data/interfaces/default/current_activity_instance.html b/data/interfaces/default/current_activity_instance.html index 75aca00e..f02b39f7 100644 --- a/data/interfaces/default/current_activity_instance.html +++ b/data/interfaces/default/current_activity_instance.html @@ -232,11 +232,11 @@ DOCUMENTATION :: END hw_d = ' (HW)' if data['transcode_hw_decoding'] else '' hw_e = ' (HW)' if data['transcode_hw_encoding'] else '' %> - Transcode (${data['video_codec'].upper()}${hw_d} ${VIDEO_RESOLUTION_OVERRIDES.get(data['video_resolution'], data['video_resolution'])} ${data['stream_video_codec'].upper()}${hw_e} ${VIDEO_RESOLUTION_OVERRIDES.get(data['stream_video_resolution'], data['stream_video_resolution'])}) + Transcode (${data['video_codec'].upper()}${hw_d} ${data['video_full_resolution']} ${data['stream_video_codec'].upper()}${hw_e} ${data['stream_video_full_resolution']}) % elif data['stream_video_decision'] == 'copy': - Direct Stream (${data['stream_video_codec'].upper()} ${VIDEO_RESOLUTION_OVERRIDES.get(data['stream_video_resolution'], data['stream_video_resolution'])}) + Direct Stream (${data['stream_video_codec'].upper()} ${data['stream_video_full_resolution']}) % else: - Direct Play (${data['stream_video_codec'].upper()} ${VIDEO_RESOLUTION_OVERRIDES.get(data['stream_video_resolution'], data['stream_video_resolution'])}) + Direct Play (${data['stream_video_codec'].upper()} ${data['stream_video_full_resolution']}) % endif % elif data['media_type'] == 'photo': Direct Play (${data['width']}x${data['height']}) diff --git a/data/interfaces/default/index.html b/data/interfaces/default/index.html index d323080e..8b27d2f5 100644 --- a/data/interfaces/default/index.html +++ b/data/interfaces/default/index.html @@ -445,7 +445,7 @@ v_res = '4k'; break; default: - v_res = s.video_resolution + 'p' + v_res = s.video_full_resolution; } var sv_res = ''; switch (s.stream_video_resolution.toLowerCase()) { @@ -456,7 +456,7 @@ sv_res = '4k'; break; default: - sv_res = s.stream_video_resolution + 'p' + sv_res = s.stream_video_full_resolution; } if (s.stream_video_decision === 'transcode') { var hw_d = (s.transcode_hw_decoding === 1) ? ' (HW)' : ''; From 85709f754a3c55f53f8fd5f69031777644b1998a Mon Sep 17 00:00:00 2001 From: samwiseg0 Date: Thu, 19 Sep 2019 21:22:37 -0400 Subject: [PATCH 8/9] Update API docs to reflect changes --- API.md | 4 ++++ plexpy/webserve.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/API.md b/API.md index a2ebc994..e2be56d5 100644 --- a/API.md +++ b/API.md @@ -507,7 +507,9 @@ Returns: "stream_video_language": "", "stream_video_language_code": "", "stream_video_ref_frames": "4", + "stream_video_full_resolution": "1080p", "stream_video_resolution": "1080", + "stream_video_scan_type": "progressive", "stream_video_width": "1920", "studio": "HBO", "subtitle_codec": "", @@ -560,12 +562,14 @@ Returns: "video_decision": "direct play", "video_frame_rate": "23.976", "video_framerate": "24p", + "video_full_resolution": "1080p", "video_height": "1078", "video_language": "", "video_language_code": "", "video_profile": "high", "video_ref_frames": "4", "video_resolution": "1080", + "video_scan_type": "progressive", "video_width": "1920", "view_offset": "1000", "width": "1920", diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 8702da80..8154f81a 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -5040,7 +5040,9 @@ class WebInterface(object): "stream_video_language": "", "stream_video_language_code": "", "stream_video_ref_frames": "4", + "stream_video_full_resolution": "1080p", "stream_video_resolution": "1080", + "stream_video_scan_type": "progressive", "stream_video_width": "1920", "studio": "HBO", "subtitle_codec": "", @@ -5093,12 +5095,14 @@ class WebInterface(object): "video_decision": "direct play", "video_frame_rate": "23.976", "video_framerate": "24p", + "video_full_resolution": "1080p", "video_height": "1078", "video_language": "", "video_language_code": "", "video_profile": "high", "video_ref_frames": "4", "video_resolution": "1080", + "video_scan_type": "progressive", "video_width": "1920", "view_offset": "1000", "width": "1920", From 8213f270e5effb875d78034cb158cc6c3906987e Mon Sep 17 00:00:00 2001 From: samwiseg0 Date: Thu, 19 Sep 2019 22:26:43 -0400 Subject: [PATCH 9/9] Move full resolution outside if statement --- plexpy/pmsconnect.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index aa73ebde..ffe75672 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -1923,16 +1923,17 @@ class PmsConnect(object): if transcode_details['transcode_video_codec'] == '*': transcode_details['transcode_video_codec'] = source_video_details['video_codec'] + # Set the full resolution by combining video_resolution and video_scan_type + 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 + stream_details['stream_video_full_resolution'] = plexpy.common.VIDEO_RESOLUTION_OVERRIDES.get( + stream_details['stream_video_resolution'], + stream_details['stream_video_resolution'] + (video_details['stream_video_scan_type'][:1] or 'p')) + # Get the quality profile if media_type in ('movie', 'episode', 'clip') and 'stream_bitrate' in stream_details: - # Set the full resolution by combining video_resolution and video_scan_type - 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 - stream_details['stream_video_full_resolution'] = plexpy.common.VIDEO_RESOLUTION_OVERRIDES.get( - stream_details['stream_video_resolution'], - stream_details['stream_video_resolution'] + (video_details['stream_video_scan_type'][:1] or 'p')) if sync_id: quality_profile = 'Original'