I got bored of remembering paths to playlists for streaming radio all the time, so I wrote a short script to do the job for me.
Rather than explaining what it can and can’t do, here’s some of the output from –help:
The following commands are recognised:
radio tag
plays the station associated with tag
radio info tag
shows information for tag
radio stop
stops playback
radio status
prints status
radio random
start playing a random station from your list
radio np
prints the currently playing track, if the stream supports it
radio
prints a list of stations. Use -v for detailed information
The script will fork, exec mplayer and then kill the parent so you won’t need to have the script running all the time. State is saved so you can get status info at any time (if you want now playing support in your IRC client of choice, for example), stop playback or switch station (if radio is already playing a station when you ask it to start playback, it will kill the old one first) and so forth.
The script needs mplayer, perl and the YAML perl-module. YAML is available from cpan and probably also from your distribution of choice.
The .radiostations file is a YAML-file with a simple layout:
tag:
name: Name of the station
desc: Description of the stations
path: Path to the station's playlist (a .pls file, usually)
stream: Misc. stream information.
The tag is what the script uses to identify a station, when you ask it to play one. It must be unique or a later station with the same tag will override the first one.
The radio script
A sample .radiostations file
The .radiostations file contain all SomaFM, DI.fm and SKY.fm stations and a few stations from DR (p1, p2, p3, boogie, barometer and electronica).
Note that the “Now Playing” feature is somewhat suboptimal. It reads the info from ICY, but not all streams use that and not all streams keep it updated. There is no general solution though, and for most sane stations (SomaFM and some DI and SKY.fm streams at least) it should work just fine. The DR streams won’t have np-support since DR sucks big time…
As usual, no guarantees or anything else. Use it if you want to :-)
There’s a similar shellscript [danish] written by Jesper Nyerup if you want to avoid perl and the YAML-module.