fixed issues

This commit is contained in:
Matteo Baldi 2025-08-02 05:31:20 +02:00
parent 502959d83b
commit 10d13e04f9
3 changed files with 28 additions and 18 deletions

View file

@ -54,26 +54,34 @@ def search(query: str):
"Authorization": "Bearer " + SessionManager.instance().get_current_session().access_tokens,
"Content-Type": "application/json"
}
return requests.get(url, headers=header).json()
response = requests.get(url, headers=header)
return response.json()
except Exception as e:
print(e)
@music_router.get("/play")
def play(song_id: str):
url = SPOTIFY_PLAY_URL + "me/player/play"
body = { "uris": [f"spotify:track:{song_id}"] }
header = {
"Authorization": "Bearer " + SessionManager.instance().get_current_session().access_tokens,
"Content-Type": "application/json"
}
requests.put(url, data=body, headers=header).json()
try:
url = SPOTIFY_PLAY_URL + "me/player/play"
body = { "uris": [f"spotify:track:{song_id}"] }
header = {
"Authorization": "Bearer " + SessionManager.instance().get_current_session().access_tokens,
"Content-Type": "application/json"
}
response = requests.put(url, data=body, headers=header)
return response.json()
except Exception as e:
print(e)
@music_router.get("/current-song")
def current_song():
url = SPOTIFY_PLAY_URL + f"me/player/currently-playing?marketing=IT"
header = {
"Authorization": "Bearer " + SessionManager.instance().get_current_session().access_tokens,
"Content-Type": "application/json"
}
return requests.get(url, headers=header).json()
try:
url = SPOTIFY_PLAY_URL + f"me/player/currently-playing?marketing=IT"
header = {
"Authorization": "Bearer " + SessionManager.instance().get_current_session().access_tokens,
"Content-Type": "application/json"
}
return requests.get(url, headers=header).json()
except Exception as e:
print(e)