diff --git a/playlist/spotify.py b/playlist/spotify.py index 80b3074..30f7ba4 100644 --- a/playlist/spotify.py +++ b/playlist/spotify.py @@ -1,5 +1,6 @@ import requests import os +import re from datetime import datetime, timedelta from dotenv import load_dotenv @@ -34,6 +35,12 @@ class Spotify(): self.valid_until = datetime.now() + timedelta(seconds=data["expires_in"]-300) return self.token + def unshort(self, url): + """Converts a spotify.link url into a normal spotify ID""" + r = requests.get(url, allow_redirects=False) + r.raise_for_status() + return r.headers["Location"] + def get_song_info(self, spotify_id): token = self.get_token() url = 'https://api.spotify.com/v1/tracks/' + spotify_id @@ -42,4 +49,5 @@ class Spotify(): 'Authorization': 'Bearer ' + token } r = requests.get(url, headers=headers) + r.raise_for_status() return r.json() diff --git a/playlist/static/bsod.css b/playlist/static/bsod.css index 0431c82..1138fb2 100644 --- a/playlist/static/bsod.css +++ b/playlist/static/bsod.css @@ -19,7 +19,8 @@ body { #bsod { display: block; - width: 70vw; + width: max(70vw, 400px); + max-width: 800px; flex-shrink: 1; gap: 1rem; display: flex; diff --git a/playlist/static/img/sound.png b/playlist/static/img/sound.png new file mode 100644 index 0000000..48fb1f3 Binary files /dev/null and b/playlist/static/img/sound.png differ diff --git a/playlist/static/style.css b/playlist/static/style.css index fcc40d0..1b64d84 100644 --- a/playlist/static/style.css +++ b/playlist/static/style.css @@ -30,6 +30,22 @@ input[type=submit] { filter: contrast(1); } +input#spotify-input { + width: 100%; + margin-bottom: 10px; +} + +input#spotify-input + input[type=submit]{ + background-image: url(img/sound.png); + background-repeat:no-repeat; + padding: 4px 8px 4px 24px; + height: 16px; + min-width: 0; + background-position: 4px 50%; + font-weight: bold; + +} + #bsod, .hide { display: none; } diff --git a/playlist/templates/Nominate.html b/playlist/templates/Nominate.html index 9307cfa..70e3031 100644 --- a/playlist/templates/Nominate.html +++ b/playlist/templates/Nominate.html @@ -7,19 +7,28 @@ Nomineren {% block main-content %}
{% csrf_token %} - - +

Vul een spotify link in om een nummer te nomineren.

+

Deze link mag zowel naar open.spotify.com gaan als naar spotify.link

+ +
-{% if nominated %} +{% if nominated or error or warning %}