diff --git a/resources/lib/library_sync/full_sync.py b/resources/lib/library_sync/full_sync.py index 5f2dc49c..1a461bae 100644 --- a/resources/lib/library_sync/full_sync.py +++ b/resources/lib/library_sync/full_sync.py @@ -81,7 +81,7 @@ class FullSync(backgroundthread.KillableThread, common.libsync_mixin): if self.plexdb.is_recorded(plex_id, self.plex_type): return else: - if self.plexdb.check_checksum( + if self.plexdb.plex_id_by_checksum( int('%s%s' % (plex_id, xml_item.get('updatedAt')))): self.plexdb.update_last_sync(plex_id, self.last_sync) diff --git a/resources/lib/plex_db/common.py b/resources/lib/plex_db/common.py index 0fbcc426..263c25d9 100644 --- a/resources/lib/plex_db/common.py +++ b/resources/lib/plex_db/common.py @@ -94,6 +94,17 @@ class PlexDBBase(object): self.cursor.execute(query, (last_sync, )) return (x[0] for x in self.cursor) + def plex_id_by_checksum(self, checksum, plex_type): + """ + Returns the plex_id for the (unique) checksum or None + """ + query = 'SELECT plex_id FROM %s WHERE checksum = ?' % plex_type + self.cursor.execute(query, (checksum, )) + try: + return self.cursor.fetchone()[0] + except TypeError: + pass + def update_last_sync(self, plex_type, plex_id, last_sync): """ Sets a new timestamp for plex_id