Skip to content

Commit

Permalink
Save .env on plex-login success
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Apr 15, 2021
1 parent b19639e commit 4df6081
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion plex_trakt_sync/commands/plex_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
PROMPT_PLEX_USERNAME = prompt("Please enter your Plex username")
PROMPT_PLEX_RELOGIN = prompt("You already have Plex Access Token, do you want to log in again?")
PROMPT_MANAGED_USER = prompt("Do you want to use managed user instead of main account?")
SUCCESS_MESSAGE = success("Plex Media Server Authentication Token and base URL have been added to .env file")


def myplex_login(username, password):
Expand Down Expand Up @@ -138,4 +139,10 @@ def plex_login(username, password):
user = managed_user
token = account.user(managed_user).get_token(plex.machineIdentifier)

print(f"User={user}, token={token}, {plex._baseurl}")
CONFIG["PLEX_USERNAME"] = user
CONFIG["PLEX_TOKEN"] = token
CONFIG["PLEX_BASEURL"] = plex._baseurl
CONFIG["PLEX_FALLBACKURL"] = "http://localhost:32400"
CONFIG.save()

click.echo(SUCCESS_MESSAGE)

0 comments on commit 4df6081

Please sign in to comment.