diff --git a/plextraktsync/cli.py b/plextraktsync/cli.py index 8f3a832a45..36bc630654 100644 --- a/plextraktsync/cli.py +++ b/plextraktsync/cli.py @@ -188,6 +188,11 @@ def env_plex_username(): help="Plex password", default=lambda: environ.get("PLEX_PASSWORD", None), ) +@click.option( + "--use-token", + is_flag=True, + help="Use saved plex token if available", +) def plex_login(): """ Log in to Plex Account to obtain Access Token. Optionally can use managed user on servers that you own. diff --git a/plextraktsync/commands/plex_login.py b/plextraktsync/commands/plex_login.py index f3cfdf6c7d..0e5d9823ab 100644 --- a/plextraktsync/commands/plex_login.py +++ b/plextraktsync/commands/plex_login.py @@ -190,17 +190,21 @@ def plex_login_autoconfig(): login(username, password) -def plex_login(username, password): - login(username, password) +def plex_login(username, password, use_token: bool): + token = None + if use_token: + config = factory.config + token = config["PLEX_ACCOUNT_TOKEN"] + + login(username, password, token) -def login(username: str, password: str): +def login(username: str, password: str, token=None): if factory.has_plex_token: if not Confirm.ask(PROMPT_PLEX_RELOGIN, default=True): return - config = factory.config - account = myplex_login(username, password, config["PLEX_ACCOUNT_TOKEN"]) + account = myplex_login(username, password, token) print( Panel.fit( "Login to MyPlex was successful",