From 23635792c2f9c97bc5fb7e84fa0ad52e116543c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Mon, 8 Jul 2024 14:47:39 +0300 Subject: [PATCH] Update optional logic --- plextraktsync/db/SyncDatabase.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/plextraktsync/db/SyncDatabase.py b/plextraktsync/db/SyncDatabase.py index 44ae89ccd9..ccf35fa84f 100644 --- a/plextraktsync/db/SyncDatabase.py +++ b/plextraktsync/db/SyncDatabase.py @@ -30,20 +30,23 @@ def insert(self, record: SyncRecord): def update(self, m: Media): record = self.find_by_id(m.type, m.trakt_id) - if record: - record.plex_timestamp_watched = m.watched_on_plex - record.seen_on_plex_sync = m.watched_on_plex - record.trakt_timestamp_watched = m.watched_on_trakt - record.seen_on_trakt_sync = m.watched_on_trakt - else: + if not record: record = SyncRecord( media_type=m.type, trakt_id=m.trakt_id, - plex_timestamp_watched=m.watched_on_plex, + # plex_timestamp_watched=m.watched_on_plex, seen_on_plex_sync=m.watched_on_plex, - trakt_timestamp_watched=m.watched_on_trakt, + # trakt_timestamp_watched=m.watched_on_trakt, seen_on_trakt_sync=m.watched_on_trakt, ) + # if record.plex_timestamp_watched != m.watched_on_plex: + # record.plex_timestamp_watched = m.watched_on_plex + if record.seen_on_plex_sync != m.watched_on_plex: + record.seen_on_plex_sync = m.watched_on_plex + # if record.trakt_timestamp_watched != m.watched_on_trakt: + # record.trakt_timestamp_watched = m.watched_on_trakt + if record.seen_on_trakt_sync != m.watched_on_trakt: + record.seen_on_trakt_sync = m.watched_on_trakt with Session(self.engine) as session: session.add(record) session.commit()