don't mark ep as watched if plex date < show reset date
MODIFY
plextraktsync/media.py
plextraktsync/media.py
@@ -75,6 +75,11 @@ def show_trakt_id(self):
raise RuntimeError("Unexpected call: episode without show property")
return self.show.trakt_id
+ @property
+ def show_reset_at(self):
+ watched = self.trakt_api.watched_shows
+ return watched.reset_at(self.show_trakt_id)
+
@cached_property
def is_movie(self):
return self.plex.type == "movie"
@@ -148,10 +153,16 @@ def watched_on_trakt(self):
self.show_trakt_id, self.season_number, self.episode_number
)
- def mark_watched_trakt(self):
+ def mark_watched_trakt(self, dry_run):
if self.is_movie:
+ if not dry_run:
+ logger.info(f"Marking as watched in Trakt: {self}")
self.trakt_api.mark_watched(self.trakt, self.plex.seen_date)
elif self.is_episode:
+ if self.show_reset_at and self.plex.seen_date < self.show_reset_at:
+ return
+ if not dry_run:
+ logger.info(f"Marking as watched in Trakt: {self}")
self.trakt_api.mark_watched(
self.trakt, self.plex.seen_date, self.show_trakt_id
)

MODIFY
plextraktsync/pytrakt_extensions.py
plextraktsync/pytrakt_extensions.py
@@ -124,6 +124,12 @@ def is_collected(self, trakt_id, season, episode):
return False
return episode in self.shows[trakt_id].seasons[season].episodes.keys()
+ def reset_at(self, trakt_id):
+ if trakt_id not in self.shows.keys():
+ return False
+ else:
+ return airs_date(self.shows[trakt_id].reset_at)
+
def add(self, trakt_id, season, episode):
episode_prog = {"number": episode, "completed": True}
season_prog = {"number": season, "episodes": [episode_prog]}

MODIFY
plextraktsync/sync.py
plextraktsync/sync.py
@@ -157,9 +157,7 @@ def sync_watched(self, m: Media, dry_run=False):
if m.watched_on_plex:
if not self.config.plex_to_trakt["watched_status"]:
return
- logger.info(f"Marking as watched in Trakt: {m}")
- if not dry_run:
- m.mark_watched_trakt()
+ m.mark_watched_trakt(dry_run)
elif m.watched_on_trakt:
if not self.config.trakt_to_plex["watched_status"]:
return

don't mark ep as watched if plex date < show reset date