added playlist view
This commit is contained in:
@@ -236,3 +236,39 @@ def cancel_artist_download():
|
||||
status=404,
|
||||
mimetype='application/json'
|
||||
)
|
||||
|
||||
# NEW ENDPOINT: Get Artist Information
|
||||
@artist_bp.route('/info', methods=['GET'])
|
||||
def get_artist_info():
|
||||
"""
|
||||
Retrieve Spotify artist metadata given a Spotify ID.
|
||||
Expects a query parameter 'id' that contains the Spotify artist ID.
|
||||
"""
|
||||
spotify_id = request.args.get('id')
|
||||
if not spotify_id:
|
||||
return Response(
|
||||
json.dumps({"error": "Missing parameter: id"}),
|
||||
status=400,
|
||||
mimetype='application/json'
|
||||
)
|
||||
|
||||
try:
|
||||
# Import the get_spotify_info function from the utility module.
|
||||
from routes.utils.get_info import get_spotify_info
|
||||
# Call the function with the artist type.
|
||||
artist_info = get_spotify_info(spotify_id, "artist")
|
||||
return Response(
|
||||
json.dumps(artist_info),
|
||||
status=200,
|
||||
mimetype='application/json'
|
||||
)
|
||||
except Exception as e:
|
||||
error_data = {
|
||||
"error": str(e),
|
||||
"traceback": traceback.format_exc()
|
||||
}
|
||||
return Response(
|
||||
json.dumps(error_data),
|
||||
status=500,
|
||||
mimetype='application/json'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user