Web Radio Broadcasters

Hi all, I thought this could be a place to talk about the nitty-gritty of running your own web radio stream, which should be an easier thing to do, but maybe sharing experiences will help inspire new projects!

Here’s my current setup for the http://phonography.radio.af stream – running on an ubuntu server:

I’m running the scripts and apps mostly under a deploy user which has no sudo rights. (Remember to set up a firewall with ufw!)

Icecast is actually serving the stream. Apache is set up to proxy the stream url to /stream/ over port 80 (see config above).

There are two systemd services: one for the liquidsoap script which generates the stream and pipes it to icecast, and one for a little flask app which is being proxied via Apache to /info/ and has a “seed” endpoint, and an SSE endpoint which the client uses for realtime updates.

The liquidsoap script (see above again for the script – I think I included all the relevant scripts and configs except the icecast config, which is basically the standard setup with different auth info) looks for tracks in a phonography.m3u playlist – which is just a list of paths to FLAC files tagged with some metadata.

When a new track starts playing, a callback in liquidsoap runs the python script which doubles as the flask app and passes it the track title and the catalog number – which is just a unique ID I give each track. The python script sets the title and catalognumber in redis, and also publishes it to a pubsub channel in redis. The title and catalognumber are actually pulled from the FLAC files by liquidsoap, there’s no DB in my setup unless you count redis.

The client (a web browser) listens to the SSE channel which gets pushed data from the redis pubsub channel – it uses that to set the now playing info and look up which picture it should show. I just gave all the pictures the same name as the catalognumber to make it simple. (See index.html for the javascript that does this part.)

That’s the handy-wavey overview of the setup. It’s working out pretty well so far for me!

I’m planning to hack in a few extra bits to add artist / bio info for the tracks below the basic track info.

There is some code to tweet each track change as well that I pulled out but I can share that bit as well if anyone is interested. It’s just the most basic usage of the tweepy library for python and gets called when liquidsoap hits the python script.

Clear as mud? I’m happy to explain the setup more, also curious if other folks are operating streams and have tips to share!


Wanted to thank you for posting this. Lines Radio would be an awesome (quixotic?) project, in conjunction with the (nopefully not defunct?) netlabel thread and summary a few years back.