Hi,

Le ven. 27 mars 2020 à 06:01, Alexandru Matei <alexandru....@gmail.com> a
écrit :
>
> Hi.
>
> I just upgraded from v1.1 to 1.4.1 and adjustments need to be made to the
script.
>
> I can't figure out how to update the script in the following case:
> def metadata_playlists(playing_metadata)
> #on_metadata function
> server_execute_output =
server.execute("#{playing_metadata[\"source\"]}.next")
>
> log("server execute output = "^string_of(server_execute_output))
> #the expected output: a list of strings with 12 elements
>
> next_tracks_head = list.hd(server_execute_output)
> log("exec output= "^string_of(list.hd(server_execute_output)))
> #the output is <fun>
>
> Why is the output of list.hd <fun>? I can't figure out what I'm doing
wrong.

The API reference over at:
https://www.liquidsoap.info/doc-1.4.1/reference.html can help you
Also, you can always execute:

% liquidsoap -h list.hd

Return the head (first element) of a list, or 'default' if the list is
empty.

Type: (default : 'a, ['a]) -> 'a

Category: List

Parameters:

 * default : 'a (default: None)
     Default value if key does not exist

 * (unlabeled) : ['a] (default: None)

Your issue here is that list.hd has a new parameter, default, used to
return a default value if the list is empty.

Thus, all your calls to list.hd should look like:
list.hd(default="", server_execute_output)

> Thanks.
>
> P.S. Even if I have programming skills, I find it difficult to get used
with liquidsoap and ocaml specific language. What should I read to better
understand it?

We've been working on a book for liquidsoap users and programmers, we want
to resume working on it asap. Until them, online doc, slack channel and
here :-)

Romain
_______________________________________________
Savonet-users mailing list
Savonet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to