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) |
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
@app.route
just tells "if someone comes to / endpoint of your server - call that function". The script can be hosted anywhere