PyRadio 0.1
October 23, 2008
PyRadio is a console based Internet radio player. It is implemented in Python, and uses mplayer for media playback. Download version 0.1.
PyRadio has been tested under Ubuntu 8.10, but should run without any problems under most UNIX based operating systems. To get it running you’ll need Python and mplayer. Instructions are below:
Instructions
- Download PyRadio (you might need to right click on the link and select “save as”)
- Make the downloaded file executable. From the command line:
chmod +x ./pyradio - And run:
./pyradio
Code
The latest code available via GitHub.
Bugs/Feature Requests
If you find any bugs or would like to request any features then please leave a comment. Lots of new features are already planned for the next release!

Nice app! Works fine on my OS X Leopard box.
… and I like your taste in music stations.
Comment by CorkyAgain — October 28, 2008 @ 8:40 pm
Well, there is one problem: changing stations seems to leave behind an orphaned mplayer process, one for each previous station listened to. These processes are not shut down when pyradio is exited. I had to kill them manually.
Comment by CorkyAgain — October 28, 2008 @ 8:55 pm
Hi,
I have no specific request, I just wanted to say this project is very nice, especially on a netbook with low ressources.
You may consider some coding-style issues, like naming a var str, as str is a type name (line 41), or adding some docstring for methods, or avoiding tabs (replace with 4 space chars) …
But this is a nice project !
Congrats
Comment by mutah — October 28, 2008 @ 9:46 pm
Hi thought I’d write and tell you that I tried you pyradio app and thought it was great. Thanks for putting that out.
Michael
Comment by Michael — October 29, 2008 @ 3:39 am
Hmm … i like it (i a big fan of pure console) but i dont like that PyRadio leave running processes of mplayer … if you changing stations often and after you stop PyRadio then you have MANY mplayer processes left – thats no good i think …
Comment by Per Ronny Westin — October 29, 2008 @ 10:22 am
Some more info re those orphaned mplayer processes.
I looked at the process tree with OS X’s Activity Monitor and noticed that the mplayer process created by pyradio was creating a second mplayer subprocess. It is this second subprocess which is orphaned after changing stations.
The first mplayer process was killed as expected by the call to python’s os.kill( ) function.
The “orphaned” process is actually shown as a child of launchd.
Comment by CorkyAgain — October 30, 2008 @ 2:33 am
If you use kill 15 (SIGTERM) instead of kill 9, the mplayer process will clean up any subprocesses it created.
I have verified that this fixes the problem on OS X.
Details of the fix:
On line 87, replace
os.kill(self.process.pid, 9)
with
os.kill(self.process.pid, 15)
Comment by CorkyAgain — October 30, 2008 @ 2:45 am
Great
i follow CorkyAgain’s recipe that use kill 15 instead of kill 9 and it work’s here on linux – PyRadio is a sweet li’l script – i have added all my favo swedish radio stations to it too .. * POWER TO THE CONSOLE *
Comment by Per Ronny Westin — October 30, 2008 @ 7:51 am
Thanks for the feedback everyone! I’ve updated the code based on your suggestions, and the latest code is now on GitHub.
Comment by Ben — October 30, 2008 @ 9:14 am
Hi,
I downloaded pyradio and ran it with python2.4. It came up okay. But, when I moved the highlighted line down to pick another station and pressed enter, it exitted with these messages:
Any idea which file it was looking for? Thanks!
Comment by Thanh Lam — November 4, 2008 @ 8:51 pm
Hi Than,
I suspect that it can’t find “mplayer”, the media player that PyRadio uses for playback. If installing mplayer doesn’t fix the problem let me know.
I’ll try to make the error message a little more readable in the next version!
Thanks, Ben
Comment by Ben — November 5, 2008 @ 10:55 am
Hi Ben,
Very nice and useful program.
2 suggestions:
1) A way to decrease/increase the volume, e.g. using ‘v’ and ‘V’ (these are the keys xine uses).
2) Move the radio stations used to a config file, so that when we upgrade PyRadio, we don’t have to modify the source code each time to have our stations.
Thanks for the nice app
Comment by John — November 6, 2008 @ 10:27 pm
Hello Ben,
very nice app. i could not play stations with the asx-ending.i added the -playlist option for mplayer in line 210, now that works too.
thank you for pyradio!
Comment by leo — November 21, 2008 @ 8:19 pm
can we use the program on windows. if yes then what all changes I need to do for it to run on WinXP
Comment by RedArc — February 3, 2009 @ 7:57 am
@RedArc: I haven’t tried it on windows and to be honest I doubt it would run as is, but it should be possible to get it to run without any major changes. If you do try it please let me know how it goes. I’d be happy to help you out with any issues you might run into.
Comment by Ben — February 15, 2009 @ 11:41 pm
hi, I’m new with this programming…
can u teach me how to use this radio player on my computer?
i have installed Mplayer and python 2.5 on my windows…
but i don’t know how to run it…
please help me…
Comment by Rony — February 26, 2009 @ 7:58 pm
Hi Ben,
i’ve made some minor modifications to your script:
I’ve added 3 radios which made my day happy.
I also added a volume up and down funtionality by pressing the buttons “+” and “-”.
Here you got the diff.
Greetings
13a14,16
> (“S K Y . F M – Roots Reggae”, “http://scfire-ntc-aa01.stream.aol.com:80/stream/1017″),
> (“Radio Caraibes”, “http://91.121.142.31:8000″),
> (“Tim’s Radio – flamencoradio.net”, “http://flamencoradio.net:8100″),
79a83,88
>
> def volumeUp(self):
> self.sendCommand(“*”)
>
> def volumeDown(self):
> self.sendCommand(“/”)
202a212,217
> elif char == ord(‘+’):
> self.player.volumeUp()
> return
> elif char == ord(‘-’):
> self.player.volumeDown()
> return
Comment by zupert — June 11, 2009 @ 7:38 am
PS: the tabulations have been eaten by the blogs comment system ! ….
Comment by zupert — June 11, 2009 @ 7:39 am
Hi Zupert,
Thanks for the patch! Just in time for the 0.2 release which I’m planning to do over the weekend!
Ben
Comment by Ben — June 11, 2009 @ 8:09 am
nice to read !
follow up the good work !
Comment by zupert — June 15, 2009 @ 7:49 am