From bd5845dd04c77923aa82834eabf05532837c4089 Mon Sep 17 00:00:00 2001 From: Brandon4466 Date: Wed, 1 May 2024 00:08:41 -0700 Subject: [PATCH] design and color changes --- spotifycontroller.py | 4 +++- templates/webapp.html | 28 ++++++++++++++-------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/spotifycontroller.py b/spotifycontroller.py index 03f0a2f..e3c710e 100644 --- a/spotifycontroller.py +++ b/spotifycontroller.py @@ -7,6 +7,8 @@ import _canvas as SpotifyCanvas import time import syncedlyrics +dev = 0 + app = Flask(__name__) if os.path.exists('client_id'): @@ -18,7 +20,6 @@ if os.path.exists('client_secret'): redirect_uri = 'http://127.0.0.1:8888/callback' encoded_creds = base64.b64encode(client_id.encode() + b':' + client_secret.encode()).decode("utf-8") - headers = { "client_id": client_id, "response_type": "code", @@ -101,6 +102,7 @@ def appdata(): return { 'reload': True } currently_playing = requests.get("https://api.spotify.com/v1/me/player/currently-playing", headers=user_headers) + if currently_playing.content: if currently_playing.json()["is_playing"] is True and currently_playing.json()["item"]["id"] == request.args.get('id'): print("QUICK" + str(time.time() - stime)) diff --git a/templates/webapp.html b/templates/webapp.html index 0724ecb..2a4199f 100644 --- a/templates/webapp.html +++ b/templates/webapp.html @@ -234,17 +234,11 @@ const color = colorThief.getColor(img); document.body.style.backgroundColor = 'rgb(' + color + ')'; getLuminance(color); - document.getElementById('progress_container').style.backgroundColor = 'rgb(' + color + ')'; - lightColor = [color[0] + 50, color[1] + 50, color[2] + 50] - document.getElementById('progress_bar').style.backgroundColor = 'rgb(' + lightColor + ')'; } else { img.addEventListener('load', function() { const color = colorThief.getColor(img); document.body.style.backgroundColor = 'rgb(' + color + ')'; getLuminance(color); - document.getElementById('progress_container').style.backgroundColor = 'rgb(' + color + ')'; - lightColor = [color[0] + 50, color[1] + 50, color[2] + 50] - document.getElementById('progress_bar').style.backgroundColor = 'rgb(' + lightColor + ')'; }); } } @@ -253,18 +247,24 @@ document.getElementById('name').style.color = 'black'; document.getElementById('artist').style.color = 'black'; document.getElementById('lyric').style.color = 'black'; - document.getElementbyId('previous').style.filter = 'invert(100%)'; - document.getElementbyId('playpause').style.filter = 'invert(100%)'; - document.getElementbyId('next').style.filter = 'invert(100%)'; - document.getElementbyId('like').style.filter = 'invert(100%)'; + document.getElementById('previous').style.filter = 'invert(100%)'; + document.getElementById('playpause').style.filter = 'invert(100%)'; + document.getElementById('next').style.filter = 'invert(100%)'; + document.getElementById('like').style.filter = 'invert(100%)'; + document.getElementById('progress_container').style.backgroundColor = 'rgb(' + color + ')'; + darkColor = [color[0] - 75, color[1] - 75, color[2] - 75] + document.getElementById('progress_bar').style.backgroundColor = 'rgb(' + darkColor + ')'; } else { document.getElementById('name').style.color = 'white'; document.getElementById('artist').style.color = 'white'; document.getElementById('lyric').style.color = 'white'; - document.getElementbyId('previous').style.filter = ''; - document.getElementbyId('playpause').style.filter = ''; - document.getElementbyId('next').style.filter = ''; - document.getElementbyId('like').style.filter = ''; + document.getElementById('previous').style.filter = ''; + document.getElementById('playpause').style.filter = ''; + document.getElementById('next').style.filter = ''; + document.getElementById('like').style.filter = ''; + document.getElementById('progress_container').style.backgroundColor = 'rgb(' + color + ')'; + lightColor = [color[0] + 75, color[1] + 75, color[2] + 75] + document.getElementById('progress_bar').style.backgroundColor = 'rgb(' + lightColor + ')'; } } // function getLuminance() {