-
-
Save cdgraff/82ab2dbac37141a6428a4597eea7457e to your computer and use it in GitHub Desktop.
Playlist check function used with the logs in Liquidsoap
This file contains 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
set("log.file.path", "/tmp/test.log") | |
set("server.socket.path","/tmp/<script>.sock") | |
set("server.socket",true) | |
# Simple check function to match any "Finished with ...." line in the logs | |
def checker(n) | |
# get info from upcoming request | |
m = request.metadata(n) | |
# command to find if the file was played according to the log | |
command = 'grep -F' | |
to_match = quote('Finished with "#{m["filename"]}"') | |
log_file = quote(get(default="", "log.file.path")) | |
command = '#{command} #{to_match} #{log_file}' | |
system("echo #{quote(command)}") | |
# assuming fgrep will return a non-zero code if it wasn't found | |
# test_process will return false for it, so invert the boolean value | |
not test_process(command) | |
end | |
src = playlist('truc.txt', id='truc', mode="normal", check_next=checker) | |
secure = playlist.safe('one.txt', id='one') | |
s = fallback([src, secure], track_sensitive=false) | |
output.pulseaudio(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment