Skip to content

Commit

Permalink
Fix for Python2 ElementTree.fromstring not supporting unicode in inpu…
Browse files Browse the repository at this point in the history
…t string

- Fix #636
  • Loading branch information
MoojMidge committed Mar 17, 2024
1 parent a23d53e commit 56c106f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions resources/lib/youtube_plugin/youtube/client/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 56c106f

Please sign in to comment.