From c748da2e00e0e7e53aea03656ba142feb8971699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 28 Apr 2024 17:06:35 +0300 Subject: [PATCH] Unregister TraktListsPlugin if no lists to update --- plextraktsync/sync/TraktListsPlugin.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plextraktsync/sync/TraktListsPlugin.py b/plextraktsync/sync/TraktListsPlugin.py index c29516cf8ef..12819fd7364 100644 --- a/plextraktsync/sync/TraktListsPlugin.py +++ b/plextraktsync/sync/TraktListsPlugin.py @@ -7,7 +7,8 @@ from plextraktsync.plugin import hookimpl if TYPE_CHECKING: - from .plugin.SyncPluginInterface import Media, TraktUserListCollection + from .plugin.SyncPluginInterface import (Media, SyncPluginManager, + TraktUserListCollection) class TraktListsPlugin: @@ -22,7 +23,7 @@ def __init__(self): @staticmethod def enabled(config): - # Use True for now, would need to keep in sync with other plugins + # Check for need is performed in init() return True @classmethod @@ -30,10 +31,13 @@ def factory(cls, sync): return cls() @hookimpl(trylast=True) - def init(self, trakt_lists: TraktUserListCollection): + def init(self, pm: SyncPluginManager, trakt_lists: TraktUserListCollection): self.trakt_lists = trakt_lists - # Skip updating lists if it's empty self.add_to_lists = not trakt_lists.is_empty + # Skip updating lists if it's empty + if trakt_lists.is_empty: + self.logger.warning("Disabling TraktListsPlugin: No lists to process") + pm.unregister(self) @hookimpl def fini(self, dry_run: bool):