From 545e71f4532849ffa9212ac27c08c4831c7473d6 Mon Sep 17 00:00:00 2001 From: MoojMidge <56883549+MoojMidge@users.noreply.github.com> Date: Mon, 7 Oct 2024 23:48:01 +1100 Subject: [PATCH] Only attempt to import InputStream Helper if necessary #923 --- .../youtube_plugin/youtube/helper/utils.py | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/resources/lib/youtube_plugin/youtube/helper/utils.py b/resources/lib/youtube_plugin/youtube/helper/utils.py index 678ab3698..d44ff78a2 100644 --- a/resources/lib/youtube_plugin/youtube/helper/utils.py +++ b/resources/lib/youtube_plugin/youtube/helper/utils.py @@ -23,11 +23,6 @@ ) -try: - from inputstreamhelper import Helper as ISHelper -except ImportError: - ISHelper = None - __RE_PLAYLIST = re.compile( r'^(/channel/(?P[^/]+))/playlist/(?P[^/]+)/?$' ) @@ -866,17 +861,23 @@ def update_play_info(provider, context, video_id, media_item, video_stream): if use_isa: license_info = video_stream.get('license_info', {}) - license_proxy = license_info.get('proxy', '') - license_url = license_info.get('url', '') - license_token = license_info.get('token', '') + license_proxy = license_info.get('proxy') + license_url = license_info.get('url') + license_token = license_info.get('token') + + if license_proxy and license_url and license_token: + try: + from inputstreamhelper import Helper - if ISHelper and license_proxy and license_url and license_token: - ISHelper('mpd' if media_item.use_mpd() else 'hls', - drm='com.widevine.alpha').check_inputstream() + is_helper = Helper('mpd' if media_item.use_mpd() else 'hls', + drm='com.widevine.alpha') + except ImportError: + is_helper = None - media_item.set_license_key(license_proxy) - ui.set_property(LICENSE_URL, license_url) - ui.set_property(LICENSE_TOKEN, license_token) + if is_helper and is_helper.check_inputstream(): + media_item.set_license_key(license_proxy) + ui.set_property(LICENSE_URL, license_url) + ui.set_property(LICENSE_TOKEN, license_token) def update_fanarts(provider, context, channel_items_dict, data=None):