From 56c106f8dc796ee2770c39feeb220afd9b8eacef Mon Sep 17 00:00:00 2001 From: MoojMidge <56883549+MoojMidge@users.noreply.github.com> Date: Sun, 17 Mar 2024 14:52:44 +1100 Subject: [PATCH] Fix for Python2 ElementTree.fromstring not supporting unicode in input string - Fix #636 --- .../lib/youtube_plugin/youtube/client/youtube.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/resources/lib/youtube_plugin/youtube/client/youtube.py b/resources/lib/youtube_plugin/youtube/client/youtube.py index f019d75ad..7dcc40471 100644 --- a/resources/lib/youtube_plugin/youtube/client/youtube.py +++ b/resources/lib/youtube_plugin/youtube/client/youtube.py @@ -21,7 +21,12 @@ from ..helper.video_info import VideoInfo from ..youtube_exceptions import InvalidJSON, YouTubeException from ...kodion.compatibility import string_type -from ...kodion.utils import datetime_parser, strip_html_from_text, to_unicode +from ...kodion.utils import ( + current_system_version, + datetime_parser, + strip_html_from_text, + to_unicode, +) class YouTube(LoginClient): @@ -1531,7 +1536,10 @@ def fetch_xml(_url, _responses): for response in responses: if response: response.encoding = 'utf-8' - xml_data = to_unicode(response.content).replace('\n', '') + xml_data = to_unicode(response.content) + if not current_system_version.compatible(19, 0): + xml_data = xml_data.encode('utf-8') + xml_data = xml_data.replace('\n', '') root = ET.fromstring(xml_data)