Tuesday, July 20, 2010

Zenplayer

This is a useful script for playing di.fm stations with mplayer (requires zenity, curl and mplayer)

1. open a terminal
sudo gedit /usr/bin/zenplayer

2. Add a bash shebang
#!/bin/bash

3. paste this:

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

4. Save

5. Make executable
sudo chmod +x /usr/bin/zenplayer

Then to run, just type zenplayer in a terminal and choose a station

otherwise make a new menu entry in your gnome menu and add zenplayer to properties.

If you want notifications when the track changes, add this:

| grep --line-buffered "StreamTitle='.*S" -o | grep --line-buffered "'.*'" -o > mus & tail -n0 -f mus | while read line; do notify-send "Zen Player" "$line";done

THANKS polaco and spiffwalker at commandlinefu.com

No comments:

Post a Comment