diff --git a/resources/lib/library_sync/get_metadata.py b/resources/lib/library_sync/get_metadata.py index c7927482..5d421d4d 100644 --- a/resources/lib/library_sync/get_metadata.py +++ b/resources/lib/library_sync/get_metadata.py @@ -33,18 +33,20 @@ class GetMetadataTask(backgroundthread.Task, common.libsync_mixin): if self.isCanceled(): return # Download Metadata - xml = PF.GetPlexMetadata(self.plex_id) - if xml is None: + item = { + 'xml': PF.GetPlexMetadata(self.plex_id), + 'children': None + } + if item['xml'] is None: # Did not receive a valid XML - skip that item for now LOG.error("Could not get metadata for %s. Skipping that item " "for now", self.plex_id) return - elif xml == 401: + elif item['xml'] == 401: LOG.error('HTTP 401 returned by PMS. Too much strain? ' 'Cancelling sync for now') utils.window('plex_scancrashed', value='401') return - xml.children = None if not self.isCanceled() and self.get_children: children_xml = PF.GetAllPlexChildren(self.plex_id) try: @@ -53,5 +55,5 @@ class GetMetadataTask(backgroundthread.Task, common.libsync_mixin): LOG.error('Could not get children for Plex id %s', self.plex_id) else: - xml.children = children_xml - self.queue.put(xml) + item['children'] = children_xml + self.queue.put(item) diff --git a/resources/lib/library_sync/process_metadata.py b/resources/lib/library_sync/process_metadata.py index cbe286e0..60259be5 100644 --- a/resources/lib/library_sync/process_metadata.py +++ b/resources/lib/library_sync/process_metadata.py @@ -88,23 +88,23 @@ class ProcessMetadata(backgroundthread.KillableThread, common.libsync_mixin): with section.context(self.last_sync) as context: while self.isCanceled() is False: # grabs item from queue. This will block! - xml = self.queue.get() - if xml is InitNewSection or xml is None: - section = xml + item = self.queue.get() + if item is InitNewSection or item is None: + section = item self.queue.task_done() break try: - context.add_update(xml[0], - viewtag=section.name, - viewid=section.id, - children=xml.children) + context.add_update(item['xml'][0], + section_name=section.name, + section_id=section.id, + children=item['children']) except: utils.ERROR(txt='process_metadata crashed', notify=True, cancel_sync=True) if self.current % 20 == 0: self.title = utils.cast(unicode, - xml[0].get('title')) + item['xml'][0].get('title')) self.update() self.current += 1 self.queue.task_done()