Developing and Automating a Podcast Radio StationPublished: 2016-07-12 | By: Ryan Williams
This article discusses the creation of an online radio station that uses podcast feeds as source content. The purpose of the article is to outline features and utilities that were needed in an actual working implementation. A link to the C# source code is provided below, knowing the tools and features enables one to write a similar application in another language.
To achieve the goal of an automated radio station with new content each day, RSS podcast feeds first need to be read, audio files from them need to be downloaded if they don't already exist, they then need to be converted to the broadcast format of Mp3, playlists need to be created with these files and finally the radio station needs to play these playlists at the appropriate times. At the end, a fully automated online radio station which can download both M4a and Mp3 files without silence gaps in them, with dedicated theme days can be built.
To develop the application which will get the audio files and make the playlists, a variety of tools are necessary. This application can be made using C# and can run on a modern Windows Server.
- RSS feeds to work with that contain audio files (example feed)
- Windows 10
- Visual Studio 2015 Professional
- NuGet Packages:
- 3rd Party Utilities:
- Windows Server 2012 R2 (needs adequate disk space and power)
- ShoutCast Server (to play the Mp3s on Internet radio)
Features of Application
The end result system will be able to do the following with the help of the Windows Task Scheduler:
- Read a JSON file of RSS podcast URLs to download with unique IDs for each source
- Download a configurable amount of podcasts from an RSS feed
- Filter the podcast files based on meta data keywords
- Download both M4a and Mp3 podcast files without naming collisions, dating each file with the date from the podcast source
- Remove silence at the beginning and end of each audio file (configurable on/off due to the system resources required)
- Save each audio file as Mp3 with a maximum bitrate, using a lower one if the origin is lower
- Add the Mp3s to their appropriate folders
- Add the Mp3s to their appropriate playlist files to be used ShoutCast
- Play the appropriate playlist for the given day
- Fetch new podcasts each day or more frequently if needed
- Add new podcast files to a special playlist representing the X number most recent podcasts at that time
Implementation of Radio Playlist Updater
To implement the features necessary to download the podcast files, convert them if needed, and add them to their corresponding playlist(s), different interfaces should created. These interfaces each need implementations to process the files accordingly, an example one is able to take a file and convert it to Mp3 if needed. The full details on the implementations have been ommitted in this article because the source is linked to below. The purpose of this article is to outline the details in terms of features.
In the implementation, the final format for the playlist is a .pls file. This file type has a specific format which includes a path to the Mp3 and the count of seconds in the file.
Configuration of ShoutCast Server
In a previous article, you can see details on setting up ShoutCast. The main differences between that article and what's required are related to the calendar feature. You need to specify certain playlist files that are known ahead of time and the days at which they will begin. You can read about the syntax of the calendar here.
In addition to this, it will be required to have a task that will restart the transcoder at the beginning of a day (or whenever the playlist is supposed to start). This is because a song will play until it ends, in the case of podcasts, that could be hours so its best to just restart the transcoder at the right time and then the radio will begin playing the correct playlist.
There are many potential issues that may occur when implementing this system. One of which is the availability of content, it may not be formatted correctly or the download may fail. Another is the space required to convert large uncompressed audio files. Using these command line utilities will require high permissions on a server. Due to the nature of the audio processing required, some of the command line utilities (particularily SoX.exe) may be extremely slow without enough RAM and/ or CPU cores.
You can see the source code for an implementation of the above mentioned approach in C# here.
It is entirely possible to automate a radio station or even multiple stations that use only podcasts. This is achieved by downloading the files, converting them to the needed streaming format and placing them in playlists needed by the radio station. The radio station then only needs to be activated to play these playlists, which can be updated many times a day depending on the size of the files and the speed of the computer processing them.