modified: app.py

modified:   templates/quiz.html
This commit is contained in:
Simon
2025-09-20 22:12:16 +02:00
parent 860d36aaf8
commit 76eaf45f5a
2 changed files with 14 additions and 5 deletions

8
app.py
View File

@@ -244,7 +244,13 @@ def play_track():
return {"error": "Missing device_id or track_uri"}, 400
sp = get_spotify_client()
sp.start_playback(device_id=device_id, uris=[track_uri], position_ms=position_ms)
try:
sp.start_playback(device_id=device_id, uris=[track_uri], position_ms=position_ms)
except spotipy.exceptions.SpotifyException as e:
if "Device not found" in str(e):
# Spezieller Fehlercode, damit das Frontend weiß, dass es neu laden soll
return {"error": "device_not_found", "message": "Spotify-Player nicht gefunden. Die Seite wird neu geladen..."}, 409
return {"error": str(e)}, 500
return {"success": True}