Skip to content

Commit

Permalink
Update optional logic
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Jul 8, 2024
1 parent fe2b2a9 commit 2363579
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions plextraktsync/db/SyncDatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 2363579

Please sign in to comment.