difmplay
difmplay is a shell script to ease playing music from Digitally Imported (DI.fm) and SKY.fm Internet radio. Both free and premium streams are supported. Playing the premium streams naturally requires paid subscription to DI.fm or SKY.fm.
difmplay provides both command line and menu driven interfaces to select the channel and the bitrate. difmplay constructs an URL matching the choices, and passes the URL to the selected audio player application. This way one doesn't need to keep bookmarks of the playlist URLs for different channels and bitrates just to avoid visiting (and in case of premium, logging in) the DI.fm or SKY.fm website everytime one wants to play some music.
Usage
The following is practically a slightly expanded version of difmplay's built-in help message. There is no man page or other documentation, and due to simplicity of difmplay, these docs should be enough.
difmplay [option]... [channel]
Channel may be omitted if interactive menu will be used or if the default channel has been specified in the configuration file.
| Option | Description |
|---|---|
| -b bitrate | Set the bitrate as kbit/s. 256, 128, and 96 are MP3. 64, 32, and 24 are AAC+. Only 96 and 24 are available without premium subscription. The default is 256 if using premium, otherwise the default is 96. |
| -i premium | Set the premium ID (a hexadecimal string) needed to construct URLs for premium streams. You can find this string by looking at the URLs of the channels when logged in DI.fm or SKY.fm website. |
| -p player | Set the command to use as the audio player. It has to accept an URL to the playlist (.pls) as the last argument. Wordsplitting is applied to player, which makes it possible to pass additional command line options to the player program. The default is mplayer. |
| -m | Display a menu using dialog to select the channel and bitrate. The default selections can be specified in the config file or on the command line. |
| -n | Don't display a menu even if config file has MENU=yes or the -m option was already used. |
| -l | Display the list of available channels. Multi-column output is used when printing to a terminal. Otherwise single-column output is used. |
| -h | Display the help message. It's practically the same as the usage information on this web page. |
Configuration file
Because settings everything on the command line is frustrating, difmplay reads the default settings from ~/.difmplayrc if it exists. It must be a sh script that sets zero or more variables listed below. If the same setting is set on both command line and in configuration file, the value on the command line takes effect.
- BITRATE sets the default bitrate just like the -b option.
- PREMIUM sets the premium ID just like the -i option.
- PLAYER sets the audio player application to use just like the -p option.
- MENU indicates if interactive menu should be displayed. Valid values are yes and no. The default is to not show the menu.
- CHANNEL sets the default channel to play or preselect from the menu if no channel is specified on the command line.
Example:
# Default channel CHANNEL=eurodance # Low-bitrate MP3 since this example doesn't # set the premium ID needed for higher bitrates. BITRATE=96 # Use bigger cache to make sure it doesn't skip. PLAYER='mplayer -cache 512 -cache-min 50' # Always ask what to play via interactive menu. # This can be overriden with the -n option. MENU=yes
Licensing
difmplay has been put into the public domain. You can do whatever you want with difmplay.
Download
difmplay (2009-11-28)
Put it to some directory in PATH and make it executable (chmod +x difmplay). difmplay has been used on GNU/Linux and OpenBSD, and probably works on many other operating systems too.
Dependencies
Some audio player is needed to actually play the streams. Most players should work, including most players with graphical user interface. The player just needs to accept an URL to a .pls playlist as its last command line argument. The default is MPlayer.
To use interactive menus to select the settings, you need dialog. Many GNU/Linux distributions include it in their default install.
Displaying multi-column channel list requires column command. It originates from BSD but is available on all GNU/Linux systems too.