zenity --list --width 500 --height 500 --column 'radio' --column 'url' --print-column 2 $(curl -s http://www.di.fm/ | awk -F '"' '/href="http:.*\.pls.*96k/ {print $2}' | sort | awk -F '/|\.' '{print $(NF-1) " " $0}') | xargs mplayer

Choose from a nice graphical menu which DI.FM radio station to play

This is a very simple and lightweight way to play DI.FM stations For a more complete version of the command with proper strings in the menu, try: (couldnt fit in the command field above) zenity --list --width 500 --height 500 --title 'DI.FM' --text 'Pick a Radio' --column 'radio' --column 'url' --print-column 2 $(curl -s http://www.di.fm/ | awk -F '"' '/href="http:.*\.pls.*96k/ {print $2}' | sort | awk -F '/|\.' '{print $(NF-1) " " $0}') | xargs mplayer This command line parses the html returned from http://di.fm and display all radio stations in a nice graphical menu. After the radio is chosen, the url is passed to mplayer so the music can start dependencies: - x11 with gtk environment - zenity: simple app for displaying gtk menus (sudo apt-get install zenity on ubuntu) - mplayer: simple audio player (sudo apt-get install mplayer on ubuntu)
Sample Output
$ zenity --list --width 500 --height 500 --title 'DI.FM' --text 'Pick a Radio' --column 'radio' --column 'url' --print-column 2 $(curl -s http://www.di.fm/ | awk -F '"' '/href="http:.*\.pls.*96k/ {print $2}' | awk -F '/|\.' '{print $(NF-1) " " $0}') | sort | xargs mplayer
MPlayer UNKNOWN-4.4.1 (C) 2000-2009 MPlayer Team
Failed to open LIRC support. You will not be able to use your remote control.

Playing http://listen.di.fm/public3/soulfulhouse.pls.
Resolving listen.di.fm for AF_INET6...
Couldn't resolve name for AF_INET6: listen.di.fm
Resolving listen.di.fm for AF_INET...
Connecting to server listen.di.fm[72.26.204.27]: 80...
Cache size set to 320 KBytes
Unknown entry type Version=2


Playing http://205.188.215.232:8016/.
Resolving 205.188.215.232 for AF_INET6...
Couldn't resolve name for AF_INET6: 205.188.215.232
Connecting to server 205.188.215.232[205.188.215.232]: 8016...
Name   : Soulful House - D I G I T A L L Y - I M P O R T E D - house music selected from Paris with love!
Genre  : Electronic Soulful House Deep
Website: http://www.di.fm
Public : yes
Bitrate: 96kbit/s
Cache size set to 320 KBytes
Cache fill:  7.50% (24576 bytes)   
ICY Info: StreamTitle='Elegant & Fabolous - 25 Classic House Anthems and Deep-House Tracks (Victor Hugh - Mine Suburbia (Original)';StreamUrl='';
Cache fill: 10.00% (32768 bytes)   
Audio only file format detected.
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
mpg123: Can't rewind stream by 291 bits!
AUDIO: 44100 Hz, 2 ch, s16le, 96.0 kbit/6.80% (ratio: 12000->176400)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
[pulse] working around probably broken pause functionality,
        see http://www.pulseaudio.org/ticket/440
AO: [pulse] 44100Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...

  2.1 (02.0) of -0.0 (unknown)  0.5% 78% 

15
By: polaco
2010-04-28 23:45:35

These Might Interest You

  • The function will take a comma separated list of items to be 'selected' by xsel -i: smenu "First item to paste,Paste me #2,Third menu item" You will then be prompted to choose one of the menu items. After you choose, you will be able to paste the string by clicking the middle mouse button. The menu will keep prompting you to choose menu items until you break out with Control-C. Show Sample Output


    2
    smenu() ( IFS=',' ; select x in $*; do echo "$x" | xsel -i; done )
    bartonski · 2010-02-08 15:33:53 4
  • Place it in your bashrc and running the command radio it will turn on or off each time it runs. Only one command needed. Obviously you can set it to any station you like.


    0
    radio() { if [ "$(pidof mpg123)" ] ; then killall mpg123; else mpg123 -q -@ http://173.236.29.51:8200 & fi }
    houghi · 2010-11-14 16:27:04 0
  • Above command will play Virgin Radio Dubai


    1
    mplayer -nolirc http://5253.live.streamtheworld.com/VIRGINRADIO_DUBAIAAC
    sandeepvreddy · 2013-01-09 09:00:41 0
  • Searches for web radio by submitted keyword and returns the station name and the link for listing . May be enhanced to read user's selection and submit it to mplayer. Show Sample Output


    4
    echo "Keyword?";read keyword;query="http://www.shoutcast.com/sbin/newxml.phtml?search="$keyword"";curl -s $query |awk -F '"' 'NR <= 4 {next}NR>15{exit}{sub(/SHOUTcast.com/,"http://yp.shoutcast.com/sbin/tunein-station.pls?id="$6)}{print i++" )"$2}'
    benyounes · 2010-05-03 00:44:10 3
  • This command lets you select from 10 different BBC stations. When one is chosen, it streams it with mplayer. Requires: mplayer with wma support.


    23
    bbcradio() { local s PS3="Select a station: ";select s in 1 1x 2 3 4 5 6 7 "Asian Network an" "Nations & Local lcl";do break;done;s=($s);mplayer -playlist "http://www.bbc.co.uk/radio/listen/live/r"${s[@]: -1}".asx";}
    eightmillion · 2009-11-14 08:17:03 14

  • 3
    mplayer dvdnav:// -dvd-device foo.img -mouse-movements
    dezza · 2009-06-19 23:03:04 0

What Others Think

This is awesome!
TheShadowFog · 341 weeks and 2 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: