How Its Made: Radio Nigga
As you know I have a music stream over http called Radio Nigga
In this post I want to explain the best I can, how I got it working and how you can too. I'm expecially show off the script I use to manage the stream, since the rest is just configuring the software.
Software
- Icecast: multimedia server
- ezstream: client for Icecast
Not sure why I made a list with 2 items, but what's done is done...
So, I just use these 2 softwares that are present on the Alpine Linux package repository.
My Script
This is the main thing...
Ezstream, as the name suggest is really easy and also really minimal. You just have to make an xml file with some data regarding where to stream (icecast) and what to stream (song or playlist), and you start the stream by using ezstream -c stream.xml or with a "&" at the end to make it run in the background. Ezstream also supports controls over the current media playing with certain system commands like SIGHUP to refresh a playlist
What my script does is make a managing system for the playlist file
Step by step explanation
The script can be found at my git it has 79 lines and its very simple, I could try to improve it but thats already as far as my knowledge goes.
Since the script uses commands like SIGHUP I have to run it as root
Below I will go over the script step by step and I will explain everything as good as I can.
Variables
The script starts with declaring paths that will be used plenty on the rest of the script, these include where the songs are located, where the playlists are located and what is the current playlist. As you will see later the playlist is defined by linking the desired playlist to a current.m3u that will be used by ezstream
Menu
Its allways nice to have a menu, makes things look good and its very simply. Its just a switch as you can see below.
Below the menu function theres a while loop, thats what will actually be running once you start the script, all it does is call the menu
Choose Playlist
The method using to choose a playlist, as I stated above is a file link. I simply link the playlist I want into current.m3u
All the playlists are listed using fzf, and when selected a symbolic link is created
Create Playlist
To create a playlist it just asks for a name, uses touch on the directory to create a file, adds a header and then uses fzf to add the songs. Simple Stuff. To edit the playlist manually, Vim is used, since most of the edits will be deleting songs.
Add to Playlist
Very similar to choosing the playlist, its just fzf and the directory of the song gets saved into the playlist.
Reload Playlist
I had to check the man pages of Ezstream to find this out, but Ezstream can actually take commands in a very unusual way, to reload I have to use a SIGHUP, and it will reload and restart the playlist on the next song.
Results
Peak audio stream over http, on tor and clearnet. Very easy to use script, really cool stuff.
