curl_url()
-new function curl_url(): return $status_uri (ok=200), $icy_name (stream’s name) -prefix functions curl_url, display_cover_art, minfo, is_int by _
This commit is contained in:
@@ -104,6 +104,24 @@ devices() {
|
|||||||
|
|
||||||
function is_int() { test "$@" -eq "$@" 2> /dev/null; }
|
function is_int() { test "$@" -eq "$@" 2> /dev/null; }
|
||||||
|
|
||||||
|
curl_url() {
|
||||||
|
status_uri=
|
||||||
|
icy_name=
|
||||||
|
q=$(curl -sS -I $1 2> /dev/null)
|
||||||
|
echo "$q"
|
||||||
|
|
||||||
|
status_uri=$(echo "$q" | head -n 1 | cut -d' ' -f2)
|
||||||
|
icy_name=$(echo "$q" | grep '^icy-name' | awk -F ':' '{print $2}')
|
||||||
|
# HTTP/1.1 200 OK / classicfm
|
||||||
|
# HTTP/2 200 / FIP
|
||||||
|
#status_uri=$(curl -sS -I ${url} 2> /dev/null | head -n 1 | cut -d' ' -f2) # 200
|
||||||
|
#status_uri=$(curl -sS -I ${url} 2> /dev/null | head -n 1 | cut -d' ' -f2-) # 200 OK
|
||||||
|
|
||||||
|
#echo "$status_uri"
|
||||||
|
#echo "$icy_name"
|
||||||
|
status_uri="${status_uri//[$'\t\r\n ']}"
|
||||||
|
icy_name="${icy_name//[$'\t\r\n ']}"
|
||||||
|
}
|
||||||
|
|
||||||
# Main Menu
|
# Main Menu
|
||||||
|
|
||||||
@@ -792,8 +810,6 @@ play_local_audio_file() {
|
|||||||
#fzf_bin=0
|
#fzf_bin=0
|
||||||
|
|
||||||
if [ $fzf_bin -eq 1 ]; then
|
if [ $fzf_bin -eq 1 ]; then
|
||||||
header=" Choose a target speaker for this alarm"
|
|
||||||
prompt="Choose a target speaker for this alarm: "
|
|
||||||
|
|
||||||
fzf_music_args=(
|
fzf_music_args=(
|
||||||
--multi
|
--multi
|
||||||
@@ -1009,9 +1025,7 @@ play_shared_link() {
|
|||||||
|
|
||||||
status_uri=$(curl -sS -I ${s_link} 2> /dev/null | head -n 1 | cut -d' ' -f2-)
|
status_uri=$(curl -sS -I ${s_link} 2> /dev/null | head -n 1 | cut -d' ' -f2-)
|
||||||
status_uri="${status_uri//[$'\t\r\n ']}"
|
status_uri="${status_uri//[$'\t\r\n ']}"
|
||||||
#echo $status_w_desc
|
|
||||||
|
|
||||||
#[ $status_uri -eq 200 ] && echo "ok"
|
|
||||||
if [ $status_uri -eq 200 ]; then
|
if [ $status_uri -eq 200 ]; then
|
||||||
#if [ -n "$s_link" ]; then
|
#if [ -n "$s_link" ]; then
|
||||||
queue=$(sonos $loc $device sharelink "$sl")
|
queue=$(sonos $loc $device sharelink "$sl")
|
||||||
@@ -1133,6 +1147,9 @@ play_artist_from_library() {
|
|||||||
|
|
||||||
if [ -n "$search" ]; then
|
if [ -n "$search" ]; then
|
||||||
a=$(sonos $loc $device search_artists "$search")
|
a=$(sonos $loc $device search_artists "$search")
|
||||||
|
|
||||||
|
# fzf
|
||||||
|
|
||||||
if [ -n "$a" ]; then
|
if [ -n "$a" ]; then
|
||||||
echo -e "$a\n"
|
echo -e "$a\n"
|
||||||
read -e -p "Album to play (n°): " number
|
read -e -p "Album to play (n°): " number
|
||||||
@@ -1214,19 +1231,54 @@ play_uri() {
|
|||||||
playing=""
|
playing=""
|
||||||
echo -e "\n${bold} Play radio stream... ${reset}\n"
|
echo -e "\n${bold} Play radio stream... ${reset}\n"
|
||||||
|
|
||||||
read -p "Enter radio stream URL [.mp3|.aac|.m3u|.pls]: " url
|
if [ $fzf_bin -eq 1 ]; then
|
||||||
|
header=" ESC to quit !"
|
||||||
|
prompt="Choose a radio: "
|
||||||
|
|
||||||
|
unset radio_uri[*CHIME*]
|
||||||
|
choice=$(printf "Play %s\n" "${!radio_uri[@]}" | sort | fzf "${fzf_args[@]}" --prompt "$prompt" --header "$header")
|
||||||
|
[ -n "$choice" ] && uri_fzf=${radio_uri[${choice:5}]}
|
||||||
|
url="$uri_fzf"
|
||||||
|
fi
|
||||||
|
echo "fzf: $uri_fzf"
|
||||||
|
|
||||||
|
|
||||||
|
if [ -z "$uri_fzf" ]; then
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
|
||||||
|
read -e -p "Enter radio stream URL [.mp3|.aac|.m3u|.pls]: " -i "http://" url
|
||||||
#url="http://jazzradio.ice.infomaniak.ch/jazzradio-high.aac"
|
#url="http://jazzradio.ice.infomaniak.ch/jazzradio-high.aac"
|
||||||
|
|
||||||
read -p "Enter radio stream name: " title
|
read -p "Enter radio stream name: " title
|
||||||
|
|
||||||
if [[ "$url" =~ ^http ]]; then
|
REGEX="CHIME|^(https?|ftp|file)://[-[:alnum:]\+&@#/%?=~_|!:,.;]+"
|
||||||
if [ -n "$title" ]; then playing="Playing $title radio stream..."
|
if [[ "$url" =~ $REGEX ]]; then
|
||||||
else playing="Playing $url radio stream..."; fi
|
#if [[ "$url" =~ ^http ]]; then
|
||||||
echo -e "\n${bold} $playing ${reset}"
|
break
|
||||||
sonos $loc $device play_uri $url "$title"
|
|
||||||
else
|
else
|
||||||
echo -e "\nWrong radio stream URL !"
|
echo -e "\nWrong radio stream URL !"
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# get url status ans radio's name
|
||||||
|
curl_url ${url}
|
||||||
|
|
||||||
|
|
||||||
|
if [ $status_uri -eq 200 ]; then
|
||||||
|
echo "$title"
|
||||||
|
echo "$icy_name" # fipreggae-midfi.mp3
|
||||||
|
echo "$url" # https://icecast.radiofrance.fr/fipreggae-midfi.mp3
|
||||||
|
|
||||||
|
if [ -n "$title" ]; then playing="Playing ${title} radio stream..."
|
||||||
|
elif [ -n "$icy_name" ]; then playing="Playing ${icy_name} radio stream..."
|
||||||
|
else playing="Playing $url radio stream..."
|
||||||
|
fi
|
||||||
|
echo -e "\n${bold} $playing ${reset}"
|
||||||
|
sonos $loc $device play_uri $url "$title"
|
||||||
|
fi
|
||||||
|
|
||||||
sleep 2
|
sleep 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user