Use coloured click prompts
from trakt.errors import ForbiddenException
from plex_trakt_sync.config import CONFIG
-from plex_trakt_sync.style import title, success, error
+from plex_trakt_sync.style import title, success, error, prompt
from plex_trakt_sync.trakt_api import TraktApi
+PROMPT_TRAKT_CLIENT_ID = prompt("Please enter your client id")
+PROMPT_TRAKT_CLIENT_SECRET = prompt("Please enter your client secret")
TRAKT_LOGIN_SUCCESS = success(
"You are now logged into Trakt. "
"Your Trakt credentials have been added in .env and .pytrakt.json files."
@@ -18,8 +20,14 @@ def trakt_authenticate():
click.echo(title("Sign in to Trakt"))
trakt.core.AUTH_METHOD = trakt.core.DEVICE_AUTH
+ click.echo("If you do not have a client ID and secret. Please visit the following url to create them.")
+ click.echo(" https://trakt.tv/oauth/applications")
+ click.echo("")
+
while True:
- client_id, client_secret = trakt.core._get_client_info()
+ client_id = click.prompt(PROMPT_TRAKT_CLIENT_ID, type=str)
+ client_secret = click.prompt(PROMPT_TRAKT_CLIENT_SECRET, type=str)
+
try:
return trakt.init(client_id=client_id, client_secret=client_secret, store=True)
except (ForbiddenException, JSONDecodeError) as e:
