8000 Catch additional exception for Plex account login failures by jjlawren · Pull Request #37143 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Catch additional exception for Plex account login failures #37143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/plex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ async def async_play_on_sonos_service(service_call):
def get_plex_account(plex_server):
try:
return plex_server.account
except plexapi.exceptions.Unauthorized:
except (plexapi.exceptions.BadRequest, plexapi.exceptions.Unauthorized):
return None

plex_account = await hass.async_add_executor_job(get_plex_account, plex_server)
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/plex/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import time
from urllib.parse import urlparse

from plexapi.exceptions import NotFound, Unauthorized
from plexapi.exceptions import BadRequest, NotFound, Unauthorized
import plexapi.myplex
import plexapi.playqueue
import plexapi.server
Expand Down Expand Up @@ -98,7 +98,7 @@ def account(self):
if not self._plex_account and self._use_plex_tv:
try:
self._plex_account = plexapi.myplex.MyPlexAccount(token=self._token)
except Unauthorized:
except (BadRequest, Unauthorized):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad Request is HTTP status code 400, your initial post showed a 422. Does this work ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self._use_plex_tv = False
_LOGGER.error("Not authorized to access plex.tv with provided token")
raise
Expand Down
0