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)
$ 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%
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.
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.
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
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: