From aa7d40f7a0d93a923bd4a23dbd137a82d3c69437 Mon Sep 17 00:00:00 2001 From: EduardSkibidiEdger Date: Sat, 18 Jan 2025 20:20:55 +0200 Subject: [PATCH] s --- .gitignore | 3 + app.py | 16 +++-- requirements.txt | 1 + run.bat | 2 +- templates/index.html | 121 +++++++++++++++++++++++++------------ templates/queue_table.html | 79 ++++++++---------------- 6 files changed, 122 insertions(+), 100 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fc7c9cc --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ + +.env +.cache diff --git a/app.py b/app.py index 5d65c49..fa42e6f 100644 --- a/app.py +++ b/app.py @@ -1,13 +1,18 @@ -from flask import Flask, render_template, request, redirect, url_for, jsonify +from flask import Flask, render_template, request, jsonify from spotipy import Spotify from spotipy.oauth2 import SpotifyOAuth +from dotenv import load_dotenv +import os + +# Load environment variables from .env file +load_dotenv() # Flask app app = Flask(__name__) -# Spotify API credentials -CLIENT_ID = "f7f2841e0c26492681499a53b4eca29f" -CLIENT_SECRET = "8e1a973438214682939b175bb9f1ed1d" +# Spotify API credentials from environment variables +CLIENT_ID = os.getenv("CLIENT_ID") +CLIENT_SECRET = os.getenv("CLIENT_SECRET") REDIRECT_URI = "http://localhost:80/callback" SCOPE = "user-modify-playback-state user-read-playback-state" @@ -23,6 +28,7 @@ sp = Spotify(auth_manager=SpotifyOAuth( @app.route("/") def home(): return render_template("index.html") + @app.route("/add", methods=["GET"]) def add_song(): @@ -58,7 +64,7 @@ def queue_table(): queue.append({"track": track_name, "artist": artist_name}) current = None if queue_data["currently_playing"]: - current = {"track":queue_data["currently_playing"]["name"], "artist":queue_data["currently_playing"]["artists"][0]["name"]} + current = {"track": queue_data["currently_playing"]["name"], "artist": queue_data["currently_playing"]["artists"][0]["name"]} return render_template("queue_table.html", queue=queue, length=len(queue), now_playing=current) # Run the Flask app diff --git a/requirements.txt b/requirements.txt index 4244895..b214db3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ Flask spotipy +python-dotenv \ No newline at end of file diff --git a/run.bat b/run.bat index f273830..316a7cb 100644 --- a/run.bat +++ b/run.bat @@ -1 +1 @@ -python app.py \ No newline at end of file +cmd /K python -m app \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index fed1883..9fcb5bf 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,6 +1,10 @@ + Spotify Queue Manager @@ -10,13 +14,9 @@ text-align: center; margin: 0; padding: 20px; - background-color: #f0f0f0; - } - h1 { - color: #000000; } form { - margin: 20px auto; + width: 100%; } input[type="text"] { width: 80%; @@ -25,34 +25,49 @@ border: 1px solid #ccc; border-radius: 5px; } - button { - background-color: #000000; - color: white; - border: none; - padding: 10px 20px; - border-radius: 5px; - cursor: pointer; + .loading-spinner { + display: none; + text-align: center; + padding: 10px; + font-size: 16px; + color: #555; } - button:hover { - background-color: #000000; + .loading-spinner.active { + display: block; } + + /* Styling for the iframe to stretch to bottom and hide scrollbar */ iframe { width: 100%; + height: calc(100vh); /* Adjusted to leave space for other content */ border: none; - margin-top: 20px; - overflow: hidden; + overflow: hidden; /* Hide the scrollbar */ + transition: height 0.3s ease-in-out; + } + /* Optional: Smooth fade on iframe content changes */ + iframe.content { + transition: opacity 0.5s ease-in-out; + opacity: 1; }

Queue

- - + +
- - + +

Now Playing:

+
+
+ Loading now playing... +
+
+ + + diff --git a/templates/queue_table.html b/templates/queue_table.html index fd4e40b..2f377cf 100644 --- a/templates/queue_table.html +++ b/templates/queue_table.html @@ -1,63 +1,32 @@ - - - - - - - + + + + + + + + table + -
- - - - - - +
+
#TrackArtist
+ + + + - - + + {% for i in range(length) %} - - - - + + + {% endfor %} -
TrackArtist
{{ i+1 }}{{ queue[i].track }}{{ queue[i].artist }}
{{ queue[i].track }}{{ queue[i].artist }}
+