radio.py – A CLI frontend to Online Radio

radio.py is a command-line frontend for mplayer designed to make listening to online radio easy.

Features

  • Allows you to easily play your favorite online radio stations.
  • Adding new stations to radio.py is very simple.
  • Record radio streams.
  • Sleep and Wake-Up features.
  • Search Tune-In for new stations.

Download and Install

radio.py is available via pip:

# pip install radiopy

The latest development version can be found in the SourceForge project page.

Using radio.py

Invoking radio.py is just as easy as specifying the station name.

radio.py Classic FM

You can view the list of supported stations by adding the --list flag.

radio.py --list

This will show a nicely formatted list of the station along with their homepage, so you can easily learn what type of music (or shows) each broadcasts.

Other Options

When invoking radio.py you can use the --wake-up and --sleep to make radio.py start to play after specified number of minutes and shut itself down after specified number of minutes accordingly.

radio.py --wake-up 30 Radio Paradise
radio.py --sleep 60 Radio Tel Aviv

These options can also be used together and make radio.py some kind of radio alarm clock.

radio.py --wake-up 480 --sleep 10 Galgalatz

will play cause radio.py to start play for 10 minutes in 8 hours from now.

radio.py also supports recording streams to mp3 (via lame).

radio.py --record news.mp3 BBC World Service

This option can also be combined with the --sleep and --wake-up flags to time the recording.

23 thoughts on “radio.py – A CLI frontend to Online Radio

  1. Simon

    This is just great – I’ve been struggling with a pile of mplayer stream url’s for BBC radio, that stopped working some time ago, and this has replaced all of the messing about entirely.

  2. Pingback: SOURCES.LIST » Blog Archive » Tante gui per Mplayer

  3. Pingback: Sveriges radio nya hemsida? Flash spelare tappar ljudet.

  4. Richard

    Unfortunately it looks as if the BBC streams have been changed, and no longer work… Other than that, great program…

  5. Cesar rodriguez

    It is a very nice project, Thank you, but somo statios don’t work any more: BBC, radioio, and probably others

  6. Chris

    The above folks are correct. Lots of the stations in the main radio.py don’t work. I ended up commenting them all out. Then I used the ~/.radiopy config file to add my own personal streams.

    Great wrapper for mplayer. Thanks a bunch!

  7. Parménides GV

    Hi!

    I love this project, but I’d like to see it in Debian.

    What about packaging it? Have you thought about it?

  8. Guy Post author

    It’s a great idea, but I never had the time to package it. I think the best thing would be to actually package it for PyPi so it would be available via tools like pip instead of directly through Debian.

    However, if you are willing to create a package for Debian, I’ll gladly upload it to the radio.py page.

  9. banshee

    This program looks like just what I am looking for! Unfortunately having issues invoking radio.py to play stations. For instance, following the example with listed stations, I am recieving this error:
    banshee@nachtcrawler:~$ radio.py Rocky FM
    Traceback (most recent call last):
    File “/usr/local/bin/radio.py”, line 96, in
    main()
    File “/usr/local/bin/radio.py”, line 91, in main
    player.play(args._station_name, **player_options)
    File “/usr/local/lib/python2.7/dist-packages/radiopy/__init__.py”, line 96, in play
    os.execvp(execargs[0],execargs)
    File “/usr/lib/python2.7/os.py”, line 344, in execvp
    _execvpe(file, args)
    File “/usr/lib/python2.7/os.py”, line 380, in _execvpe
    func(fullname, *argrest)
    OSError: [Errno 2] No such file or directory

    This error seems to occur when I try to start any radio station listed (radio.py –list)

    Do you have any thoughts why this error may be occuring? I am new to linux and python X| but i am trying to learn more and radio.py seems very cool. Any direction would be much appreciated!

  10. merijn

    cool! thanks to the error report (by banshee) i managed to find a file to add/edit radio-stations! (radiopy.default) now listening to WFMU! are there more ways to achieve this? i couldn’t find that “~/.radiopy config file” (mentioned by chris)

  11. Tom

    Hi, I am packaging version 0.6 for arch linux AUR. However I noticed that tune-in stations only work if I change station[“playlist”] = “yes” to station[“playlist”] = “no” in stations_tunein.py. This is consistent with when I run mplayer manually, the -playlist argument does not work with tune-in streams. Any comments? Can you maybe change that in an upcoming version?

  12. Kostek

    Hi there, i have the same problem as banshee. I’m totally new at python, i’m working on Win7. My python ver is 2.7
    So I have installed mplayer7.0, I have installed radiopy. And I have that problem

    import mplayer
    import radiopy
    c = radiopy.Player()
    c.play(“Rocky FM”)
    Traceback (most recent call last):
    File “”, line 1, in
    File “build\bdist.win32\egg\radiopy__init_
    File “C:\Python27\lib\os.py”, line 346, in
    _execvpe(file, args)
    File “C:\Python27\lib\os.py”, line 382, in
    func(fullname, *argrest)
    OSError: [Errno 2] No such file or directory

    Any ideas?

  13. Nathan Cheever

    I’m able to record to .wav or .mp3 file formats, but I’m not sure about the bitrates of these files. A project I’m doing requires them to be 16 bits per sample. Is there anyway to customize this?
    Thanks

  14. Guy Post author

    The bitrate is the same as the original stream, there is no conversion. The bitrate of the compression is not the same as how many bits per sample, bits per sample are usually relevant to non-compressed streams (wav, pcm) and lossless.

Leave a Reply

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