– a Wrapper Script for Listening to Radio in Linux

Download radio-0.3.tar.gz.

Update: is now available.

I like listening to music and radio while working, and fortunately there are numerous ways to do that. Unfortunately, most ways that allow you to listen to radio are very resource consuming/memory hogs (such as listening to streaming-media via web-browsers) or very unfriendly to users (listening via mplayer for example). So, I set out to find a way that will use as little system resources as possible while keeping it user-friendly. One other requirement that I had, that I will be able to do all that from the command-line, so it will work great with GNU Screen and won’t require an X server (if I work without one).

I used for some time mplayer for listening to radio. I had a file with a list of web-radio streams URLs which I would copy and pass to mplayer -playlist. This method answered two of the requirements (minimal resources and command-line interface), but wasn’t really user friendly. So, I wrote a little wrapper script in python around mplayer – After quick installation (download and extract the tar archive and copy to somewhere in you PATH), will allow you to listen to stations easily, and it will also do couple more things for you.

To listen to a station just call with the station’s name, e.g. in the command-line enter BBC1 to listen for BBC radio channel 1. To view a list of know stations run --list. Currently there aren’t many stations (just stations I thought that are needed or I listen to). You can easily edit to add new stations (the script is documented and very clear). If you do so, please write a comment or email me so I will be able to add those stations to next release by default.

So, as you seen allows you to easily listen to radio, as easy as writing the station’s name. But, as I said, it can do more things that I thought should be in a radio script. It has both a sleep feature (that turns off the radio after specified amount of time) and a wake-up feature (that starts the radio after a specified amount of time). This two features can be used together, and practically allow you to use as an alarm clock.

You can find more information about options by calling --help. I hope you will find this script useful as I do.


6 thoughts on “ – a Wrapper Script for Listening to Radio in Linux

  1. ben

    maybe you should have some web page to list the radio stations and have an auto update option in the script 🙂

  2. Guy Post author

    I was thinking about something similar, having an option to translate station names to URLs via a XML file on the web. For example you will call “ -u STATION” and it will access some XML file and parse it instead of using it’s internal station list.

  3. Nado

    HI, I’ve modified a little your python script, to read from a file. I used the ConfigParser module of standar python, not XML. If you like I send you a mail with the modifications.

  4. Nathan Cheever

    I’ve been having the same problems, but then I used Homebrew to install mplayer and it seems to be working better.
    brew install mplayer

Leave a Reply

Your email address will not be published. Required fields are marked *