Skip to content

Commit

Permalink
plex: Handle server unavailable
Browse files Browse the repository at this point in the history
Fixes #308
  • Loading branch information
iamkroot committed Jul 21, 2024
1 parent 7040132 commit f6b0a5a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion trakt_scrobbler/player_monitors/plex.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from json.decoder import JSONDecodeError
import confuse
from requests import HTTPError
from trakt_scrobbler import logger
from trakt_scrobbler.app_dirs import DATA_DIR
from trakt_scrobbler.file_info import cleanup_guess
Expand Down Expand Up @@ -86,7 +87,14 @@ def get_data(self, url):
if resp is None:
return
# TODO: If we get a 401, clear token and restart plex auth flow
resp.raise_for_status()
try:
resp.raise_for_status()
except HTTPError:
if resp.status_code == 503 and "Maintenance" in resp.text:
logger.warning("Plex server unavailable, ignoring")
return None
raise

try:
data = resp.json()["MediaContainer"]
except JSONDecodeError:
Expand Down

0 comments on commit f6b0a5a

Please sign in to comment.