DEV Community

Hyena
Hyena

Posted on

Tape-selecta Online Radio Station


What is Tape-selecta?

Tape-selecta is a dockerized Icecast2 server together with Ezstream and Node.js that makes the perfect way to set up your own online radio station following just a few simple steps.

How does it work?

The setup is very simple:

  1. Install Docker.
  2. Copy your mp3 files into the music directory.
  3. Run start.sh.
  4. Check localhost:8000/mountpoint, your music should be streaming there!

The selector.sh

The selector.sh is the script that chooses what is the next file to be streamed. By default, the script just randomly picks the next file to be played. Have a look at the code:

#pick a random mp3 file under /home/music
song=$(find /home/music -name *.mp3 | shuf -n 1);
#write mp3 tag information to status.json
mp3info -p '{"title": "%t","artist": "%a" ,"category": "'${genre}'"}' "$song" > /home/info.json
#echo the info
echo $song;

Configuration

Before running your online radio station, it is important to make some security changes to the configuration of the Icecast2 server. Change the content of the file icecast-config/icecast.xml:

<authentication>
    <!-- Sources log in with username 'source' -->
    <source-password>password</source-password>
    <!-- Relays log in with username 'relay' -->
    <relay-password>password</relay-password>

    <!-- Admin logs in with the username given below -->
    <admin-user>admin</admin-user>
    <admin-password>password</admin-password>
  </authentication>

After this change the content of the ezstream-config/ezstream_mp3.xml file to match the password choosen for the Icecast2 admin user.

<sourcepassword>password</sourcepassword>

There are some other configuration options in both xml files please check the Icecast documentation page and Ezstream documentation page to know more on the subject.

Front end

The code of the project includes an Express/Node.js server, ready to the static files included in the web/public directory.
Futhermore, it is possible to retrieve the information of the current track playing in the endpoint localhost/status, the information can be useful in case we want to show information of the track provided by the mp3 tags of the file.

Next steps

If you setup your own radio station, please let me know! It would be great to have a community of self hosted stations and get to know your ideas for it.

Discussion (0)