-
Hello, I'm migrating our broadcasting script from I would like to send an HTTP request at the end of specific streams in a radio =
switch(
track_sensitive=false,
[
(morning_jingle, delay(180., jingles)),
(morning_slot, morning),
(afternoon_jingle, delay(180., jingles)),
(afternoon_slot, afternoon),
(evening_jingle, delay(180., jingles)),
(evening_slot, evening),
(night_jingle, delay(180., jingles)),
(night_slot, night),
({true}, fallback_track)
]
)
def request_rotate() =
req =
http.post(
headers=[
("Content-Type", "application/x-www-form-urlencoded"),
("Authorization", "Bearer #{api_auth_key}")
],
data="moment=#{!moment}",
"localhost:#{station_port}/dial/rotate"
)
if
req.status_code >= 400
then
log.important("failed to request rotation")
end
end
morning.on_leave(request_rotate)
afternoon.on_leave(request_rotate)
evening.on_leave(request_rotate)
night.on_leave(request_rotate) And each morning_playlists =
playlist(
mode='normal',
reload_mode='watch',
loop=false,
"#{rotation_dir}/morning/",
check_next=log_next_metadata
)
morning_playlists = append(morning_playlists, insert_jingles)
p =
playlist(
mode='randomize',
reload_mode='watch',
"#{selections_dir}/morning/",
check_next=log_next_metadata
)
p.on_track(signal_selection)
morning_selections = replaygain(p)
morning_selections =
crossfade(fade_out=2., fade_in=2., duration=5., morning_selections)
morning_selections = rotate(weights=[1, 4], [jingles_morning, morning_selections])
morning = fallback.skip(morning_playlists, fallback=morning_selections) However, the more recent version of LS have dropped
I've gone through the API docs and it looks like Otherwise, maybe the proper way to go about it would be to, instead of doing the request when handling the end of a given playlist, I should do the request on the first track of the following playlist (would essentially be the same behavior). Thanks for your opinions! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi, I think that in this case, a transition is the best way to go. Transitions are functions: Something like this:
|
Beta Was this translation helpful? Give feedback.
-
Nice, thanks for pointing me in the right way, I'll try it out! |
Beta Was this translation helpful? Give feedback.
-
I'm almost there, but now I'm a bit confused about the way liquidsoap handles return types. I have these functions: def request_rotate(src) =
id = src.id
print(id)
end
def transition(old_source, new_source) =
thread.run(delay=1., {request_rotate(old_source)})
sequence([old_source, new_source])
end And i get this error:
How come the second to last statement If I replace the body of Thanks! |
Beta Was this translation helpful? Give feedback.
This is a limitation with the typing system. Once you start calling the source's methods, it assumes all sources in the list must have the same methods.
The most simple solution is to give the typechecker a hint that you only need sources with no methods. Something like this: