Add missing method

This commit is contained in:
croneter 2018-10-28 17:02:06 +01:00
parent 01fc08b027
commit 3d77bd64d1
2 changed files with 12 additions and 1 deletions

View file

@ -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)

View file

@ -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