Created
April 23, 2024 13:44
-
-
Save sgnyjohn/b4a8244db01546c68eb0408a714658c8 to your computer and use it in GitHub Desktop.
BASH Icecast streaming radio player
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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