Fix AttributeError

This commit is contained in:
croneter 2018-10-28 16:14:37 +01:00
parent 8f86fc1038
commit 17a7d306ae

View file

@ -34,7 +34,7 @@ class FullSync(backgroundthread.KillableThread, common.libsync_mixin):
self.queue = None self.queue = None
self.process_thread = None self.process_thread = None
self.last_sync = None self.last_sync = None
self.plex_db = None self.plexdb = None
self.plex_type = None self.plex_type = None
self.processing_thread = None self.processing_thread = None
self.install_sync_done = utils.settings('SyncInstallRunDone') == 'true' self.install_sync_done = utils.settings('SyncInstallRunDone') == 'true'
@ -78,13 +78,13 @@ class FullSync(backgroundthread.KillableThread, common.libsync_mixin):
""" """
plex_id = int(xml_item.get('ratingKey')) plex_id = int(xml_item.get('ratingKey'))
if self.new_items_only: if self.new_items_only:
if self.plex_db.is_recorded(plex_id, self.plex_type): if self.plexdb.is_recorded(plex_id, self.plex_type):
return return
else: else:
if self.plex_db.check_checksum( if self.plexdb.check_checksum(
int('%s%s' % (plex_id, int('%s%s' % (plex_id,
xml_item.get('updatedAt')))): xml_item.get('updatedAt')))):
self.plex_db.update_last_sync(plex_id, self.last_sync) self.plexdb.update_last_sync(plex_id, self.last_sync)
return return
task = GetMetadataTask() task = GetMetadataTask()
task.setup(self.queue, plex_id, self.get_children) task.setup(self.queue, plex_id, self.get_children)
@ -96,7 +96,7 @@ class FullSync(backgroundthread.KillableThread, common.libsync_mixin):
is different is different
""" """
with self.context(self.last_sync) as c: with self.context(self.last_sync) as c:
for plex_id in self.plex_db.plex_id_by_last_sync(self.plex_type, for plex_id in self.plexdb.plex_id_by_last_sync(self.plex_type,
self.last_sync): self.last_sync):
if self.isCanceled(): if self.isCanceled():
return return
@ -126,6 +126,7 @@ class FullSync(backgroundthread.KillableThread, common.libsync_mixin):
section['section_id'], section['section_id'],
section['plex_type']) section['plex_type'])
self.queue.put(queue_info) self.queue.put(queue_info)
with PlexDB() as self.plexdb:
for xml_item in iterator: for xml_item in iterator:
if self.isCanceled(): if self.isCanceled():
return False return False
@ -152,13 +153,13 @@ class FullSync(backgroundthread.KillableThread, common.libsync_mixin):
(v.PLEX_TYPE_ARTIST, itemtypes.Artist, False), (v.PLEX_TYPE_ARTIST, itemtypes.Artist, False),
(v.PLEX_TYPE_ALBUM, itemtypes.Album, True), (v.PLEX_TYPE_ALBUM, itemtypes.Album, True),
(v.PLEX_TYPE_SONG, itemtypes.Song, False)]) (v.PLEX_TYPE_SONG, itemtypes.Song, False)])
with PlexDB() as self.plexdb:
for kind in kinds: for kind in kinds:
# Setup our variables # Setup our variables
self.plex_type = kind[0] self.plex_type = kind[0]
self.context = kind[1] self.context = kind[1]
self.get_children = kind[2] self.get_children = kind[2]
# Now do the heavy lifting # Now do the heavy lifting
with PlexDB() as self.plex_db:
if self.isCanceled() or not self.process_kind(): if self.isCanceled() or not self.process_kind():
return False return False
if self.new_items_only: if self.new_items_only: