Re: What's the easiest way to add internet radio station?
Posted: Mon Feb 08, 2010 9:48 pm
ilinux, you are awesome. Thank you for contributing this, I will have to test it out on my radio.
Create, share, discuss. Join the resistance.
https://mightyohm.com/forum/
Code: Select all
url=`wget --quiet http://listen.di.fm/public3/vocaltrance.pls -O - | grep -o -m1 'http://.*'`
mpc add $url
Code: Select all
#!/bin/sh
if [ "$1" != "" ] ; then
suffix=${1##*.}
if [ "$suffix" = "mp3" ] ; then
echo "it's a 'mp3' file"
mpc add $1
else
#Fake useragent
alias wget='wget -U "Mozilla/5.0 (X11; U; Linux i686; it; rv:1.9.1.7) Gecko/20100106 Ubuntu/9.10 (karmic) Firefox/3.5.7"'
#Download parse and add to mpd
#result=$(wget -q $1 -O-)
#echo "$result"
if [ "$suffix" = "pls" ] ; then
echo "it's a 'pls' file"
wget -q $1 -O- | grep "File1=" | sed -e 's/^File[1]*=//' | tr -d "\r" | mpc add
elif [ "$suffix" = "m3u" ] ; then
echo "it's a 'm3u' file"
wget -q $1 -O- | cat | xargs -r mpc add
else
echo "file suffix not know, try it anyway"
mpc add $1
fi
fi
else
echo "USAGE: mpc_add http://www.example.com/file.mp3"
echo "USAGE: can add url to .mp3 .m3u .pls"
fi