Unified spotify api request into one function

This commit is contained in:
agres
2025-03-23 21:56:09 +01:00
parent 9d48f7bef7
commit c65a1a8c8b
-28
View File
@@ -40,34 +40,6 @@ def get_track_information(track_id: str, bearer_token: str) -> dict:
return response_json return response_json
def get_multiple_tracks_information(bearer_token: str, *track_ids) -> dict:
"""
This function returns the track information based on the track id
:param *track_id: str
:param bearer_token: str
:return: dict
"""
if len(track_ids) > 50:
log.error('Passed more than 50 track ids to get_multiple_tracks_information')
return None
url_suffix = "ids="
separator = ","
for track_id in track_ids:
url_suffix = url_suffix + track_id + separator
url = f"https://api.spotify.com/v1/tracks?{url_suffix}"
url = url[:-len(separator)]
header = {
'Authorization': f'Bearer {bearer_token}'
}
response = requests.get(url, headers=header)
response_json = response.json()
return response_json
def get_artist_information(artist_id: str, bearer_token: str) -> dict: def get_artist_information(artist_id: str, bearer_token: str) -> dict:
""" """
This function returns the artist information based on the artist id This function returns the artist information based on the artist id