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