Skip to content

Commit

Permalink
Undo keep_watched check in the plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed May 1, 2024
1 parent d0ce161 commit d7bc315
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions plextraktsync/sync/TraktListsPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from plextraktsync.plugin import hookimpl

if TYPE_CHECKING:
from ..trakt.TraktUserList import TraktUserList
from .plugin.SyncPluginInterface import Media, Sync, SyncPluginManager


Expand All @@ -17,10 +16,9 @@ class TraktListsPlugin:
"""
logger = logging.getLogger(__name__)

def __init__(self, keep_watched: bool, trakt_lists_config=None):
def __init__(self, keep_watched: bool):
self.keep_watched = keep_watched
self.trakt_lists = None
self.trakt_lists_config = trakt_lists_config or {}

@staticmethod
def enabled(config):
Expand All @@ -35,7 +33,6 @@ def enabled(config):
def factory(cls, sync: Sync):
return cls(
sync.config.liked_lists_keep_watched,
sync.config.liked_lists_overrides,
)

@hookimpl(trylast=True)
Expand All @@ -55,29 +52,17 @@ async def fini(self, dry_run: bool):

with measure_time("Updated Trakt Lists"):
for tl in self.trakt_lists:
items = tl.plex_items_sorted(self.list_keep_watched(tl))
items = tl.plex_items_sorted()
updated = tl.plex_list.update(items)
if not updated:
continue
self.logger.info(f"Plex list {tl.title_link} ({len(tl.plex_items)} items) updated",
extra={"markup": True})

def list_keep_watched(self, tl: TraktUserList):
config = self.trakt_lists_config.get(tl.name)
if config is None:
return self.keep_watched
return config.get("keep_watched", self.keep_watched)

@hookimpl
async def walk_movie(self, movie: Media):
if not self.keep_watched and movie.plex.is_watched:
return

self.trakt_lists.add_to_lists(movie)

@hookimpl
async def walk_episode(self, episode: Media):
if not self.keep_watched and episode.plex.is_watched:
return

self.trakt_lists.add_to_lists(episode)

0 comments on commit d7bc315

Please sign in to comment.