Liquidsoap 0.9.2 : HTTP and harbot inputs.

HTTP input

Liquidsoap can create a source that pulls its data from an HTTP location. This location can be a distant file or playlist, or an icecast or shoutcast stream.

To use it in your script, simply create a source that way:

# url is a HTTP location, like
source = input.http(url)
Grab the code!

This operator will pull regulary the given location for its data, so it should be used for locations that are assumed to be available most of the time. If not, it might generate unnecessary traffic and polute the logs. In this case, it is perhaps better to inverse the paradigm and use the input.harbor operator.

Harbor input

Liquidsoap is also able to receive a source using icecast or shoutcast source protocol with the input.harbor operator. Using this operator, the running liquidsoap will open a network socket and wait for an incoming connection.

This operator is very useful to seamlessly add live streams into your final streams: you configure the live source client to connect directly to liquidsoap, and manage the switch to and from the live inside your script.


The global parameters for harbor can be retreived using liquidsoap --conf-descr-key harbor. They are:

You may also set some parameters per-source. You can retreive them using the command liquidsoap -h input.harbor. They are:

Let auth function is a function, that takes a pair (user,password) and returns a boolean representing whether the user should be granted access or not. Typical example can be:

def auth(user,password) = 
  # Call an external process to check 
  # the credentials:
  # The script will return the string 
  # "true" of "false"
  # First call the script
  ret = get_process_lines("/path/to/script \
         --user=#{user} --password=#{password}")
  # Then get the first line of its output
  ret = list.hd(ret)
  # Finally returns the boolean represented 
  # by the output (bool_of_string can also 
  # be used)
  if ret == "true" then
Grab the code!

In the case of the ICY (shoutcast) source protocol, there is no user parameter for the source connection. Hence, the user used will be, by order of priority:

Hence, when using a custom authentication function, in case of a ICY (shoutcast) connection, the function will receive this value for the username.


When using harbor inputs, you first set the required settings, as described above. Then, you define each source using input.harbor("mountpoint"). This source is faillible and will become available when a source client is connected.

The unlabeled parameter is the mount point that the source client may connect to. It should be "/" for shoutcast source clients.

The source client may use any of the recognized audio input codec. Hence, when using shoucast source clients, you need to have compiled liquidsoap with mp3 decoding support (ocaml-mad)

A sample code can be:


# Some code...

# This defines a source waiting on mount point 
# /test-harbor
live = input.harbor("test-harbor")

# This is the final stream.
# Uses the live source as soon as available,
# and don't wait for an end of track, since 
# we don't want to cut the beginning of the live
# stream.
# You may insert a jingle transition here...
radio = fallback(track_sensitive=false,
Grab the code!