Skip to content

Unable to access audio files.  #8

@Chiarinze

Description

@Chiarinze

I tried fetching an audio file from the API using the composer's name and the name of the audio, but it returned an error. Does the API's database have the composer's work in an audio format, if it does, how can I fetch it?

This was the function I ran;

@app.route('/audio//')
def get_audio(composer, work):
url = f"https://openopus.org/{composer}/{work}.mp3"
response = requests.get(url)
if response.status_code == 200:
return response.content, 200, {'Content-Type': 'audio/mpeg'}
else:
return jsonify({'error': 'Unable to fetch audio file.'}), 500

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions