Skip to content
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

926 spotify network error narrowcasting #933

Merged
merged 3 commits into from
Mar 3, 2025
Merged
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
7 changes: 4 additions & 3 deletions amelie/narrowcasting/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
from typing import Union

import requests
from django.conf import settings
Expand Down Expand Up @@ -124,7 +125,7 @@ def room_spotify_now_playing(request):
params={"market": "from_token"},
headers={"Authorization": "Bearer {}".format(assoc.access_token)}
)
except ConnectionError as e:
except Union[requests.ConnectionError, ConnectionError] as e:
log = logging.getLogger("amelie.narrowcasting.views.room_spotify_now_playing")
log.warning(f"ConnectionError while retrieving player info: {e}")
# Return empty response
Expand Down Expand Up @@ -169,7 +170,7 @@ def room_spotify_pause(request):
res = requests.put("https://api.spotify.com/v1/me/player/pause",
headers={"Authorization": "Bearer {}".format(assoc.access_token)}
)
except ConnectionError as e:
except Union[requests.ConnectionError, ConnectionError] as e:
log = logging.getLogger("amelie.narrowcasting.views.room_spotify_now_playing")
log.warning(f"ConnectionError while pausing Spotify player: {e}")
# Return empty response
Expand Down Expand Up @@ -214,7 +215,7 @@ def room_spotify_play(request):
res = requests.put("https://api.spotify.com/v1/me/player/play",
headers={"Authorization": "Bearer {}".format(assoc.access_token)}
)
except ConnectionError as e:
except Union[requests.ConnectionError, ConnectionError] as e:
log = logging.getLogger("amelie.narrowcasting.views.room_spotify_now_playing")
log.warning(f"ConnectionError while unpausing Spotify player: {e}")
# Return empty response
Expand Down