Fix process_metadata and get_metadata
This commit is contained in:
parent
d5f4ad3e62
commit
7640f1e2d2
2 changed files with 16 additions and 14 deletions
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue