modified: .env.example
modified: Dockerfile modified: app.py new file: locales/de-DE.json modified: templates/login.html modified: templates/playlists.html modified: templates/quiz.html
This commit is contained in:
18
app.py
18
app.py
@@ -9,6 +9,7 @@ from spotipy.oauth2 import SpotifyOAuth
|
||||
import random
|
||||
from difflib import SequenceMatcher
|
||||
import re
|
||||
import json
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = os.getenv("SECRET_KEY")
|
||||
@@ -16,6 +17,20 @@ app.secret_key = os.getenv("SECRET_KEY")
|
||||
# Erweiterte Berechtigungen für Web Playback SDK
|
||||
SCOPE = "user-library-read playlist-read-private streaming user-read-email user-read-private"
|
||||
|
||||
def get_locale():
|
||||
return os.getenv("LANG", "de-DE")
|
||||
|
||||
def get_translations():
|
||||
lang = get_locale()
|
||||
path = os.path.join(os.path.dirname(__file__), "locales", f"{lang}.json")
|
||||
try:
|
||||
with open(path, encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
except Exception:
|
||||
# Fallback auf Deutsch
|
||||
with open(os.path.join(os.path.dirname(__file__), "locales", "de-DE.json"), encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
|
||||
def get_spotify_client():
|
||||
token_info = session.get("token_info", None)
|
||||
if not token_info:
|
||||
@@ -150,7 +165,8 @@ def quiz(playlist_id):
|
||||
question_number=len(played_tracks),
|
||||
total_questions=len(tracks),
|
||||
score=score,
|
||||
answered=answered
|
||||
answered=answered,
|
||||
translations=get_translations()
|
||||
)
|
||||
|
||||
@app.route("/search_track", methods=["POST"])
|
||||
|
||||
Reference in New Issue
Block a user