Initial commit.

This commit is contained in:
stormdragon2976 2023-02-11 15:04:45 -05:00
parent c945869e6f
commit cf0cf0aad4
1 changed files with 58 additions and 0 deletions

58
radio.sh Executable file
View File

@ -0,0 +1,58 @@
#!/bin/bash
# To add your own stations, put them in ~/.config/radio.sh.conf
if [[ -r "${XDG_CONFIG_HOME:-$HOME/.config}/radio.sh.conf" ]]; then
source "${XDG_CONFIG_HOME:-$HOME/.config}/radio.sh.conf"
else
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"
)
fi
if ! command -v mpv &> /dev/null ; then
echo "Please install mpv."
exit 1
fi
# Handle subprocesses that may not close with the main program.
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
# Dialog accessibility
export DIALOGOPTS='--no-lines --visit-items'
for i in "${!stations[@]}" ; do
menuList+=("${stations[$i]}" "${i}")
done
url="$(dialog --clear \
--backtitle "Storm radio" \
--no-tags \
--extra-button \
--extra-label "Record and Listen" \
--ok-label "Listen" \
--cancel-label "Exit" \
--menu "Select a radio station" -1 -1 -1 "${menuList[@]}" --stdout)"
menuCode=$?
if [[ $menuCode -eq 1 ]]; then
exit 0
fi
if [[ ${menuCode} -eq 3 ]]; then
if ! command -v streamripper &> /dev/null ; then
echo "Please install streamripper."
exit 1
fi
mkdir -p ~/stream
streamripper "${url}" --quiet -r -z -d ~/stream &
echo "Starting stream recording..."
sleep 3
mpv --quiet --no-video --volume="${1:-100}" "http://localhost:8000"
else
mpv --quiet --no-video --volume="${1:-100}" "${url}"
fi
exit 0