RW

Developing and Automating a Podcast Radio Station

Published: 2016-07-12 | By: Ryan Williams
Introduction
 
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.
 
 
Requirements 
 
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. 
 
  • Content:

    • RSS feeds to work with that contain audio files (example feed)
  • Development:
    • Windows 10
    • Visual Studio 2015 Professional
  • NuGet Packages:
    • TagLib (to get the length of Mp3 files and their bitrates)
    • log4net (logging to console and file for debugging)
    • MoreLinq.Portable (extension methods for working with lists more effectively)
    • RestSharp (HTTP client for easier web requests)
    • Newtonsoft.Json (enables working with JSON files such easily)
  • 3rd Party Utilities:
    • FFmpeg (enables conversion from Mp3 to Wav)
    • FAAD (enbles conversion from M4a to Wav)
    • SoX (for working with Wav files, it can remove silence placed at the beginning and end of a file)
    • LAME (to convert Wav to Mp3)
  • Deployment:
    • 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.
 
 
Concerns
 
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. 
 
 
Source Code
 
You can see the source code for an implementation of the above mentioned approach in C# here.
 
 
Summary
 
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. 
 


No Comments... Yet


Comment On

Prove you are human 12 + 8 =