Fix many items not getting synced

This commit is contained in:
croneter 2018-12-21 15:18:06 +01:00
parent 9682d7a313
commit 5d6b8f1273
2 changed files with 13 additions and 5 deletions

View file

@ -187,7 +187,8 @@ class FullSync(common.libsync_mixin):
# Tell the processing thread about this new section # Tell the processing thread about this new section
queue_info = InitNewSection(section['context'], queue_info = InitNewSection(section['context'],
iterator.total, iterator.total,
iterator.get('librarySectionTitle'), iterator.get('librarySectionTitle',
iterator.get('title1')),
section['section_id'], section['section_id'],
section['plex_type']) section['plex_type'])
self.queue.put(queue_info) self.queue.put(queue_info)

View file

@ -522,10 +522,11 @@ class DownloadChunk(backgroundthread.Task):
""" """
This task will also be executed while library sync is suspended! This task will also be executed while library sync is suspended!
""" """
def setup(self, url, args, callback): def __init__(self, url, args, callback):
self.url = url self.url = url
self.args = args self.args = args
self.callback = callback self.callback = callback
super(DownloadChunk, self).__init__()
def run(self): def run(self):
xml = DU().downloadUrl(self.url, parameters=self.args) xml = DU().downloadUrl(self.url, parameters=self.args)
@ -587,8 +588,9 @@ class DownloadGen(object):
raise RuntimeError('Error while downloading chunks for %s' raise RuntimeError('Error while downloading chunks for %s'
% self.url) % self.url)
else: else:
task = DownloadChunk() task = DownloadChunk(self.url,
task.setup(self.url, self.args, self.on_chunk_downloaded) deepcopy(self.args), # Beware!
self.on_chunk_downloaded)
backgroundthread.BGThreader.addTask(task) backgroundthread.BGThreader.addTask(task)
def on_chunk_downloaded(self, xml): def on_chunk_downloaded(self, xml):
@ -630,7 +632,12 @@ class SectionItems(DownloadGen):
""" """
def __init__(self, section_id, plex_type=None, last_viewed_at=None, def __init__(self, section_id, plex_type=None, last_viewed_at=None,
updated_at=None, args=None): updated_at=None, args=None):
url = '{server}/library/sections/%s/all' % section_id if plex_type == v.PLEX_TYPE_EPISODE:
# Annoying Plex bug. You won't get all episodes otherwise
url = '{server}/library/sections/%s/allLeaves' % section_id
plex_type = None
else:
url = '{server}/library/sections/%s/all' % section_id
super(SectionItems, self).__init__(url, plex_type, last_viewed_at, super(SectionItems, self).__init__(url, plex_type, last_viewed_at,
updated_at, args) updated_at, args)