I often run into this problem of trying to conditionally assign something in
liquidsoap.
Of course this doesn’t work. Liquidsoap complains that I didn’t use the result
of the variable.
Since liquidsoap does not actually allow mutation of variables, what you are
really doing in this case is creating two source variables. You are not using
the second one. Somewhat like this:
Maybe thinking of it this way, the error makes more sense.
Of course you didn’t use the result of source2.
The solution is to write an if else statement on one line.
This assigns the result to source if the condition passes, if not assign the
source to itself.
Modern Online Radio with Liquidsoap Book - Free Sample
Need more help with liquidsoap?
Can’t get your script to work?
I wrote a book to help you learn Liquidsoap. The book covers all aspects of liquidsoap, from getting started, to making dynamic streams, audio processing, video, customizing metadata, authentication, and more. The book is available for purchase now here!
You can get a free sample chapter of my book! Just enter your email address to subscribe to my mailing list and I'll send you a free PDF sample of the book in return.