Hack:streammpc
From Music Player Daemon Community Wiki
#!/bin/bash
# streammpc by dare2dreamer, 2005.
# Popup to ask if stream should be played in local player or mpd server.
# This is intended as an add-on tool for streamtuner. To use, set play
# m3u and play stream to "streammpc %q" in streamtuner preferences.
# HINT: Also works well for playlists in your web browser.
# MPD_HOST and MPD_PORT must be set for mpc to work properly.
# Requires: streamtuner, zenity, mpc/mpd and a local media player
export MPD_HOST=YOURMPDHOST
export MPD_PORT=YOURMPDPORT
playwhere=`zenity --list --title "Play Internet Radio" --radiolist \
--text "Select location to play stream." --column "" \
--column "Play Location" FALSE "Jukebox" TRUE "Local"`
case "$playwhere" in
"Local" )
# Set to your preferred local media player
vlc $1 &
;;
"Jukebox")
if echo $1 | grep -i pls
then
# Handle pls-style playlists
mpc clear
grep '^File[0-9]*' $1 | sed -e 's/^File[0-9]*=//' | mpc add
mpc play
else
# Handle m3u-style playlists
mpc clear
cat $1 | mpc add
mpc play
fi
;;
esac
exit
another version modded by endre:
#!/bin/bash
# streammpc by dare2dreamer, 2005.
# Popup to ask if stream should be played in local player or mpd server.
# This is intended as an add-on tool for streamtuner. To use, set play
# m3u and play stream to "streammpc %q" in streamtuner preferences.
# HINT: Also works well for playlists in your web browser.
# MPD_HOST and MPD_PORT must be set for mpc to work properly.
# Requires: streamtuner, mpc/mpd and a local media player
# modified by endre, 2007: removed dialog, added playlist append feature
export MPD_HOST=127.0.0.1
export MPD_PORT=6600
#playwhere=`zenity --list --title "Play Internet Radio" --radiolist \
#--text "Select location to play stream." --column "" \
#--column "Play Location" FALSE "Jukebox" TRUE "Local"`
if echo $1 | grep -i pls; then
ITEM=`grep '^File[0-9]*' $1 | sed -e 's/^File[0-9]*=//'`
else
ITEM=$1
fi
echo $ITEM | mpc add
LASTITEM=`mpc playlist | tail -n1 | cut -d\) -f1 | cut -d\# -f2`
if [ $LASTITEM -gt 0 ]; then
mpc play $LASTITEM
else
mpc clear
echo $ITEM | mpc add
mpc play
fi
exit
</core>
