Feature:
+pause
This commit is contained in:
2020-12-20 09:41:51 +01:00
parent 96b1f9d772
commit 3e150d6235

108
sonos.sh
View File

@@ -153,10 +153,10 @@ soco() {
echo -e " 4) Rires et ${bgd}C${reset}hansons " " | " "14) m${bgd}u${reset}te OFF " " | " "24) Play artists (${bgd}x${reset}) "
echo -e " 5) ${bgd}R${reset}TL " " | " "15) volume ${bgd}15${reset} " " | " "25) Play tracks (${bgd}y${reset}) "
echo -e " 6) ${bgd}D${reset}eezer Flow " " | " "16) ${bgd}s${reset}tart $device " " | " "26) Sleeep (${bgd}w${reset}) "
echo -e " 7) " " | " "17) s${bgd}t${reset}op $device " " | " "27) "
echo -e " 8) " " | " "18) ${bgd}p${reset}rev on $device " " | " "28) "
echo -e " 9) " " | " "19) ${bgd}n${reset}ext on $device " " | " "29) ${bgd}H${reset}elp "
echo -e "10) " " | " "20) Sha${bgd}z${reset}aaaam " " | " "30) ➔ ${bgd}A${reset}ccueil "
echo -e " 7) " " | " "17) s${bgd}t${reset}op $device " " | " "27) Sha${bgd}z${reset}aaaam "
echo -e " 8) " " | " "18) Pause on $device " " | " "28) "
echo -e " 9) " " | " "19) ${bgd}p${reset}rev on $device " " | " "29) ${bgd}H${reset}elp "
echo -e "10) " " | " "20) ${bgd}n${reset}ext on $device " " | " "30) ➔ ${bgd}A${reset}ccueil "
echo -e "========================================================================"
echo -e "Enter your menu choice [1-30]: \c "
read soco_menu
@@ -176,15 +176,16 @@ soco() {
15) option_15;;
16|s|S) option_16;;
17|t|T) option_17;;
18|p|P) option_18;;
19|n|N) option_19;;
20|z|Z) option_20;;
18) option_18;;
19|p|P) option_19;;
20|n|N) option_20;;
21|i|I) soco_infos $device;;
22|l|L) soco_lists $device;;
23|b|B) play_album_from_library;;
24|x|X) play_artist_from_library;;
25|y|Y) play_track_from_library;;
26|w|W) sleeep;;
27|z|Z) option_27;;
29|h|H) help;;
30|a|A) exec "$0";;
*) echo -e "\n${red}Oops!!! Please Select Correct Choice${reset}";
@@ -286,61 +287,27 @@ option_17() {
sonos $loc $device stop && sleep 2
}
# Previous tracks
# Pause $device
option_18() {
playing="Pause $device..."
echo -e "\n\033[1m $playing \033[0m"
sonos $loc $device pause && sleep 2
}
# Previous tracks
option_19() {
#playing="Start $device..." # <= Shazaaam
echo -e "\n\033[1m $playing \033[0m"
sonos $loc $device previous && sleep 2
}
# Next tracks
option_19() {
option_20() {
#playing="Stop $device..." # <= Shazaaam
echo -e "\n\033[1m $playing \033[0m"
sonos $loc $device next && sleep 2
}
# Shazaaaam
option_20() {
echo -e "\n\033[1m Shazaaaam... \033[0m"
shazam
}
shazam() {
sz=$(sonos $loc $device track)
if [[ "$sz" =~ "Artist" ]]; then artist=$(echo "$sz" | grep "Artist" | awk -F"[=:]" '{print $2}');
else artist=""; fi
if [[ "$sz" =~ "Title" ]]; then title=$(echo "$sz" | grep "Title" | awk -F"[=:]" '{print $2}');
else title=""; fi
if [[ "$sz" =~ "Album" ]]; then album=$(echo "$sz" | grep "Album" | awk -F"[=:]" '{print $2}');
else album=""; fi
result=$( grep -i "uRi" <<< $sz)
if [ -n "$result" ]; then
uri=$(echo ${sz} | grep "URI" | grep -Eo '(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]');
if [[ "$uri" =~ "?" ]]; then
radio=$(echo "$uri" | awk -F"?" '{print $1}')
else
radio="$uri"
fi
else radio=""; fi
if [ -n "$radio" ]; then
shazam="\033[1mOn air\033[0m: \033[3m$radio\033[0m"
else
shazam="\033[1mOn air\033[0m: \033[1m$title\033[0m \033[3mfrom\033[0m $album \033[3mof\033[0m $artist"
fi
echo -e "\n $shazam \n"
sleep 2.5
#read -p "< Press Enter>"
}
# Search artist in library -> add album to queue -> play it
play_artist_from_library() {
read -p "Search artist in library: " search
@@ -497,6 +464,47 @@ sleeep_1() {
sleep 2
}
# Shazaaaam
option_27() {
echo -e "\n\033[1m Shazaaaam... \033[0m"
shazam
}
shazam() {
sz=$(sonos $loc $device track)
if [[ "$sz" =~ "Artist" ]]; then artist=$(echo "$sz" | grep "Artist" | awk -F"[=:]" '{print $2}');
else artist=""; fi
if [[ "$sz" =~ "Title" ]]; then title=$(echo "$sz" | grep "Title" | awk -F"[=:]" '{print $2}');
else title=""; fi
if [[ "$sz" =~ "Album" ]]; then album=$(echo "$sz" | grep "Album" | awk -F"[=:]" '{print $2}');
else album=""; fi
result=$( grep -i "uRi" <<< $sz)
if [ -n "$result" ]; then
uri=$(echo ${sz} | grep "URI" | grep -Eo '(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]');
if [[ "$uri" =~ "?" ]]; then
radio=$(echo "$uri" | awk -F"?" '{print $1}')
else
radio="$uri"
fi
else radio=""; fi
if [ -n "$radio" ]; then
shazam="\033[1mOn air\033[0m: \033[3m$radio\033[0m"
else
shazam="\033[1mOn air\033[0m: \033[1m$title\033[0m \033[3mfrom\033[0m $album \033[3mof\033[0m $artist"
fi
echo -e "\n $shazam \n"
sleep 2.5
#read -p "< Press Enter>"
}
# Soco device Lists Menu
soco_lists() {