Fix backgroundsync KeyError

This commit is contained in:
tomkat83 2016-09-17 19:12:32 +02:00
parent ee4f1517d5
commit 9c74fd4a98

View file

@ -1399,11 +1399,9 @@ class LibrarySync(Thread):
if item['state'] == 9: if item['state'] == 9:
successful = self.process_deleteditems(item) successful = self.process_deleteditems(item)
else: else:
successful = self.process_newitems(item) successful, item = self.process_newitems(item)
if successful is True: if successful and settings('FanartTV') == 'true':
deleteListe.append(i) if item['mediatype'] in ('movie', 'show'):
if (settings('FanartTV') == 'true' and
item['mediatype'] in ('movie')):
mediaType = {'movie': 'Movie'}[item['mediatype']] mediaType = {'movie': 'Movie'}[item['mediatype']]
cls = {'movie': 'Movies'}[item['mediatype']] cls = {'movie': 'Movies'}[item['mediatype']]
self.fanartqueue.put({ self.fanartqueue.put({
@ -1412,6 +1410,8 @@ class LibrarySync(Thread):
'mediaType': mediaType, 'mediaType': mediaType,
'refresh': False 'refresh': False
}) })
if successful is True:
deleteListe.append(i)
else: else:
# Safety net if we can't process an item # Safety net if we can't process an item
item['attempt'] += 1 item['attempt'] += 1
@ -1437,7 +1437,7 @@ class LibrarySync(Thread):
xml = PF.GetPlexMetadata(ratingKey) xml = PF.GetPlexMetadata(ratingKey)
if xml in (None, 401): if xml in (None, 401):
log.error('Could not download data for %s, skipping' % ratingKey) log.error('Could not download data for %s, skipping' % ratingKey)
return False return False, item
log.debug("Processing new/updated PMS item: %s" % ratingKey) log.debug("Processing new/updated PMS item: %s" % ratingKey)
viewtag = xml.attrib.get('librarySectionTitle') viewtag = xml.attrib.get('librarySectionTitle')
viewid = xml.attrib.get('librarySectionID') viewid = xml.attrib.get('librarySectionID')
@ -1462,7 +1462,7 @@ class LibrarySync(Thread):
music.add_updateSong(xml[0], music.add_updateSong(xml[0],
viewtag=viewtag, viewtag=viewtag,
viewid=viewid) viewid=viewid)
return True return True, item
def process_deleteditems(self, item): def process_deleteditems(self, item):
if item.get('type') == 1: if item.get('type') == 1: