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.

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

  1. 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. Unfortunately it looks as if the BBC streams have been changed, and no longer work… Other than that, great program…

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

  4. 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!

  5. Hi!

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

    What about packaging it? Have you thought about it?

  6. 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.

  7. 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!

  8. 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)

  9. 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?

  10. 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?

  11. 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

  12. 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.

  13. Why it doesn’t find any radios?

    radio.py -v -v -v -v bbc
    INFO:Verbosity: Level -10
    DEBUG:tunein: Searching for: bbc
    DEBUG:tunein: No matching station
    radiopy couldn’t find the requested station “bbc”
    Try –list to see the available stations list

  14. Fails to install on Win 10 x64 with the following error:

    pip install radiopy
    Collecting radiopy
    Downloading radiopy-0.6.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
    File “”, line 1, in
    File “C:\Users\user\AppData\Local\Temp\pip-build-fp_7pckz\radiopy\setup.py”, line 23, in
    version=get_version(‘radio.py’),
    File “C:\Users\user\AppData\Local\Temp\pip-build-fp_7pckz\radiopy\setup.py”, line 19, in get_version
    return version
    NameError: name ‘version‘ is not defined

    ----------------------------------------

    Command “python setup.py egg_info” failed with error code 1 in C:\Users\user\AppData\Local\Temp\pip-build-fp_7pckz\radiopy\

    Can anything be done to resolve it?

  15. In addition to my earlier comment, I was trying to install radiopy on Win 10 x64 in python 3.

  16. Runs fine on a Raspberry 3 with Rapsbian (Jessie) or actually OpenMediaVault 3.2 🙂 This after adding working stations in
    /usr/local/lib/python2.7/dist-packages/radiopy/data/radiopy.default

    Nice job! Next steps should be

    See if I can have my raspberry plays it through a BT-connected speaker
    Give moc and mpd/mpc a try (the latter is said to be easily controlled via some Android app)

  17. This sounds awesome. Unfortunately, neither the pip installer nor the sourgeforge link seem to work anymore. If you could make them available again it would be so great!

Leave a Reply

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