You no longer have to declare an array in the configuration file. just add the stations in the format [station name]="url"

This commit is contained in:
stormdragon2976 2023-02-11 16:50:24 -05:00
parent 5721e6dd89
commit 9c8c253d03

View File

@ -1,15 +1,26 @@
#!/bin/bash #!/bin/bash
# To add your own stations, put them in ~/.config/radio.sh.conf # To add your own stations, put them in ~/.config/radio.sh.conf
declare -A stations=(
[NS Hit Radio <EDM>]="https://listen.nshitradio.com/"
[The Metal Plague <Death Metal>]="http://46.4.40.246:8386/"
[The True Monster <horror Punk>]="http://procyon.shoutca.st:8428/stream?fbclid=IwAR37SD7AucBHp-woBj7QyoeQPzQkCTW2BBI-CR1Q9W1hIMvIJhV9iQRQYMs"
[Thunder Rock <Classic Rock>]="http://ice10.securenetsystems.net/KTHU2"
$( [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/radio.sh.conf" ]] && source "${XDG_CONFIG_HOME:-$HOME/.config}/radio.sh.conf")
)
if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/radio.sh.conf" ]]; then if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/radio.sh.conf" ]]; then
source "${XDG_CONFIG_HOME:-$HOME/.config}/radio.sh.conf" while IFS="=" read -r key value; do
else if [[ "$key" =~ ^\[.*\]$ && "$value" =~ ^\".*\"$ ]]; then
declare -A stations=( key="${key#[}"
[NS Hit Radio <EDM>]="https://listen.nshitradio.com/" key="${key%]}"
[The Metal Plague <Death Metal>]="http://46.4.40.246:8386/" value="${value#\"}"
[The True Monster <horror Punk>]="http://procyon.shoutca.st:8428/stream?fbclid=IwAR37SD7AucBHp-woBj7QyoeQPzQkCTW2BBI-CR1Q9W1hIMvIJhV9iQRQYMs" value="${value%\"}"
[Thunder Rock <Classic Rock>]="http://ice10.securenetsystems.net/KTHU2" stations["$key"]="$value"
) else
echo "Error: invalid format in ${XDG_CONFIG_HOME:-$HOME/.config}/radio.sh.conf" >&2
exit 1
fi
done < <(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' "${XDG_CONFIG_HOME:-$HOME/.config}/radio.sh.conf")
fi fi