diff --git a/tiddl/cli/__init__.py b/tiddl/cli/__init__.py index 5a636a8..fc7750c 100644 --- a/tiddl/cli/__init__.py +++ b/tiddl/cli/__init__.py @@ -22,7 +22,7 @@ from .auth import refresh ) def cli(ctx: Context, verbose: bool, quiet: bool, no_cache: bool): """TIDDL - Tidal Downloader \u266b""" - ctx.obj = ContextObj(omit_cache=no_cache) + ctx.obj = ContextObj() # latest logs file_handler = logging.FileHandler( @@ -62,14 +62,11 @@ def cli(ctx: Context, verbose: bool, quiet: bool, no_cache: bool): logging.getLogger("urllib3").setLevel(logging.ERROR) - # BUG: tiddl raises AuthError after token refresh, - # probably ctx is not working like this. - # NOTE: got 'fixed', - # but i will know if it works after my token expire - if ctx.invoked_subcommand in ("fav", "file", "search", "url"): ctx.invoke(refresh) + ctx.obj.initApi(omit_cache=no_cache) + cli.add_command(ConfigCommand) cli.add_command(AuthGroup) diff --git a/tiddl/cli/ctx.py b/tiddl/cli/ctx.py index 3f6559d..7f0db57 100644 --- a/tiddl/cli/ctx.py +++ b/tiddl/cli/ctx.py @@ -16,12 +16,13 @@ class ContextObj: resources: list[TidalResource] console: Console - def __init__(self, omit_cache=False) -> None: + def __init__(self) -> None: self.config = Config.fromFile() self.resources = [] self.api = None self.console = Console() + def initApi(self, omit_cache=False): auth = self.config.auth if auth.token and auth.user_id and auth.country_code: