Handle config with a limited Plex account (#35218)

This commit is contained in:
jjlawren authored and GitHub committed 2020-05-06 18:46:00 -07:00
1 parent 64ce8e970f
commit dfe2a457c0
2 files changed
+51 -14

No files matched your search

+18 -14
View File
@@ -3,6 +3,7 @@ import logging
import ssl
from urllib.parse import urlparse
from plexapi.exceptions import Unauthorized
import plexapi.myplex
import plexapi.playqueue
import plexapi.server
@@ -138,21 +139,24 @@ class PlexServer:
else:
_connect_with_token()
self._accounts = [
account.name
for account in self._plex_server.systemAccounts()
if account.name
]
_LOGGER.debug("Linked accounts: %s", self.accounts)
try:
system_accounts = self._plex_server.systemAccounts()
except Unauthorized:
_LOGGER.warning(
"Plex account has limited permissions, shared account filtering will not be available."
)
else:
self._accounts = [
account.name for account in system_accounts if account.name
]
_LOGGER.debug("Linked accounts: %s", self.accounts)
owner_account = [
account.name
for account in self._plex_server.systemAccounts()
if account.accountID == 1
]
if owner_account:
self._owner_username = owner_account[0]
_LOGGER.debug("Server owner found: '%s'", self._owner_username)
owner_account = [
account.name for account in system_accounts if account.accountID == 1
]
if owner_account:
self._owner_username = owner_account[0]
_LOGGER.debug("Server owner found: '%s'", self._owner_username)
self._version = self._plex_server.version