Le 06/04/2018 à 13:21, Nolan Wagner a écrit :
> Hi all,
> 
> Has anyone done any work on something that can limit the number of times
> an artist can play within a duration of time ex) 3 times an hour when
> using a directory as a "playlist?"
> 
> Maybe using check_next? I tried the code in the comment here, but
> haven't been able to get anywhere:
> 
> https://github.com/savonet/liquidsoap/issues/333
> 
> If anyone has any ideas that would be greatly appreciated.
> 
> Thanks!


Hi,

I ran in a similar situation, where I just wanted liq not to play
something it already played... So I hacked and used the log that tells
"Finished with...", as I have a rotation in place to move the logs.
It's probably not too hard to add a restriction on date/hour while
browsing the log though.

There is most certainly ways to do that using liq directly, but my
grep-fu made me do it that way :p.

set("log.file.path", "/tmp/test.log")
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)

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Savonet-users mailing list
Savonet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to