Usage: radiobro `searchterm`
The `searchterm` can be anything related to the radio station you are looking for, eg. jazz, essex, bbc
Code: Select all
#!/bin/bash
# radio-browser TUI frontend (depends: curl, jq, mpg123)
[[ -z $1 ]] && printf "E: Enter search term for radio stations.\n" && exit 0
BYNAME=http://www.radio-browser.info/webservice/json/stations/byname
STATION_LIST=/tmp/stations
## bbq way
BUFFER=3000
PLAYER="mpg123"
PARAMS="-C -b $BUFFER"
## for mr-know-all:
# BUFFER=3000
# PLAYER="mpg123" # you can try with streamripper, mplayer, vlc, ...
# PARAMS="--silent-whore --shut-the-fuck-up-smoothly --asshole-on-fire -b $BUFFER" # depends on the $PLAYER, make *your* choices and stop fucking discussing what whoreface parameters you suggest
printf "Searching for stations containing $1... \n"
curl -A "LinuxBBQ Radiobro" -s $BYNAME/$1 | jq '.[] | .url' > $STATION_LIST
killall $PLAYER 2> /dev/null # to make sure we don't have multiple streams running
array=( $(cat $STATION_LIST) )
select opt in "${array[@]}"; do
$PLAYER $PARAMS `echo $opt | tr -d '"' | tr -d ';'` &
break
done