diff --git a/plextraktsync/cli.py b/plextraktsync/cli.py index e8a5372237..e6ebb44c1b 100644 --- a/plextraktsync/cli.py +++ b/plextraktsync/cli.py @@ -23,13 +23,7 @@ def wrap(*args, **kwargs): name = fn.__name__ module = importlib.import_module(f".commands.{name}", package=__package__) cmd = getattr(module, name) - - try: - cmd(*args, **kwargs) - except RuntimeError as e: - from click import ClickException - - raise ClickException(f"Error running {name} command: {str(e)}") + cmd(*args, **kwargs) return wrap diff --git a/plextraktsync/factory.py b/plextraktsync/factory.py index dfaa669e11..97381baaf9 100644 --- a/plextraktsync/factory.py +++ b/plextraktsync/factory.py @@ -7,6 +7,8 @@ class Factory: def trakt_api(self): from plextraktsync.trakt_api import TraktApi + self.monkey_patch_trakt() + config = self.run_config() trakt = TraktApi(batch_delay=config.batch_delay) @@ -159,6 +161,25 @@ def config(self): return Config() + @staticmethod + def monkey_patch_trakt(): + from collections import namedtuple + + import trakt.users + + # Add `type` to UserList named tuple: + # - https://github.com/moogar0880/PyTrakt/pull/206 + # Monkey patch the class: + # - https://stackoverflow.com/a/28500620/2314626 + # - https://stackoverflow.com/a/62160225/2314626 + UserListOriginal = trakt.users.UserList + UserListTuple = namedtuple('UserList', UserListOriginal._fields + ('type',)) + + class UserList(UserListTuple, UserListOriginal): + pass + + trakt.users.UserList = UserList + factory = Factory() logger = factory.logger