Skip to content

Commit

Permalink
Merge pull request #1927 from glensc/lists-plugin-load
Browse files Browse the repository at this point in the history
Refactor: Enable TraktListsPlugin only if two other plugins need it
  • Loading branch information
glensc authored Apr 30, 2024
2 parents 9e77979 + 2a19119 commit 3201c2b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
7 changes: 7 additions & 0 deletions plextraktsync/config/SyncConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ def sync_wl(self):
def sync_liked_lists(self):
return self.trakt_to_plex["liked_lists"]

@cached_property
def sync_watchlists(self):
return any([
self.plex_to_trakt["watchlist"],
self.trakt_to_plex["watchlist"],
])

@cached_property
def need_library_walk(self):
return any([
Expand Down
8 changes: 6 additions & 2 deletions plextraktsync/sync/TraktListsPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ def __init__(self):

@staticmethod
def enabled(config):
# Check for need is performed in init()
return True
return any([
# LikedListsPlugin
config.sync_liked_lists,
# WatchListPlugin
config.sync_watchlists,
])

@classmethod
def factory(cls, sync):
Expand Down
5 changes: 1 addition & 4 deletions plextraktsync/sync/WatchListPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ def __init__(self, config: SyncConfig, plex: PlexApi, trakt: TraktApi):

@staticmethod
def enabled(config: SyncConfig):
return any([
config.plex_to_trakt["watchlist"],
config.trakt_to_plex["watchlist"],
])
return config.sync_watchlists

@classmethod
def factory(cls, sync: Sync):
Expand Down

0 comments on commit 3201c2b

Please sign in to comment.