I have a python script that makes a database call to get a music track. The script returns the path of that music file. How can I get Liquidsoap to call the python script and load the music file that the script returns?
I also need to know date/time when Liquidsoap plays that file and return that to the python script.
In liquidsoap, I currently just have it watch for changes to a playlist file:
myplaylist = playlist(mode="normal",reload=0,reload_mode="watch","/home/wruser/radio/test.m3u")
The python script makes the database call and then writes the test.m3u file.
I am thinking that perhaps there is a way in Liquidsoap to just call the script and have it return the location of the file so Liquidsoap can then load it. I would also want to know the date/time Liquidsoap does this so I can have python script save that info back to database.
I am using liquidsoap to send output to Icecast server.
Regards, Anthony
Ok, I found an answer to getting results back from python script by using this code:
def my_request_function() =
# Get the first line of my external process
result = list.hd(default="", get_process_lines("python3 /home/wruser/radio/python/test.py"))
print(result)
# Create and return a request using this result
[request.create(result)]
end
# Create the source
s = request.dynamic.list(my_request_function)