From dad390c217a1b335878bf53cc4b2f65fd71f58cb Mon Sep 17 00:00:00 2001 From: Sylvain CECCHETTO Date: Thu, 28 Dec 2023 08:16:27 +0100 Subject: [PATCH] Use xbmcvfs functions to read and write filesystem files (fix Jellyfin addon on tvOS) --- jellyfin_kodi/helper/xmls.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/jellyfin_kodi/helper/xmls.py b/jellyfin_kodi/helper/xmls.py index 0831514b5..64c93440b 100644 --- a/jellyfin_kodi/helper/xmls.py +++ b/jellyfin_kodi/helper/xmls.py @@ -117,13 +117,18 @@ def verify_kodi_defaults(): if xbmcvfs.exists(file_name): try: - tree = etree.parse(file_name) + with xbmcvfs.File(file_name) as f: + b = f.read() + tree = etree.ElementTree(etree.fromstring(b)) except etree.ParseError: LOG.error("Unable to parse `{}`".format(file_name)) LOG.exception("We ensured the file was OK above, something is wrong!") + tree = None - tree.getroot().set('order', str(17 + index)) - tree.write(file_name) + if tree is not None: + tree.getroot().set('order', str(17 + index)) + with xbmcvfs.File(file_name, 'w') as f: + f.write(etree.tostring(tree.getroot())) playlist_path = translate_path("special://profile/playlists/video")