Skip to content

Instantly share code, notes, and snippets.

@giflw
Forked from gilou/check.liq
Created September 2, 2019 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save giflw/b0596ce276bf81a1703d6e4cca48eac2 to your computer and use it in GitHub Desktop.
Save giflw/b0596ce276bf81a1703d6e4cca48eac2 to your computer and use it in GitHub Desktop.
Playlist check function used with the logs in Liquidsoap
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