diff --git a/plextraktsync/sync.py b/plextraktsync/sync.py index 4a80e8a99f..d49b9792ff 100644 --- a/plextraktsync/sync.py +++ b/plextraktsync/sync.py @@ -126,20 +126,28 @@ def trakt_wl_shows(self) -> Dict[int, TVShow]: def sync(self, walker: Walker, dry_run=False): listutil = TraktListUtil() + is_partial = walker.is_partial if self.config.update_plex_wl_as_pl: - listutil.addList(None, "Trakt Watchlist", trakt_list=self.trakt.watchlist_movies) + if is_partial: + logger.warning("Running partial library sync. Watchlist as playlist won't update because it needs full library sync.") + else: + listutil.addList(None, "Trakt Watchlist", trakt_list=self.trakt.watchlist_movies) if self.config.sync_liked_lists: - for lst in self.trakt.liked_lists: - listutil.addList(lst["listid"], lst["listname"]) + if is_partial: + logger.warning("Partial walk, disabling liked lists updating. Liked lists won't update because it needs full library sync.") + else: + for lst in self.trakt.liked_lists: + listutil.addList(lst["listid"], lst["listname"]) if self.config.need_library_walk: for movie in walker.find_movies(): self.sync_collection(movie, dry_run=dry_run) self.sync_ratings(movie, dry_run=dry_run) self.sync_watched(movie, dry_run=dry_run) - listutil.addPlexItemToLists(movie) + if not is_partial: + listutil.addPlexItemToLists(movie) self.trakt.flush() shows = set() @@ -147,7 +155,8 @@ def sync(self, walker: Walker, dry_run=False): self.sync_collection(episode, dry_run=dry_run) self.sync_ratings(episode, dry_run=dry_run) self.sync_watched(episode, dry_run=dry_run) - listutil.addPlexItemToLists(episode) + if not is_partial: + listutil.addPlexItemToLists(episode) if self.config.sync_ratings: # collect shows for later ratings sync shows.add(episode.show) @@ -157,11 +166,14 @@ def sync(self, walker: Walker, dry_run=False): self.sync_ratings(show, dry_run=dry_run) if self.sync_wl or self.config.sync_liked_lists: - with measure_time("Updated watchlist and/or liked list"): - if self.config.update_plex_wl_as_pl or self.config.sync_liked_lists: - self.update_playlists(listutil, dry_run=dry_run) - if self.sync_wl: - self.sync_watchlist(walker, dry_run=dry_run) + if is_partial: + logger.warning("Partial walk, watchlist and/or liked list updating was skipped") + else: + with measure_time("Updated watchlist and/or liked list"): + if self.config.update_plex_wl_as_pl or self.config.sync_liked_lists: + self.update_playlists(listutil, dry_run=dry_run) + if self.sync_wl: + self.sync_watchlist(walker, dry_run=dry_run) if not dry_run: self.trakt.flush() diff --git a/plextraktsync/walker.py b/plextraktsync/walker.py index 7398cef83b..5cc28522b3 100644 --- a/plextraktsync/walker.py +++ b/plextraktsync/walker.py @@ -43,6 +43,19 @@ def add_show(self, show): def add_movie(self, movie): self.movie.append(movie) + @property + def is_partial(self): + """ + Returns true if partial library walk is performed. + Due the way watchlist is filled, watchlists should only be updated on full walk. + """ + # Single item provided + if self.library or self.movie or self.show or self.id: + return True + + # Must sync both movies and shows to be full sync + return not self.walk_movies or not self.walk_shows + def is_valid(self): # Single item provided if self.library or self.movie or self.show or self.id: @@ -212,6 +225,10 @@ def __init__( def plan(self): return WalkPlanner(self.plex, self.config).plan() + @property + def is_partial(self): + return self.config.is_partial + def print_plan(self, print=print): if self.plan.movie_sections: print(f"Sync Movie sections: {self.plan.movie_sections}")