Last active
February 28, 2022 02:44
-
-
Save ohld/6c42813148c53737ec855ea5bd7ad4b8 to your computer and use it in GitHub Desktop.
Create 24/7 Youtube online radio (like lo-fi music for study/relax/sleep)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, json | |
from flask import Flask, request | |
app = Flask(__name__) | |
FNAME = "song.txt" | |
@app.route('/', methods=['POST','GET']) | |
def index(): | |
with open(FNAME, "w") as f: | |
req_data = request.get_json() | |
if "now_playing" in req_data: | |
if "song" in req_data["now_playing"]: | |
if "text" in req_data["now_playing"]["song"]: | |
text = req_data["now_playing"]["song"]["text"] | |
f.write(text) | |
return '{"success":"true"}' | |
if __name__ == "__main__": | |
app.run(host='0.0.0.0', port=5000) |
@dropitlikecross You need just to set up a webhook via Azuracast admin panel: provide your webhook's URL and that is it.
So if I'm running both ffmpeg and azuracast on the same box, I'd just be inputting the IP address of that machine into the Azuracast admin panel webhook section?
Also can I run azuracast and ffmpeg on 2 separate machines with webhook.py running or is webhook.py reliant on azuracast running on that machine? Sorry new to python and trying to understand what @app.route is doing.
Thanks @ohld :)
@app.route
just tells "if someone comes to / endpoint of your server - call that function". The script can be hosted anywhere
Is this full script ?
Hi can you give an example of how you would set up a webhook for this to work on azuracast. I think thats the confusing portion.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@dropitlikecross You need just to set up a webhook via Azuracast admin panel: provide your webhook's URL and that is it.