Allow protocol to be configured for spotify proxy
This commit is contained in:
parent
29ecc9725d
commit
899e97dedc
3 changed files with 6 additions and 6 deletions
|
@ -9,7 +9,7 @@ env = environ.Env(
|
|||
DEBUG=(bool, False),
|
||||
BASE_HOSTNAME=(str, "example.com"),
|
||||
UNSPLASH_CLIENT_ID=(str, ""),
|
||||
SPOTIFY_PROXY_HOST=(str, ""),
|
||||
SPOTIFY_PROXY_URL=(str, ""),
|
||||
SEO_INDEX=(bool, False),
|
||||
SENTRY_DSN=(str, ""),
|
||||
TEST=(bool, False),
|
||||
|
@ -307,7 +307,7 @@ WAGTAIL_WORKFLOW_ENABLED = False
|
|||
WAGTAIL_MODERATION_ENABLED = False
|
||||
|
||||
UNSPLASH_CLIENT_ID = env("UNSPLASH_CLIENT_ID")
|
||||
SPOTIFY_PROXY_HOST = env("SPOTIFY_PROXY_HOST")
|
||||
SPOTIFY_PROXY_URL = env("SPOTIFY_PROXY_URL")
|
||||
|
||||
ACTIVITYPUB_HOST = env("ACTIVITYPUB_HOST")
|
||||
|
||||
|
|
|
@ -7,13 +7,13 @@ API_LIMIT = 50
|
|||
|
||||
def is_valid_playlist(playlist_id: str) -> bool:
|
||||
return requests_session.get(
|
||||
f"https://{settings.SPOTIFY_PROXY_HOST}/v1/playlists/{playlist_id}"
|
||||
settings.SPOTIFY_PROXY_URL + f"/v1/playlists/{playlist_id}"
|
||||
).ok
|
||||
|
||||
|
||||
def get_playlist(playlist_id: str) -> dict:
|
||||
playlist_response = requests_session.get(
|
||||
f"https://{settings.SPOTIFY_PROXY_HOST}/v1/playlists/{playlist_id}",
|
||||
settings.SPOTIFY_PROXY_URL + f"/v1/playlists/{playlist_id}",
|
||||
params={"fields": "name,external_urls.spotify,tracks.total,description"},
|
||||
)
|
||||
playlist_response.raise_for_status()
|
||||
|
@ -22,7 +22,7 @@ def get_playlist(playlist_id: str) -> dict:
|
|||
tracks = []
|
||||
for offset in range(0, playlist_data["tracks"]["total"], API_LIMIT):
|
||||
tracks_response = requests_session.get(
|
||||
f"https://{settings.SPOTIFY_PROXY_HOST}/v1/playlists/{playlist_id}/tracks",
|
||||
settings.SPOTIFY_PROXY_URL + f"/v1/playlists/{playlist_id}/tracks",
|
||||
params={
|
||||
"offset": str(offset),
|
||||
"limit": str(API_LIMIT),
|
||||
|
|
|
@ -8,7 +8,7 @@ class SpotifyHealthCheckBackend(BaseHealthCheckBackend):
|
|||
def check_status(self) -> None:
|
||||
try:
|
||||
requests_session.get(
|
||||
f"https://{settings.SPOTIFY_PROXY_HOST}/.health/"
|
||||
settings.SPOTIFY_PROXY_URL + "/.health/"
|
||||
).raise_for_status()
|
||||
except Exception as e:
|
||||
self.add_error(str(e))
|
||||
|
|
Loading…
Reference in a new issue