From: Rafael K. <raf...@gm...> - 2013-08-07 22:26:41
|
Hi guys! Thank you for such a great tool as liquidsoap, but I have a problem with the playlist. I'm working on some online radio and I have the following liquidsoap script: # This function is called when # a new metadata block is passed in # the stream. def apply_metadata(m) = title = m["filename"] print("Now playing: #{title}") filename = string.split(separator="/",title) # rozdelime cestu po lomitkach filename = list.nth(list.rev(filename),0) # vezmeme meno suboru filename = list.nth(string.split(separator="\.",filename),0) # odpojime koncovku .mp3 command = "python3.3 feedback.py " ^ filename system(command) end #!/usr/bin/liquidsoap # Log dir set("log.file.path","/tmp/basic-radio.log") #tidy up before playing playlist playlist_file = "playlist.m3u" system("python3.3 feedback.py -init") # Music myplaylist = playlist(mode="normal",playlist_file,reload_mode="rounds",reload=1) myplaylist = on_track(apply_metadata,myplaylist) # Stream it out output.icecast(%mp3, host = "localhost", port = 8080, password = "baldur", mount = "stream", myplaylist, fallible=true) As you can see - every time a new track starts, liquidsoap calls a python script - feedback.py, and every round the playlist reloads. I have 5 songs in the playlist file. This script shifts the playlist file and adds a new song to it (it will have a complex algorithm to compute which song is next to add, now it has only random, for testing. Then I expected, that liquidsoap will reload the playlist as soon as the round ends and continue playing the next songs. It reloads it, but too soon and it results in repeated playing of some songs. Then I figured out, that the playlist is actually reloaded BEFORE the round is finished and it's written also in the specification. It would be nice if I could hook on the event of playlist reloading, but I couldn't find how to do this. Or simply to be sure, that the playlist will be reloaded after the round is ended. Now I hacked it with adding "fail tracks" which aren't songs but just silence and appended it to the beginning and the end of the playlist, but I think, it's quite dirty and I don't believe, that it is reliable, because liquidsoap can reload the playlist at any time, not just few songs before the end of the playlist if I understand good. I thought also about using playlist.once and killing liquidsoap after every round and harboring the stream to another script, but I think it is quite dirty too. Can you, please, suggest me, how to solve this problem in some cleaner way or implement some methods that will make it easier in the future if you are developer? Thaks in advance :) |