Romain Beauxis <toots@...> writes:
>
> Hi Rafael!2013/8/7 Rafael Korbaš <rafael.korbas-
[email protected]>>> 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?The first though that comes to my mind is that
you are perhaps using playlist() in a way this is not intended to be..
>
> Have you though about using request.dynamic? This operator gives you full
control over which song is being played next and the next track callback can
be written in any language of your choice, which also makes is more
convenient..
>
>
> Good luck!
> Romain
>
>
> --------------------------------------------------------------------------
----
> Get 100% visibility into Java/.NET code with AppDynamics Lite!
> It's a free troubleshooting tool designed for production.
> Get down to code-level detail for bottlenecks, with <2% overhead.
> Download for free and get started troubleshooting in minutes.
> http://pubads.g.doubleclick.net/gampad/clk?
id=48897031&iu=/4140/ostg.clktrk
>
> --------------------------------------------------------------------------
----
> Get 100% visibility into Java/.NET code with AppDynamics Lite!
> It's a free troubleshooting tool designed for production.
> Get down to code-level detail for bottlenecks, with <2% overhead.
> Download for free and get started troubleshooting in minutes.
> http://pubads.g.doubleclick.net/gampad/clk?
id=48897031&iu=/4140/ostg.clktrk
Thank you very much Romain!
request.dynamic solved it!
Here is my solution, that works (at least worked when testing :D) -
next_song.py now prints next song to play and feedback.py logs the currently
played song to the database:
#!/usr/bin/liquidsoap
# Log dir
set("log.file.path","/tmp/basic-radio.log")
def my_request_function() =
# Get the first line of my external process
result =
list.hd(
get_process_lines("python3 next_song.py"))
# Create and return a request using this result
print("#{result}")
request.create(result)
end
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
#set queued but not played songs to unqueued (can happen if liquidsoap was
suddenly closed)
system("python3.3 feedback.py -init")
# Create the source
s = request.dynamic(my_request_function)
s = on_track(apply_metadata,s)
output.icecast(%mp3, host = "localhost", port = 8080, password = "baldur",
mount = "stream", s, fallible=true)
Than you again,
Rafael
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users