diff --git a/resources/lib/initialsetup.py b/resources/lib/initialsetup.py index 5d9eba95..54bd9940 100644 --- a/resources/lib/initialsetup.py +++ b/resources/lib/initialsetup.py @@ -401,9 +401,8 @@ class InitialSetup(): dialog = self.dialog # Get current Kodi video cache setting - try: - cache, _ = advancedsettings_xml(['cache', 'memorysize']) - except TypeError: + cache, _ = advancedsettings_xml(['cache', 'memorysize']) + if cache is None: # Kodi default cache cache = '20971520' else: diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index 75c4217b..d0e50cda 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -297,15 +297,6 @@ class LibrarySync(Thread): } if self.enableMusic: process['music'] = self.PlexMusic - if self.direct_paths is True: - if music.set_excludefromscan_music_folders() is True: - log.info('Detected new Music library - restarting now') - # 'New Plex music library detected. Sorry, but we need to - # restart Kodi now due to the changes made.' - dialog('ok', lang(29999), lang(39711)) - from xbmc import executebuiltin - executebuiltin('RestartApp') - return False # Do the processing for itemtype in process: @@ -483,6 +474,16 @@ class LibrarySync(Thread): """ Compare the views to Plex """ + if self.direct_paths is True: + if music.set_excludefromscan_music_folders() is True: + log.info('Detected new Music library - restarting now') + # 'New Plex music library detected. Sorry, but we need to + # restart Kodi now due to the changes made.' + dialog('ok', lang(29999), lang(39711)) + from xbmc import executebuiltin + executebuiltin('RestartApp') + return False + self.views = [] vnodes = self.vnodes diff --git a/resources/lib/music.py b/resources/lib/music.py index 3e967bbd..9ed2cb7b 100644 --- a/resources/lib/music.py +++ b/resources/lib/music.py @@ -21,9 +21,8 @@ def get_current_music_folders(): excludefromscan music folders in the advancedsettings.xml """ paths = [] - try: - root, _ = advancedsettings_xml(['audio', 'excludefromscan']) - except TypeError: + root, _ = advancedsettings_xml(['audio', 'excludefromscan']) + if root is None: return paths for element in root: diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 752801cf..f53759d3 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -542,8 +542,10 @@ def __setSubElement(element, subelement): def advancedsettings_xml(node_list, new_value=None, attrib=None, force_create=False): """ - Returns the etree element for nodelist (if it exists) and the tree. None if - not set + Returns + etree element, tree + or + None, None node_list is a list of node names starting from the outside, ignoring the outter advancedsettings. Example nodelist=['video', 'busydialogdelayms'] @@ -576,7 +578,7 @@ def advancedsettings_xml(node_list, new_value=None, attrib=None, # Document is blank or missing if new_value is None and attrib is None and force_create is False: log.debug('Could not parse advancedsettings.xml, returning None') - return + return None, None # Create topmost xml entry tree = etree.ElementTree(element=etree.Element('advancedsettings')) root = tree.getroot()