add plex account token for shared resource
MODIFY
plextraktsync/commands/plex_login.py
plextraktsync/commands/plex_login.py
@@ -207,6 +207,8 @@ def login(username: str, password: str):
user = managed_user
CONFIG["PLEX_OWNER_TOKEN"] = token
token = account.user(managed_user).get_token(plex.machineIdentifier)
+ else:
+ CONFIG["PLEX_ACCOUNT_TOKEN"] = account._token
CONFIG["PLEX_USERNAME"] = user
CONFIG["PLEX_TOKEN"] = token

MODIFY
plextraktsync/config.py
plextraktsync/config.py
@@ -108,6 +108,7 @@ class Config(dict):
"PLEX_LOCALURL",
"PLEX_TOKEN",
"PLEX_OWNER_TOKEN",
+ "PLEX_ACCOUNT_TOKEN",
"PLEX_USERNAME",
"TRAKT_USERNAME",
]

MODIFY
plextraktsync/plex_api.py
plextraktsync/plex_api.py
@@ -629,6 +629,7 @@ def get_sessions(self):
def _plex_account(self):
CONFIG = factory.config()
plex_owner_token = CONFIG.get("PLEX_OWNER_TOKEN")
+ plex_account_token = CONFIG.get("PLEX_ACCOUNT_TOKEN")
plex_username = CONFIG.get("PLEX_USERNAME")
if plex_owner_token:
try:
@@ -636,6 +637,11 @@ def _plex_account(self):
return plex_owner_account.switchHomeUser(plex_username)
except BadRequest as e:
logger.error(f"Error during {plex_username} account access: {e}")
+ elif plex_account_token:
+ try:
+ return MyPlexAccount(token=plex_account_token)
+ except BadRequest as e:
+ logger.error(f"Error during {plex_username} account access: {e}")
else:
try:
return self.plex.myPlexAccount()

add plex account token for shared resource