From a98bc45c102b95822b0ea63465b843690244f879 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Fri, 24 Jan 2020 20:14:48 -0800 Subject: [PATCH 001/114] Fix HDR for direct stream video --- plexpy/pmsconnect.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index f81f35e3..297bf2e8 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -1995,7 +1995,8 @@ class PmsConnect(object): else: stream_details['video_dynamic_range'] = 'SDR' - if helpers.cast_to_int(video_details['stream_video_bit_depth']) > 8 \ + if video_details['stream_video_decision'] != 'transcode' \ + or helpers.cast_to_int(video_details['stream_video_bit_depth']) > 8 \ and video_details['stream_video_color_space'] == 'bt2020nc': stream_details['stream_video_dynamic_range'] = 'HDR' else: From 4d4a8ca3b2c3c1cb1ab552c09909f070f4177f8b Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Tue, 28 Jan 2020 10:38:21 -0800 Subject: [PATCH 002/114] Trim MaxMind License Key when saving --- data/interfaces/default/settings.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html index bee08d84..6f6282e8 100644 --- a/data/interfaces/default/settings.html +++ b/data/interfaces/default/settings.html @@ -2868,11 +2868,13 @@ $(document).ready(function() { } $("#install_geoip_db").click(function () { - if ($.trim($("#maxmind_license_key").val()) === "") { - $("#maxmind_license_key").focus(); + var maxmind_license_key = $("#maxmind_license_key"); + maxmind_license_key.val($.trim(maxmind_license_key.val())); + if (maxmind_license_key.val() === "") { + maxmind_license_key.focus(); showMsg(' Maxmind License Key is required.', false, true, 5000, true); return false; - } else if (!(saveSettings())){ + } else if (!(saveSettings())) { return false; } var msg = 'Are you sure you want to install the GeoLite2 database?

' + From 645c2ecef61226b81c5271f7e44105c9aae3d6e1 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Mon, 3 Feb 2020 18:11:56 -0800 Subject: [PATCH 003/114] Use Authorization header for GitHub API --- plexpy/versioncheck.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plexpy/versioncheck.py b/plexpy/versioncheck.py index b9440c19..dce083aa 100644 --- a/plexpy/versioncheck.py +++ b/plexpy/versioncheck.py @@ -158,13 +158,17 @@ def check_update(auto_update=False, notify=False): def check_github(auto_update=False, notify=False): plexpy.COMMITS_BEHIND = 0 + if plexpy.CONFIG.GIT_TOKEN: + headers = {'Authorization': 'token {}'.format(plexpy.CONFIG.GIT_TOKEN)} + else: + headers = {} + # Get the latest version available from github logger.info('Retrieving latest version information from GitHub') url = 'https://api.github.com/repos/%s/%s/commits/%s' % (plexpy.CONFIG.GIT_USER, plexpy.CONFIG.GIT_REPO, plexpy.CONFIG.GIT_BRANCH) - if plexpy.CONFIG.GIT_TOKEN: url = url + '?access_token=%s' % plexpy.CONFIG.GIT_TOKEN - version = request.request_json(url, timeout=20, validator=lambda x: type(x) == dict) + version = request.request_json(url, headers=headers, timeout=20, validator=lambda x: type(x) == dict) if version is None: logger.warn('Could not get the latest version from GitHub. Are you running a local development version?') @@ -187,8 +191,8 @@ def check_github(auto_update=False, notify=False): plexpy.CONFIG.GIT_REPO, plexpy.LATEST_VERSION, plexpy.CURRENT_VERSION) - if plexpy.CONFIG.GIT_TOKEN: url = url + '?access_token=%s' % plexpy.CONFIG.GIT_TOKEN - commits = request.request_json(url, timeout=20, whitelist_status_code=404, validator=lambda x: type(x) == dict) + commits = request.request_json(url, headers=headers, timeout=20, whitelist_status_code=404, + validator=lambda x: type(x) == dict) if commits is None: logger.warn('Could not get commits behind from GitHub.') From bc2f73d68645bdee06729ac80c485b60ab9851be Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Mon, 3 Feb 2020 18:27:41 -0800 Subject: [PATCH 004/114] v2.1.43 --- CHANGELOG.md | 19 +++++++++++++++++++ plexpy/version.py | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41f2eeed..fc9fcdbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## v2.1.43 (2020-02-03) + +* Monitoring: + * New: Added HDR indicator on activity card. + * New: Added dynamic range to history steam info modal. +* Notifications: + * Fix: Webhook notification body sent as incorrect data type when Content-Type header is overridden. + * Fix: Telegram notification character limit incorrect for unicode characters. + * New: Added color and dynamic range notification parameters. +* Newsletters: + * Fix: Episodes and Albums plural spelling on recently added newsletter section headers. +* UI: + * Fix: Windows and macOS platform capitalization. + * Fix: Season number 0 not shown for episodes on history tables. +* Other: + * Change: Mask email addresses in logs. + * Change: Update deprecated GitHub access token URL parameter to Authorization header. + + ## v2.1.42 (2020-01-04) * Other: diff --git a/plexpy/version.py b/plexpy/version.py index 591119a4..bb0fa335 100644 --- a/plexpy/version.py +++ b/plexpy/version.py @@ -1,2 +1,2 @@ PLEXPY_BRANCH = "master" -PLEXPY_RELEASE_VERSION = "v2.1.42" +PLEXPY_RELEASE_VERSION = "v2.1.43" From f88d673e874b222b0abc91b04ccff10d1de543cc Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Tue, 4 Feb 2020 13:48:29 -0800 Subject: [PATCH 005/114] Remove capitalization for platform on history tables --- data/interfaces/default/js/tables/history_table.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/interfaces/default/js/tables/history_table.js b/data/interfaces/default/js/tables/history_table.js index 60f55513..2011ebaa 100644 --- a/data/interfaces/default/js/tables/history_table.js +++ b/data/interfaces/default/js/tables/history_table.js @@ -115,7 +115,7 @@ history_table_options = { "data": "platform", "createdCell": function (td, cellData, rowData, row, col) { if (cellData !== '') { - $(td).html(capitalizeFirstLetter(cellData)); + $(td).html(cellData); } }, "width": "10%", From 99f826c2364db85a71b18b3b372f4e8570e5993f Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Wed, 5 Feb 2020 20:24:43 -0800 Subject: [PATCH 006/114] Fix video color notification condition types --- plexpy/common.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plexpy/common.py b/plexpy/common.py index c3c5c547..1b74989f 100644 --- a/plexpy/common.py +++ b/plexpy/common.py @@ -364,8 +364,8 @@ 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 Chroma Subsampling', 'type': 'str', 'value': 'stream_video_chroma_subsampling', 'description': 'The video chroma subsampling of the stream.'}, - {'name': 'Stream Video Color Primaries', 'type': 'srt', 'value': 'stream_video_color_primaries', 'description': 'The video color primaries of the stream.'}, - {'name': 'Stream Video Color Range', 'type': 'srt', 'value': 'stream_video_color_range', 'description': 'The video color range of the stream.'}, + {'name': 'Stream Video Color Primaries', 'type': 'str', 'value': 'stream_video_color_primaries', 'description': 'The video color primaries of the stream.'}, + {'name': 'Stream Video Color Range', 'type': 'str', 'value': 'stream_video_color_range', 'description': 'The video color range of the stream.'}, {'name': 'Stream Video Color Space', 'type': 'str', 'value': 'stream_video_color_space', 'description': 'The video color space of the stream.'}, {'name': 'Stream Video Color Transfer Function', 'type': 'str', 'value': 'stream_video_color_trc', 'description': 'The video transfer function of the stream.'}, {'name': 'Stream Video Dynamic Range', 'type': 'str', 'value': 'stream_video_dynamic_range', 'description': 'The video dynamic range of the stream.', 'example': 'HDR or SDR'}, @@ -477,8 +477,8 @@ 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 Chroma Subsampling', 'type': 'str', 'value': 'video_chroma_subsampling', 'description': 'The video chroma subsampling of the original media.'}, - {'name': 'Video Color Primaries', 'type': 'srt', 'value': 'video_color_primaries', 'description': 'The video color primaries of the original media.'}, - {'name': 'Video Color Range', 'type': 'srt', 'value': 'video_color_range', 'description': 'The video color range of the original media.'}, + {'name': 'Video Color Primaries', 'type': 'str', 'value': 'video_color_primaries', 'description': 'The video color primaries of the original media.'}, + {'name': 'Video Color Range', 'type': 'str', 'value': 'video_color_range', 'description': 'The video color range of the original media.'}, {'name': 'Video Color Space', 'type': 'str', 'value': 'video_color_space', 'description': 'The video color space of the original media.'}, {'name': 'Video Color Transfer Function', 'type': 'str', 'value': 'video_color_trc', 'description': 'The video transfer function of the original media.'}, {'name': 'Video Dynamic Range', 'type': 'str', 'value': 'video_dynamic_range', 'description': 'The video dynamic range of the original media.', 'example': 'HDR or SDR'}, From 7ae87fe0e7b94039db7cbe648856cd75ef1027e4 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Wed, 5 Feb 2020 21:37:33 -0800 Subject: [PATCH 007/114] Fix SDR source video being identified as HDR stream video --- plexpy/__init__.py | 9 +++++++++ plexpy/pmsconnect.py | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/plexpy/__init__.py b/plexpy/__init__.py index 73f7e63a..63a93802 100644 --- a/plexpy/__init__.py +++ b/plexpy/__init__.py @@ -1569,6 +1569,15 @@ def dbcheck(): c_db.execute( 'ALTER TABLE session_history_media_info ADD COLUMN stream_video_dynamic_range TEXT ' ) + + result = c_db.execute('SELECT * FROM session_history_media_info ' + 'WHERE video_dynamic_range = "SDR" AND stream_video_dynamic_range = "HDR"').fetchone() + if result: + c_db.execute( + 'UPDATE session_history_media_info SET stream_video_dynamic_range = "SDR" ' + 'WHERE video_dynamic_range = "SDR" AND stream_video_dynamic_range = "HDR"' + ) + # Upgrade users table from earlier versions try: c_db.execute('SELECT do_notify FROM users') diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index 297bf2e8..7867fdc4 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -1995,7 +1995,8 @@ class PmsConnect(object): else: stream_details['video_dynamic_range'] = 'SDR' - if video_details['stream_video_decision'] != 'transcode' \ + if stream_details['video_dynamic_range'] == 'HDR' \ + and video_details['stream_video_decision'] != 'transcode' \ or helpers.cast_to_int(video_details['stream_video_bit_depth']) > 8 \ and video_details['stream_video_color_space'] == 'bt2020nc': stream_details['stream_video_dynamic_range'] = 'HDR' From c825176563a21245a035514b1d870aa814d77f63 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Wed, 5 Feb 2020 21:41:31 -0800 Subject: [PATCH 008/114] v2.1.44 --- CHANGELOG.md | 10 ++++++++++ plexpy/version.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc9fcdbc..3d631062 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## v2.1.44 (2020-02-05) + +* Monitoring: + * Fix: SDR source video being identified as HDR stream video. +* Notifications: + * Fix: Unable to select condition operator for video color parameters. +* UI: + * Fix: Capitalization for platforms on history tables. + + ## v2.1.43 (2020-02-03) * Monitoring: diff --git a/plexpy/version.py b/plexpy/version.py index bb0fa335..9b23cb76 100644 --- a/plexpy/version.py +++ b/plexpy/version.py @@ -1,2 +1,2 @@ PLEXPY_BRANCH = "master" -PLEXPY_RELEASE_VERSION = "v2.1.43" +PLEXPY_RELEASE_VERSION = "v2.1.44" From 66de806b02693ce1f6f3d0ca487f3b07a2868fa0 Mon Sep 17 00:00:00 2001 From: Patrick Koenig Date: Fri, 14 Feb 2020 08:11:07 -0800 Subject: [PATCH 009/114] Add crossorigin use-credentials attribute to manifest tag --- data/interfaces/default/base.html | 2 +- data/interfaces/default/login.html | 4 ++-- data/interfaces/default/welcome.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/data/interfaces/default/base.html b/data/interfaces/default/base.html index 38b7cc10..47f262f9 100644 --- a/data/interfaces/default/base.html +++ b/data/interfaces/default/base.html @@ -28,7 +28,7 @@ - + diff --git a/data/interfaces/default/login.html b/data/interfaces/default/login.html index 30e72046..99e906da 100644 --- a/data/interfaces/default/login.html +++ b/data/interfaces/default/login.html @@ -24,7 +24,7 @@ - + @@ -183,4 +183,4 @@ } - \ No newline at end of file + diff --git a/data/interfaces/default/welcome.html b/data/interfaces/default/welcome.html index 88bafce0..10af25ae 100644 --- a/data/interfaces/default/welcome.html +++ b/data/interfaces/default/welcome.html @@ -27,7 +27,7 @@ - + From a811edb236cdb59659299bf61019912db52b3a17 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Sat, 15 Feb 2020 10:03:11 -0800 Subject: [PATCH 010/114] Fix race condition for notification stream count when stopping playback --- plexpy/notification_handler.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 2901bb80..1afbe47e 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -536,8 +536,15 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, m ap = activity_processor.ActivityProcessor() sessions = ap.get_sessions() - stream_count = len(sessions) user_sessions = ap.get_sessions(user_id=session.get('user_id')) + + # Filter out the session_key from the database sessions for playback stopped events + # to prevent race condition between the database and notifications + if notify_action == 'on_stop': + sessions = [s for s in sessions if str(s['session_key']) != notify_params['session_key']] + user_sessions = [s for s in user_sessions if str(s['session_key']) != notify_params['session_key']] + + stream_count = len(sessions) user_stream_count = len(user_sessions) # Generate a combined transcode decision value From 91da41ff867facd0938c902fca3c3d1f77ed637e Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Sat, 15 Feb 2020 10:48:01 -0800 Subject: [PATCH 011/114] Fix Live TV on PMS 1.18.7.2415 crashing Tautulli activity --- plexpy/pmsconnect.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index 7867fdc4..dc0c4671 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -1342,8 +1342,6 @@ class PmsConnect(object): 'parts': parts }) - video_full_resolution = helpers.get_xml_attr(media, 'videoResolution').lower() - metadata['media_info'] = medias if metadata: @@ -1819,7 +1817,7 @@ class PmsConnect(object): source_media_details = source_media_part_details = \ source_video_details = source_audio_details = source_subtitle_details = {} - if not helpers.get_xml_attr(session, 'ratingKey').isdigit(): + if stream_details['live'] or not helpers.get_xml_attr(session, 'ratingKey').isdigit(): channel_stream = 1 audio_channels = helpers.get_xml_attr(stream_media_info, 'audioChannels') @@ -1865,13 +1863,19 @@ class PmsConnect(object): 'full_title': helpers.get_xml_attr(session, 'title'), 'container': helpers.get_xml_attr(stream_media_info, 'container') \ or helpers.get_xml_attr(stream_media_parts_info, 'container'), + 'bitrate': helpers.get_xml_attr(stream_media_info, 'bitrate'), 'height': helpers.get_xml_attr(stream_media_info, 'height'), 'width': helpers.get_xml_attr(stream_media_info, 'width'), + 'aspect_ratio': helpers.get_xml_attr(stream_media_info, 'aspectRatio'), 'video_codec': helpers.get_xml_attr(stream_media_info, 'videoCodec'), 'video_resolution': helpers.get_xml_attr(stream_media_info, 'videoResolution').lower(), + 'video_full_resolution': helpers.get_xml_attr(stream_media_info, 'videoResolution').lower(), + 'video_framerate': helpers.get_xml_attr(stream_media_info, 'videoFrameRate'), + 'video_profile': helpers.get_xml_attr(stream_media_info, 'videoProfile'), '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), + 'audio_profile': helpers.get_xml_attr(stream_media_info, 'audioProfile'), 'channel_icon': helpers.get_xml_attr(session, 'sourceIcon'), 'channel_title': helpers.get_xml_attr(session, 'sourceTitle'), 'extra_type': helpers.get_xml_attr(session, 'extraType'), @@ -1973,15 +1977,15 @@ class PmsConnect(object): # Override * in audio codecs if stream_details['stream_audio_codec'] == '*': - stream_details['stream_audio_codec'] = source_audio_details['audio_codec'] + stream_details['stream_audio_codec'] = source_audio_details.get('audio_codec', '') if transcode_details['transcode_audio_codec'] == '*': - transcode_details['transcode_audio_codec'] = source_audio_details['audio_codec'] + transcode_details['transcode_audio_codec'] = source_audio_details.get('audio_codec', '') # Override * in video codecs if stream_details['stream_video_codec'] == '*': - stream_details['stream_video_codec'] = source_video_details['video_codec'] + stream_details['stream_video_codec'] = source_video_details.get('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.get('video_codec', '') if media_type in ('movie', 'episode', 'clip'): # Set the full resolution by combining stream_video_resolution and stream_video_scan_type @@ -1989,8 +1993,8 @@ class PmsConnect(object): stream_details['stream_video_resolution'], stream_details['stream_video_resolution'] + (video_details['stream_video_scan_type'][:1] or 'p')) - if helpers.cast_to_int(source_video_details['video_bit_depth']) > 8 \ - and source_video_details['video_color_space'] == 'bt2020nc': + if helpers.cast_to_int(source_video_details.get('video_bit_depth')) > 8 \ + and source_video_details.get('video_color_space') == 'bt2020nc': stream_details['video_dynamic_range'] = 'HDR' else: stream_details['video_dynamic_range'] = 'SDR' @@ -2032,7 +2036,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), - source_media_details['video_full_resolution']) + source_media_details.get('video_full_resolution')) else: optimized_version_profile = '' From c6cfb4a020568689a61692c47e8fe44c62f8dbbd Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Sat, 15 Feb 2020 11:44:11 -0800 Subject: [PATCH 012/114] More Live TV fixes --- plexpy/pmsconnect.py | 68 ++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index dc0c4671..564eed41 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -776,7 +776,7 @@ class PmsConnect(object): elif metadata_type == 'season': parent_rating_key = helpers.get_xml_attr(metadata_main, 'parentRatingKey') - show_details = self.get_metadata_details(parent_rating_key) + show_details = self.get_metadata_details(parent_rating_key) if parent_rating_key else {} metadata = {'media_type': metadata_type, 'section_id': section_id, 'library_name': library_name, @@ -790,22 +790,22 @@ class PmsConnect(object): 'sort_title': helpers.get_xml_attr(metadata_main, 'titleSort'), 'media_index': helpers.get_xml_attr(metadata_main, 'index'), 'parent_media_index': helpers.get_xml_attr(metadata_main, 'parentIndex'), - 'studio': show_details['studio'], - 'content_rating': show_details['content_rating'], - 'summary': show_details['summary'], + 'studio': show_details.get('studio', ''), + 'content_rating': show_details.get('content_rating', ''), + 'summary': show_details.get('summary', ''), 'tagline': helpers.get_xml_attr(metadata_main, 'tagline'), 'rating': helpers.get_xml_attr(metadata_main, 'rating'), 'rating_image': helpers.get_xml_attr(metadata_main, 'ratingImage'), 'audience_rating': helpers.get_xml_attr(metadata_main, 'audienceRating'), 'audience_rating_image': helpers.get_xml_attr(metadata_main, 'audienceRatingImage'), 'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'), - 'duration': show_details['duration'], + 'duration': show_details.get('duration', ''), 'year': helpers.get_xml_attr(metadata_main, 'year'), 'thumb': helpers.get_xml_attr(metadata_main, 'thumb'), 'parent_thumb': helpers.get_xml_attr(metadata_main, 'parentThumb'), 'grandparent_thumb': helpers.get_xml_attr(metadata_main, 'grandparentThumb'), 'art': helpers.get_xml_attr(metadata_main, 'art'), - 'banner': show_details['banner'], + 'banner': show_details.get('banner', ''), 'originally_available_at': helpers.get_xml_attr(metadata_main, 'originallyAvailableAt'), 'added_at': helpers.get_xml_attr(metadata_main, 'addedAt'), 'updated_at': helpers.get_xml_attr(metadata_main, 'updatedAt'), @@ -813,12 +813,12 @@ class PmsConnect(object): 'guid': helpers.get_xml_attr(metadata_main, 'guid'), 'parent_guid': helpers.get_xml_attr(metadata_main, 'parentGuid'), 'grandparent_guid': helpers.get_xml_attr(metadata_main, 'grandparentGuid'), - 'directors': show_details['directors'], - 'writers': show_details['writers'], - 'actors': show_details['actors'], - 'genres': show_details['genres'], - 'labels': show_details['labels'], - 'collections': show_details['collections'], + 'directors': show_details.get('directors', []), + 'writers': show_details.get('writers', []), + 'actors': show_details.get('actors', []), + 'genres': show_details.get('genres', []), + 'labels': show_details.get('labels', []), + 'collections': show_details.get('collections', []), 'full_title': u'{} - {}'.format(helpers.get_xml_attr(metadata_main, 'parentTitle'), helpers.get_xml_attr(metadata_main, 'title')), 'children_count': helpers.get_xml_attr(metadata_main, 'leafCount') @@ -826,7 +826,7 @@ class PmsConnect(object): elif metadata_type == 'episode': grandparent_rating_key = helpers.get_xml_attr(metadata_main, 'grandparentRatingKey') - show_details = self.get_metadata_details(grandparent_rating_key) + show_details = self.get_metadata_details(grandparent_rating_key) if grandparent_rating_key else {} parent_rating_key = helpers.get_xml_attr(metadata_main, 'parentRatingKey') parent_media_index = helpers.get_xml_attr(metadata_main, 'parentIndex') @@ -838,7 +838,7 @@ class PmsConnect(object): parent_rating_key = parent_thumb.split('/')[3] # Try getting the parent_rating_key from the grandparent's children - if not parent_rating_key: + if not parent_rating_key and grandparent_rating_key: children_list = self.get_item_children(grandparent_rating_key) parent_rating_key = next((c['rating_key'] for c in children_list['children_list'] if c['media_index'] == parent_media_index), '') @@ -856,7 +856,7 @@ class PmsConnect(object): 'sort_title': helpers.get_xml_attr(metadata_main, 'titleSort'), 'media_index': helpers.get_xml_attr(metadata_main, 'index'), 'parent_media_index': parent_media_index, - 'studio': show_details['studio'], + 'studio': show_details.get('studio', ''), 'content_rating': helpers.get_xml_attr(metadata_main, 'contentRating'), 'summary': helpers.get_xml_attr(metadata_main, 'summary'), 'tagline': helpers.get_xml_attr(metadata_main, 'tagline'), @@ -871,7 +871,7 @@ class PmsConnect(object): 'parent_thumb': parent_thumb, 'grandparent_thumb': helpers.get_xml_attr(metadata_main, 'grandparentThumb'), 'art': helpers.get_xml_attr(metadata_main, 'art'), - 'banner': show_details['banner'], + 'banner': show_details.get('banner', ''), 'originally_available_at': helpers.get_xml_attr(metadata_main, 'originallyAvailableAt'), 'added_at': helpers.get_xml_attr(metadata_main, 'addedAt'), 'updated_at': helpers.get_xml_attr(metadata_main, 'updatedAt'), @@ -881,10 +881,10 @@ class PmsConnect(object): 'grandparent_guid': helpers.get_xml_attr(metadata_main, 'grandparentGuid'), 'directors': directors, 'writers': writers, - 'actors': show_details['actors'], - 'genres': show_details['genres'], - 'labels': show_details['labels'], - 'collections': show_details['collections'], + 'actors': show_details.get('actors', []), + 'genres': show_details.get('genres', []), + 'labels': show_details.get('labels', []), + 'collections': show_details.get('collections', []), 'full_title': u'{} - {}'.format(helpers.get_xml_attr(metadata_main, 'grandparentTitle'), helpers.get_xml_attr(metadata_main, 'title')), 'children_count': helpers.get_xml_attr(metadata_main, 'leafCount') @@ -939,7 +939,7 @@ class PmsConnect(object): elif metadata_type == 'album': parent_rating_key = helpers.get_xml_attr(metadata_main, 'parentRatingKey') - artist_details = self.get_metadata_details(parent_rating_key) + artist_details = self.get_metadata_details(parent_rating_key) if parent_rating_key else {} metadata = {'media_type': metadata_type, 'section_id': section_id, 'library_name': library_name, @@ -955,7 +955,7 @@ class PmsConnect(object): 'parent_media_index': helpers.get_xml_attr(metadata_main, 'parentIndex'), 'studio': helpers.get_xml_attr(metadata_main, 'studio'), 'content_rating': helpers.get_xml_attr(metadata_main, 'contentRating'), - 'summary': helpers.get_xml_attr(metadata_main, 'summary') or artist_details['summary'], + 'summary': helpers.get_xml_attr(metadata_main, 'summary') or artist_details.get('summary', ''), 'tagline': helpers.get_xml_attr(metadata_main, 'tagline'), 'rating': helpers.get_xml_attr(metadata_main, 'rating'), 'rating_image': helpers.get_xml_attr(metadata_main, 'ratingImage'), @@ -968,7 +968,7 @@ class PmsConnect(object): 'parent_thumb': helpers.get_xml_attr(metadata_main, 'parentThumb'), 'grandparent_thumb': helpers.get_xml_attr(metadata_main, 'grandparentThumb'), 'art': helpers.get_xml_attr(metadata_main, 'art'), - 'banner': artist_details['banner'], + 'banner': artist_details.get('banner', ''), 'originally_available_at': helpers.get_xml_attr(metadata_main, 'originallyAvailableAt'), 'added_at': helpers.get_xml_attr(metadata_main, 'addedAt'), 'updated_at': helpers.get_xml_attr(metadata_main, 'updatedAt'), @@ -989,7 +989,7 @@ class PmsConnect(object): elif metadata_type == 'track': parent_rating_key = helpers.get_xml_attr(metadata_main, 'parentRatingKey') - album_details = self.get_metadata_details(parent_rating_key) + album_details = self.get_metadata_details(parent_rating_key) if parent_rating_key else {} track_artist = helpers.get_xml_attr(metadata_main, 'originalTitle') or \ helpers.get_xml_attr(metadata_main, 'grandparentTitle') metadata = {'media_type': metadata_type, @@ -1015,12 +1015,12 @@ class PmsConnect(object): 'audience_rating_image': helpers.get_xml_attr(metadata_main, 'audienceRatingImage'), 'user_rating': helpers.get_xml_attr(metadata_main, 'userRating'), 'duration': helpers.get_xml_attr(metadata_main, 'duration'), - 'year': album_details['year'], + 'year': album_details.get('year', ''), 'thumb': helpers.get_xml_attr(metadata_main, 'thumb'), 'parent_thumb': helpers.get_xml_attr(metadata_main, 'parentThumb'), 'grandparent_thumb': helpers.get_xml_attr(metadata_main, 'grandparentThumb'), 'art': helpers.get_xml_attr(metadata_main, 'art'), - 'banner': album_details['banner'], + 'banner': album_details.get('banner', ''), 'originally_available_at': helpers.get_xml_attr(metadata_main, 'originallyAvailableAt'), 'added_at': helpers.get_xml_attr(metadata_main, 'addedAt'), 'updated_at': helpers.get_xml_attr(metadata_main, 'updatedAt'), @@ -1031,9 +1031,9 @@ class PmsConnect(object): 'directors': directors, 'writers': writers, 'actors': actors, - 'genres': album_details['genres'], - 'labels': album_details['labels'], - 'collections': album_details['collections'], + 'genres': album_details.get('genres', []), + 'labels': album_details.get('labels', []), + 'collections': album_details.get('collections', []), 'full_title': u'{} - {}'.format(helpers.get_xml_attr(metadata_main, 'title'), track_artist), 'children_count': helpers.get_xml_attr(metadata_main, 'leafCount') @@ -1088,7 +1088,7 @@ class PmsConnect(object): elif metadata_type == 'photo': parent_rating_key = helpers.get_xml_attr(metadata_main, 'parentRatingKey') - photo_album_details = self.get_metadata_details(parent_rating_key) + photo_album_details = self.get_metadata_details(parent_rating_key) if parent_rating_key else {} metadata = {'media_type': metadata_type, 'section_id': section_id, 'library_name': library_name, @@ -1128,9 +1128,9 @@ class PmsConnect(object): 'directors': directors, 'writers': writers, 'actors': actors, - 'genres': photo_album_details.get('genres', ''), - 'labels': photo_album_details.get('labels', ''), - 'collections': photo_album_details.get('collections', ''), + 'genres': photo_album_details.get('genres', []), + 'labels': photo_album_details.get('labels', []), + 'collections': photo_album_details.get('collections', []), 'full_title': u'{} - {}'.format(helpers.get_xml_attr(metadata_main, 'parentTitle') or library_name, helpers.get_xml_attr(metadata_main, 'title')), 'children_count': helpers.get_xml_attr(metadata_main, 'leafCount') @@ -1817,7 +1817,7 @@ class PmsConnect(object): source_media_details = source_media_part_details = \ source_video_details = source_audio_details = source_subtitle_details = {} - if stream_details['live'] or not helpers.get_xml_attr(session, 'ratingKey').isdigit(): + if not helpers.get_xml_attr(session, 'ratingKey').isdigit(): channel_stream = 1 audio_channels = helpers.get_xml_attr(stream_media_info, 'audioChannels') From ee1b0eeeff1db0c2121fd3fe725cfa791c1ca952 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Sat, 15 Feb 2020 13:29:25 -0800 Subject: [PATCH 013/114] Add Live TV metadata to activity card --- .../default/current_activity_instance.html | 35 +++++++++++++-- data/interfaces/default/index.html | 21 +++++++-- plexpy/pmsconnect.py | 45 +++++++++++-------- 3 files changed, 75 insertions(+), 26 deletions(-) diff --git a/data/interfaces/default/current_activity_instance.html b/data/interfaces/default/current_activity_instance.html index c69b295e..4e0b609a 100644 --- a/data/interfaces/default/current_activity_instance.html +++ b/data/interfaces/default/current_activity_instance.html @@ -96,7 +96,13 @@ DOCUMENTATION :: END
% endif % if data['live'] == 1: + % if data['grandparent_thumb'].startswith('http'): +
+ % elif data['grandparent_thumb']: +
+ % else:
+ % endif % elif data['channel_stream'] == 0: % if data['media_type'] == 'movie': @@ -377,7 +383,7 @@ DOCUMENTATION :: END % endif