Skip to content

Instantly share code, notes, and snippets.

@sgnyjohn
Created April 23, 2024 13:44
Show Gist options
  • Save sgnyjohn/b4a8244db01546c68eb0408a714658c8 to your computer and use it in GitHub Desktop.
Save sgnyjohn/b4a8244db01546c68eb0408a714658c8 to your computer and use it in GitHub Desktop.
BASH Icecast streaming radio player
#!/bin/bash
player=mpv
diag() {
local x="============================================================="
echo "$x
$1
$x"
}
u=http://dir.xiph.org/yp.xml
ud=/tmp/yp.xml
if ! test -e $ud; then
wget -O $ud $u
fi
tb=$'\t'
lf=$'\n'
ls=$(cat /tmp/yp.xml |tr -d '\n'|tr '>' '\n'|grep -E '/server_name|/listen|/entr'|sed -e 's/<\/server_name/\t/g'|sed -e 's/<\/listen_url//g'|tr -d '\n'|sed -e 's/<\/entry/\n/g'|while IFS=$'\t' read a b c; do echo "$a$tb$b";done|grep ://)
fl="$1"
while true; do
if [ "$fl" == "" ]; then
diag "filtrar por:"
read fl
fi
[ "$fl" == "" ] && exit 0
x=0
dl=""
while IFS=$'\t' read a b c; do
dl="$dl$x $a $b$lf"
let x=x+1
done < <(echo "$ls"|grep -i "$fl")
diag "$dl$lf ?radio?"
read op
if [ "$op" != "" ]; then
x=0
while IFS=$'\t' read a b c; do
if [ $x -eq $op ]; then
diag "$a$tb$tb$tb$b"
$player "$b"
break
fi
let x=x+1
done < <(echo "$ls"|grep -i "$fl")
fi
fl=
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment