From 8860edd59272bfe9385f50526e80f74a28f0866c Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Mon, 29 May 2017 15:39:11 +0200 Subject: [PATCH] Fix library sync crash due to UnicodeDecodeError - Fixes #302 --- resources/lib/music.py | 3 +-- resources/lib/utils.py | 13 +++++++------ resources/lib/videonodes.py | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/resources/lib/music.py b/resources/lib/music.py index 9ed2cb7b..ab229f0e 100644 --- a/resources/lib/music.py +++ b/resources/lib/music.py @@ -65,7 +65,6 @@ def set_excludefromscan_music_folders(): path = api.validatePlayurl(location.attrib['path'], typus=v.PLEX_TYPE_ARTIST, omitCheck=True) - path = tryEncode(path) paths.append(__turn_to_regex(path)) # Get existing advancedsettings root, tree = advancedsettings_xml(['audio', 'excludefromscan'], @@ -98,7 +97,7 @@ def set_excludefromscan_music_folders(): if write_xml is True: indent(tree.getroot()) - tree.write('%sadvancedsettings.xml' % v.KODI_PROFILE) + tree.write('%sadvancedsettings.xml' % v.KODI_PROFILE, encoding="UTF-8") return changed diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 0a64942b..322ff9c2 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -557,8 +557,8 @@ def __setXMLTag(element, tag, value, attrib=None): If "subelement" does not exist, create it using attrib and value. element : etree element - tag : string/unicode for subelement - value : string/unicode + tag : unicode for subelement + value : unicode attrib : dict; will use etree attrib method Returns the subelement @@ -657,7 +657,7 @@ def advancedsettings_xml(node_list, new_value=None, attrib=None, # Indent and make readable indent(root) # Safe the changed xml - tree.write(path) + tree.write(path, encoding="UTF-8") return element, tree @@ -705,7 +705,7 @@ def sourcesXML(): try: indent(root) except: pass - etree.ElementTree(root).write(xmlpath) + etree.ElementTree(root).write(xmlpath, encoding="UTF-8") def passwordsXML(): @@ -749,7 +749,8 @@ def passwordsXML(): paths.remove(path) log.info("Successfully removed credentials for: %s" % credentials) - etree.ElementTree(root).write(xmlpath) + etree.ElementTree(root).write(xmlpath, + encoding="UTF-8") break else: log.error("Failed to find saved server: %s in passwords.xml" @@ -817,7 +818,7 @@ def passwordsXML(): indent(root) except: pass - etree.ElementTree(root).write(xmlpath) + etree.ElementTree(root).write(xmlpath, encoding="UTF-8") # dialog.notification( # heading="PlexKodiConnect", diff --git a/resources/lib/videonodes.py b/resources/lib/videonodes.py index 12aed035..9f526175 100644 --- a/resources/lib/videonodes.py +++ b/resources/lib/videonodes.py @@ -120,7 +120,7 @@ class VideoNodes(object): indent(root) except: pass - etree.ElementTree(root).write(nodeXML) + etree.ElementTree(root).write(nodeXML, encoding="UTF-8") nodetypes = { '1': "all", @@ -375,7 +375,7 @@ class VideoNodes(object): indent(root) except: pass - etree.ElementTree(root).write(nodeXML) + etree.ElementTree(root).write(nodeXML, encoding="UTF-8") def singleNode(self, indexnumber, tagname, mediatype, itemtype): tagname = tryEncode(tagname) @@ -431,7 +431,7 @@ class VideoNodes(object): indent(root) except: pass - etree.ElementTree(root).write(nodeXML) + etree.ElementTree(root).write(nodeXML, encoding="UTF-8") def clearProperties(self):