Issue
I just want to know how to read or get data from an MP3 stream (URL), and then restream it in Flask.
I already have a Icecast2/DarkIce service running an MP3.
The purpose of this is that I want to re-stream that mp3 using my own Flask code, so this stream together with all my services are running on the same Flask server.
Thanks so much in advance!
Solution
So I've found the a solution and it's so stupidly easy:
@app.route("/audio_stream")
def Audio_Stream():
r = requests.get("http://localhost:8082/audio_stream.mp3", stream=True)
return Response(r.iter_content(chunk_size=1024), mimetype='audio/mpeg')
Basically I just used the Icecast2 stream URL, read the data and returned it using Flask.
I hope this helps somebody.
Answered By - Juan Answer Checked By - Terry (WPSolving Volunteer)