Compare commits

..

40 Commits

Author SHA1 Message Date
56bbfb1e6a Rework alarms functions 2023-08-01 13:51:36 +02:00
20c8ae162b New function: search_tracks_from_youtube()
-update help() et help_cli()
-update rename()
2023-03-29 07:31:57 +02:00
d2be4d95f3 cleaning code 2023-03-19 08:12:27 +01:00
4b6a4de17a shellcheck
correct some warnings
2023-03-18 21:05:26 +01:00
4622f0ef69 18-03-2023
-new _trim() , play_queue() functions
-modify search_artist_from_library() , list_fav() , list_queue() , remove_from_queue() with fzf

-macros.txt
2023-03-18 16:04:26 +01:00
b2455fb484 stop all devices
-new function stop_all()
2023-03-13 12:33:38 +01:00
deaa6cbe17 Bugfix
-prev()
-next()
-shazam()
-vol-
2023-03-13 09:27:25 +01:00
8adf31b467 clean code 2023-03-13 08:56:12 +01:00
bdc25bc0a3 rewrite search_tracks_from_youtube()
update search_tracks_from_youtube(): now use youtube api for search (more faster than ytsearch)
completion: add search_tracks_from_youtube()
2023-03-11 15:57:24 +01:00
59d5eb4e3e search_tracks_from_youtube()
search_tracks_from_youtube(): recherche des pistes sur youtube et les joue sur le sonos
2023-03-09 20:43:53 +01:00
a2299e9c70 shellcheck
-correct 4 errors
2023-03-02 07:01:03 +01:00
8814740b6f bugfix 2023-03-01 14:23:24 +01:00
5aaf543ad3 play_track_from_library()
-replace play_track_from_library() by search_tracks_from_library(): usage of fzf
2023-02-28 09:13:02 +01:00
7daeac02f2 bugfix
in functions art(), _tia(), search_artist_from_library(), search_album_from_library()

remove functions play_album_from_library() and play_artist_from_library()
2023-02-24 12:51:33 +01:00
267373b209 22-02-2023
-rename functions: minfo() in _minfo()
, display_cover_art() in _display_cover_art(), is_int in _is_int
-new function: art() tia(), search_artist_from_library(), search_album_from_library()
2023-02-22 13:35:08 +01:00
ec3efed2df 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 _
2023-02-17 11:29:17 +01:00
a50fbf8e03 test uri status
-play_shared_link(): test uri status = 200
2023-02-16 11:30:46 +01:00
93d9959bac make_playlist()
rework make_playlist() with fzf
2023-02-16 10:08:56 +01:00
507ca63f0e play_shared_link
play_shared_link(): rework with fzf
2023-02-14 14:41:15 +01:00
7abf5bc721 play_local_audio_dir()
play_local_audio_dir(): rework function with fzf
2023-02-14 14:12:18 +01:00
5d8f01d8e3 display_cover_art
feature:
- new display_cover_art() function (require exiftool and iTerm2)
- rework play_local_audio_file() function (support fzf)
2023-02-11 23:10:39 +01:00
555a86dc27 copy_alarms
features:
- copy_alarm() to speaker
2023-02-10 12:50:52 +01:00
f1a532f75d fzf
-new fzf arguments
2023-02-10 11:40:34 +01:00
fbf69fdcd3 feature
-rework modify_alarms() with fzf
-add sort to fzf
2023-02-09 19:53:33 +01:00
58bd538092 spec()
-update spec() as create_alarms()
2023-02-08 17:58:11 +01:00
33c8eb68f0 08-02-2023
remove_alarms(): remove a series of <Alarm_ID>
create_alarms(): remork the function and add some fzf to options
2023-02-08 17:43:43 +01:00
c5d7d3f16d Bugfix
-move_alarms()
-snooze_alarms()
2023-02-07 10:27:11 +01:00
d9255dc165 Update
-update bash_completion
-update cli help
2023-02-06 14:35:47 +01:00
12385f639a Alarms
-new functions:
 * move_alarm() and
 * spec() for modify alarms
 * modify_alarms()
 * enable_alarms()

-rebuild the list_alarms()
-update remove_alarms()
2023-02-06 10:13:56 +01:00
953a115598 Alarms menu
-new menu alarm
-rework the main menu (soco())
2023-02-03 06:56:22 +01:00
37637d11e7 Create alarms
-new create_alarms() function
2023-02-02 19:16:50 +01:00
1fd4a10a5c Bugfix
-add a timeout to shazam() for launching soco() offline
2023-02-01 16:34:50 +01:00
80e3bf39be Cosmetic
-center titles menu
2023-02-01 09:02:55 +01:00
9a1b1de529 Bugfix
-add some help
-correct some $playing
2023-01-29 07:37:13 +01:00
ec7c4dd295 Rework start/stop/prev/next/pause actions
-bugfix in shazam()
-don’t display error in prev/next if no applicable for the audio source
2023-01-28 10:26:55 +01:00
34edd44cd7 Volume
-add a step for up/down volume
2023-01-28 07:18:43 +01:00
8317260816 19-01-2023
-correct shebang install.sh
-update help
2023-01-19 10:15:50 +01:00
a214e5e908 install.sh
-install script and completion
2023-01-18 06:46:13 +01:00
aca0a37746 Auto-completion
-à mettre dans /opt/homebrew/etc/bash_completion.d
2023-01-18 06:44:09 +01:00
f207aa6133 Rename some functions 2023-01-18 06:42:06 +01:00
7 changed files with 3153 additions and 594 deletions

32
install.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# /opt/homebrew/etc/bash_completion.d/soco-cli-gui-completion.bash
italic="\033[3m"
underline="\033[4m"
bold="\033[1m"
reset="\033[0m"
SCRIPT_PATH=$(pwd)
completion_path="/opt/homebrew/etc/bash_completion.d"
# Make soco-cli-gui accessible in PATH
if [ -d $HOME/.local/bin ]; then
dest="$HOME/.local/bin"
ln -fs "${SCRIPT_PATH}"/soco-cli-gui.sh $dest/soco-cli-gui
else
dest="/usr/local/bin"
sudo ln -fs "${SCRIPT_PATH}"/soco-cli-gui.sh $dest/soco-cli-gui
fi
echo -e "Installing ${bold}soco-cli-gui${reset} in ${bold}$dest${reset} ..."
# Install completions
ln -fs "${SCRIPT_PATH}"/soco-cli-gui-completion.bash $completion_path/soco-cli-gui-completion.bash
echo -e "\n${bold}soco-cli-gui${reset} has been installed. Run ${bold}soco-cli-gui${reset} command!"

86
list_functions.txt Normal file
View File

@@ -0,0 +1,86 @@
about
add_playlist_to_queue
alarms
all
all_mute_off
all_mute_on
all_status_light_off
all_status_light_on
all_zones
clear_queue
create_alarms
create_playlist
deezer_flow
delete_playlist
delete_speaker_cache
devices
enable_alarms
favourite_radio_stations
franceinfo
franceinter
groupstatus
help
info_groups
inform
infos
is_int
k6fm
led
level_11
level_13
level_15
list_alarms
list_albums
list_all_playlist_tracks
list_artists
list_favs
list_playlists
list_queue
main
make_playlist
minfo
modify_alarms
move_alarms
mute_off
mute_on
next
option_7
party_mode
pause
play_album_from_library
play_artist_from_library
play_local_dir
play_local_file
play_local_m3u
play_radio_from_tunein
play_shared_link
play_track_from_library
play_uri
prev
refresh_speaker_list
reindex
remove_alarms
remove_from_playlist
remove_from_queue
rename_spk
rires
rtl
shares
shazaaaam
shazam
sleeep
sleeep_cancel
sleeep_duration
sleeep_timer
snooze_alarms
soco
soco_alarms
soco_infos
soco_lists
spec
start
stop
sysinfo
ungroup_all
vol+
vol-

3
macros.txt Normal file
View File

@@ -0,0 +1,3 @@
# SoCo-CLI HTTP API Server Macros file
# Format is:
# macro_name = speaker <action> <parameters> [: speaker <action> <parameters> ...]

524
old_functions.sh Normal file
View File

@@ -0,0 +1,524 @@
# play local file (.mp3|.mp4|.m4a|.aac|.flac|.ogg|.wma|.wav)
# alac in m4v
# /Users/bruno/Music/The Smile - A Light For Attracting Attention [Japan Edition] (2022)/01. The Same.mp3
# BLOQUANT Ctrl-C to quit
play_local_file() {
playing="Play a local audio file..."
echo -e "\n${bold} $playing ${reset}\n"
echo -e "${underline}Enter audio file/folder path${reset} (.mp3|.mp4|.m4a|.aac|.flac|.ogg|.wma|.wav) "
read -e -i "$HOME/" -p ": " fa
#fa=/Users/bruno/Music/Alanis\ Morissette\ -\ Such\ Pretty\ Forks\ In\ The\ Road
if ! command -v mediainfo &> /dev/null; then
echo "Install mediainfo to display media tags !"
echo -e "${italic}brew install mediainfo${reset}"
mediainfo=false
else
mediainfo=true
fi
audio=$(echo "$fa" | awk -F"/" '{print $NF}')
if [ -d "$fa" ]; then
if [[ "$OSTYPE" == "darwin"* ]]; then
echo $fa
list=$(find -E "$fa" -iregex ".*\.(mp3|mp4|m4a|aac|flac|ogg|wma|wav)" | sort)
else
list=$(find "$fa" -iregex ".*\.\(mp3\|mp4\|m4a\|aac\|flac\|ogg\|wma\|wav\)" | sort)
fi
echo -e "\n${underline}Tracks to play...${reset}"
i=1
while IFS= read -r line; do
[ "$mediainfo" = true ] && minfo "${line}" "$i"
((i++))
done <<< "$list"
echo -e "\n${underline}Playing...${reset}"
echo -e "\nHit CTRL-C to play next track \n"
printf " %-2s %-20s %-30s %-30s %-12s %-10s \n" "N°" "Artist" "Track" "Album" "Duration" "Year"
i=1
while IFS= read -r line; do
[ "$mediainfo" = true ] && minfo "${line}" "$i"
sonos $loc $device play_file "${line}"
[ $? != 0 ] && echo -e "${red}Error !${reset}"; break
((i++))
done <<< "$list"
#sonos $loc $device play_file "$list"
elif [ -f "$fa" ]; then
echo -e "\nCurrently playing ${underline}$audio${reset} ...\n"
[ "$mediainfo" = true ] && minfo "$fa"
echo -e "\n${italic}Wait for the music to end, hit <sonos -l $device stop> from another shell or hit CTRL-C to quit${reset}"
sonos $loc $device play_file "$fa"
#album_art
else
echo -e "File/folder ${bold}$audio${reset} doesn't exist!" && sleep 2
playing=""
fi
}
play_local_dir() {
playing="Playing a local directory..."
echo -e "\n${bold} $playing ${reset}\n"
echo -e "${underline}Enter a folder path:${reset} "
read -e -i "$HOME/" -p "? " dir
echo $fa
#dir=$(echo "$fa" | sed 's/ /\\ /g')
if [ -d "$dir" ]; then
sonos $loc $device play_directory "$dir"
else
echo -e "Folder ${bold}$dir${reset} doesn't exist!" && sleep 2
playing=""
fi
read -p "< Press Enter>"
sleep 2
}
export -f play_local_dir
play_shared_link() {
playing="Playing a shared link..."
echo -e "\n${bold} $playing ${reset}\n"
echo -e "\nExample:"
echo "https://open.spotify.com/track/6cpcorzV5cmVjBsuAXq4wD"
echo "https://tidal.com/browse/album/157273956"
echo "https://www.deezer.com/en/playlist/5390258182"
echo "https://music.apple.com/dk/album/black-velvet/217502930?i=217503142"
music=("https://open.spotify.com" "https://tidal.com" "https://www.deezer.com/" "https://music.apple.com")
echo -e "${underline}Enter an url:${reset} "
read -e -i "https://" -p "? " sl
for i in ${music[@]}; do
[[ "$sl" == *"$i"* ]] && s_link=$sl
done
if [ -n "$s_link" ]; then
echo "$sl"
queue=$(sonos $loc $device sharelink "$sl")
sonos $loc $device play_from_queue $queue
else
echo -e "❗ Invalid shared link !"
playing=""
fi
read -p "< Press Enter>"
sleep 2
}
make_playlist() {
playing="Create a playlist..."
echo -e "\n${bold} $playing ${reset}\n"
# GNU bash, version 3.2.57(1)-release-(x86_64-apple-darwin20)
#read -e -p "Choose folder to create playlist from: " folder
# GNU bash, version 5.1.4(1)-release (x86_64-apple-darwin19.6.0) (brew install bash)
read -e -i "$HOME/Music/" -p "Choose folder to create playlist from: " folder
if [ -d "$folder" ]; then
read -e -p "Include subfolder ? (y/n) " sub
if [ "$sub" == "y" ] || [ "$sub" == "Y" ]; then
#m3u=$(echo "$fp" | awk -F"/" '{print $NF}')
if [[ "$OSTYPE" == "darwin"* ]]; then list=$(find -E "$folder" -iregex ".*\.(mp3|mp4|m4a|aac|flac|ogg|wma|wav)" | sort)
else list=$(find "$folder" -iregex ".*\.\(mp3\|mp4\|m4a\|aac\|flac\|ogg\|wma\|wav\)" | sort); fi
else
if [[ "$OSTYPE" == "darwin"* ]]; then list=$(find -E "$folder" -maxdepth 1 -iregex ".*\.(mp3|mp4|m4a|aac|flac|ogg|wma|wav)" | sort)
else list=$(find "$folder" -maxdepth 1 -iregex ".*\.\(mp3\|mp4\|m4a\|aac\|flac\|ogg\|wma\|wav\)" | sort); fi
fi
while [ true ] ; do
read -t 10 -e -p "Give a name to the playlist (without extension): " pl_name
if [ -n "$pl_name" ] ; then
break ;
else
echo "Waiting for a name !"
fi
done
plst="$pl_name.m3u"
printf "#EXTM3U\n" > "$plst"
echo "$list" >> "$plst"
read -e -p "Do you want to edit $plst ? (y/n) " edit
if [ "$edit" == "y" ] || [ "$edit" == "Y" ]; then
[ -n $EDITOR ] && $EDITOR "$plst" || nano "$plst"
fi
# Extract album art from .mp3
# ffmpeg -hide_banner -loglevel error -i 01.\ Portez\ vos\ croix.mp3 -s 300x300 album_art.jpg
read -e -p "Do you want to play $plst ? (y/n) " play
if [ "$play" == "y" ] || [ "$play" == "Y" ]; then
playing="Playing the ${bold_under}$plst${reset}${underline} playlist..."
echo -e "\n${underline}$playing${reset}"
pls=$(cat "$plst")
echo -e "\n$pls\n"
### BUG: bloc menu avec CTRL-C ###
echo -e "Hit CTRL-C to exit playlist \n"
sonos $loc $device play_m3u "$plst" pi
fi
else
echo "Folder $folder doesn't exist !'"
fi
}
# Play URI
play_uri() {
playing=""
echo -e "\n${bold} Play radio stream... ${reset}\n"
read -p "Enter radio stream URL [.mp3|.aac|.m3u|.pls]: " url
#url="http://jazzradio.ice.infomaniak.ch/jazzradio-high.aac"
read -p "Enter radio stream name: " title
if [[ "$url" =~ ^http ]]; then
if [ -n "$title" ]; then playing="Playing $title radio stream..."
else playing="Playing $url radio stream..."; fi
echo -e "\n${bold} $playing ${reset}"
sonos $loc $device play_uri $url "$title"
else
echo -e "\nWrong radio stream URL !"
fi
sleep 2
}
# Search artist in library -> add album to queue -> play it
play_artist_from_library() {
read -e -p "Search artist in library: " search
if [ -n "$search" ]; then
a=$(sonos $loc $device search_artists "$search")
# fzf
if [ -n "$a" ]; then
echo -e "$a\n"
read -e -p "Album to play (n°): " number
if [[ "$number" =~ ^[+-]?[0-9]+$ ]]; then
b=$(echo "$a" | grep -m 1 "$number: ")
album=$(echo "$b" | awk -F ": " '{print $3}' | awk -F "|" '{print $1}' | sed 's/ *$//g')
artist=$(echo "$b" | awk -F ": " '{print $4}')
playing="Playing $album from $artist..."
echo -e "\n${bold} $playing ${reset}"
sonos $loc $device queue_search_result_number $number first : $device play_from_queue > /dev/null
else echo "Please, enter the number of the album to play !"
fi
else echo -e "Artist ${underline}$search${reset} was not found !"
fi
else echo "Empty query !"
fi
}
# Search album in library -> add to queue -> play it
play_album_from_library() {
read -e -p "Search album in library: " search
if [ -n "$search" ]; then
a=$(sonos $loc $device search_albums "$search")
if [ -n "$a" ]; then
echo -e "$a\n"
read -e -p "Album to play (n°): " number
if [[ "$number" =~ ^[+-]?[0-9]+$ ]]; then
b=$(echo "$a" | grep -m 1 "$number: ")
album=$(echo "$b" | awk -F ": " '{print $3}' | awk -F "|" '{print $1}' | sed 's/ *$//g')
artist=$(echo "$b" | awk -F ": " '{print $4}')
playing="Playing $album from $artist..."
echo -e "\n${bold} $playing ${reset}"
sonos $loc $device queue_search_result_number $number first : $device play_from_queue > /dev/null
else echo "Please, enter the number of the album to play !"
fi
else echo -e "Album ${underline}$search${reset} was not found !"
fi
else echo "Empty query !"
fi
}
# Search track in library -> add to queue -> play it
play_track_from_library() {
read -e -p "Search track in library: " search
if [ -n "$search" ]; then
a=$(sonos $loc $device search_tracks "$search")
if [ -n "$a" ]; then
echo -e "$a\n"
read -e -p "Track to play: " number
if [[ "$number" =~ ^[+-]?[0-9]+$ ]]; then
b=$(echo "$a" | grep -m 1 "$number: ")
# 1: Artist: Alain Souchon | Album: Collection (1984-2001) | Title: J'veux du cuir
track=$(echo "$b" | awk -F ": " '{print $5}')
artist=$(echo "$b" | awk -F ": " '{print $3}' | awk -F "|" '{print $1}' | sed 's/ *$//g')
playing="Playing $track from $artist..."
echo -e "\n${bold} $playing ${reset}"
sonos $loc $device queue_search_result_number $number first : $device play_from_queue > /dev/null
else echo "Please, enter the number of the track to play !"
fi
else echo -e "Track ${underline}$search${reset} was not found !"
fi
else echo "Empty query !"
fi
}
search_tracks_from_youtube_ytdlp() {
# https://github.com/mps-youtube/yewtube
# https://github.com/pystardust/ytfzf
# https://stackoverflow.com/questions/49804874/download-the-best-quality-audio-file-with-youtube-dl
#yt-dlp ytsearch5:"the clash" --get-id --get-title
# yt-dlp -f 'ba' -ciw --extract-audio --audio-quality 0 --audio-format aac -o "%(title)s.%(ext)s" -v --downloader aria2c 'https://www.youtube.com/watch?v=l0Q8z1w0KGY'
# yt-dlp -f 251 'https://www.youtube.com/watch?v=l0Q8z1w0KGY' (webm opus)
# yt-dlp -f 140 'https://www.youtube.com/watch?v=l0Q8z1w0KGY' (m4a)
# cache: ~/.cache/yt-dlp/ ~/.cache/youtube-dl/
# dl
# yt-dlp -- bJ9r8LMU9bQ
# yt-dlp -o - "https://www.youtube.com/watch?v=bJ9r8LMU9bQ" | vlc -
# audio='yt-dIp -f 'ba' -x --audio-format mp3'
# -o '%(id)s.%(ext)s'
# ytfzf
if (! type yt-dlp > /dev/null 2>&1); then
echo -e "Install ${bold}yt-dlp${reset} for searching / downloading from YouTube !"
echo -e "https://github.com/yt-dlp/yt-dlp"
echo -e "${italic}brew install yt-dlp${reset}"
exit
fi
tmp_path=/tmp/soco-cli-gui
[ -d $tmp_path ] && rm -rf $tmp_path
mkdir $tmp_path
tempfile=$(mktemp)
youtube_dl_log=$(mktemp)
read -e -p $'\e[1mSearch in YouTube: \e[1m' search
yt-dlp -j "ytsearch20:$search" | jq -r '{"Title": .fulltitle,"URL": .webpage_url,"Id": .id,"Thumbnail": .thumbnail,"Duration": .duration_string,"Description": .description}' | sed 's/\\\"/*/g' > $tempfile
# --match-filter "description !~= '\"'"
img=$(_sanitize $search)
#cat $tempfile | jq
echo
declare -a yt_urls=()
declare -a yt_titles=()
declare -a yt_durations=()
j=1
while read i; do
#echo "$i"
title=$(jq -r '.Title' <<< "$i")
url=$(jq -r '.URL' <<< "$i")
idx=$(jq -r '.Id' <<< "$i")
desc=$(jq -r '.Description' <<< "$i")
thumb=$(jq -r '.Thumbnail' <<< "$i")
duration=$(jq -r '.Duration' <<< "$i")
[ ${#duration} -le 2 ] && duration="0:$duration"
echo -e "${bold}$j. $title${reset} ($duration)"
# "Title": "Arno \"Je serais devenu un gangster sans la scène\" #INA #short",
echo -e "${desc:0:200}" | fold -w 80 -s
echo "$url"
#echo "$thumb"
#echo "$idx"
yt_urls+=("$url")
yt_titles+=("$title")
yt_durations+=("$duration")
if [ -n "$thumb" ]; then
name="$img$j.png"
magick "$thumb" -quality 75 -resize 300x300\> $tmp_path/$name
if [ -f "$tmp_path/$name" ]; then
printf "\n\t\033]1337;File=;width=300px;inline=1:`cat $tmp_path/$name | base64`\a\n"
fi
fi
echo
((j++))
done <<< $(jq -c '.' "$tempfile")
nb=${#yt_urls[@]}
while :
do
read -e -p $'\e[1mEnter video number to download/listen or q to quit: \e[1m' i
echo
[ "$i" == "q" ] && break
if ((i >= 1 && i <= $nb)); then
((i=i-1))
youtube_title=${yt_titles[$i]}
youtube_duration=${yt_durations[$i]}
youtube_url=${yt_urls[$i]}
if [ -n "$youtube_url" ]; then
yt-dlp -f 140 $youtube_url -P $dest_yt -o "%(title)s.%(ext)s" --restrict-filenames
filename=$(yt-dlp -f 140 $youtube_url -P $dest_yt -o "%(title)s.%(ext)s" --restrict-filenames --get-filename)
echo -e "\nPlaying ${bold}$youtube_title${reset} ($youtube_duration) (Ctrl-C to quit)\n"
sonos $loc $device play_file "$filename"
fi
fi
done
}
s_ar_f_l() {
######################@
while :
do
echo
read -e -p "Search artist in library: " search
if [ -n "$search" ]; then
artists=$(sonos "$loc" "$device" list_artists | tail -n+4 | fzf "${fzf_music_folder_args[@]}")
#artists=$(sonos "$loc" "$device" search_artists "$search" | tail -n+4 | awk NF | grep -v -E "^ ===" | sort)
#tracks=$(cat search_tracks.txt| tail -n+4)
echo "$artists"
nb=$(echo -n "$artists" | grep -c '^')
if [ "$nb" -gt 0 ]; then
if [ $fzf_bin -eq 1 ]; then
fzf_music_folder_args=(
--border
--exact
--header="ENTER for select artist; ESC for a new search"
)
alb=$(echo "$artists" | fzf "${fzf_music_folder_args[@]}")
[ -n "$alb" ] && break
else
[ "$nb" -gt 1 ] && echo "Artists found:" || echo "Artist found:"
echo -e "$artists\n"
while :
do
read -e -p "Choose index of artist or (q) to re-search: " research
if [ "$research" != "q" ] && [ -n "$research" ]; then
alb=$(echo "$artists" | grep -E ^[[:blank:]]+"$research:")
[ -n "$art" ] && break 2 || echo "Wrong Choice !"
else break
fi
done
fi
fi
fi
done
if [ -n "$alb" ]; then
echo "$alb"
fi
}
s_al_f_l() {
while :
do
echo
read -e -p "Search album in library: " search
if [ -n "$search" ]; then
albums=$(sonos "$loc" "$device" search_albums "$search" | tail -n+4)
nb=$(echo -n "$albums" | grep -c '^')
if [ "$nb" -gt 0 ]; then
#fzf_bin=0
if [ $fzf_bin -eq 1 ]; then
fzf_music_folder_args=(
--border
--exact
--header="ENTER for select album; ESC for a new search"
--prompt="Search album..."
)
alb=$(echo "$albums" | fzf "${fzf_music_folder_args[@]}")
[ -n "$alb" ] && break
else
[ "$nb" -gt 1 ] && echo "Albums found:" || echo "Album found:"
echo -e "$albums\n"
while :
do
read -e -p "Choose index of album, (s) to re-search, (q) to quit: " research
[ "$research" == "s" ] && break
[ "$research" == "q" ] && break 2
if [[ $research == ?(-)+([[:digit:]]) ]]; then
if [ $research -gt 0 ] && [ $research -le $nb ]; then
alb=$(echo "$albums" | grep -E ^[[:blank:]]+"$research:")
#result=$research
[ -n "$alb" ] && break 2 || echo "Wrong Choice !"
fi
fi
done
fi
fi
fi
done
if [ -n "$alb" ]; then
track=$(echo "$alb" | awk -F ": " '{print $1}' | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')
artist=$(echo "$alb" | awk -F ": " '{print $3}' | awk -F "|" '{print $1}' | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')
album=$(echo "$alb" | awk -F ": " '{print $4}' | awk -F "|" '{print $1}' | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')
#title=$(echo "$alb" | awk -F ": " '{print $5}' | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//')
echo -e "\nPlaying album ${bold}$album${reset} of ${bold}$artist${reset}..."
sonos "$loc" "$device" queue_search_result_number $track first : $device play_from_queue > /dev/null
art
fi
}

View File

@@ -0,0 +1,14 @@
#/usr/bin/env bash
# https://iridakos.com/programming/2018/03/01/bash-programmable-completion-tutorial#registering-the-completion-script
_soco-cli-gui_completions()
{
COMPREPLY=($(compgen -W "deezer_flow franceinfo franceinter k6fm rires rtl level_11 level_13 level_15 vol+ vol- mute_off mute_on pause next prev start stop alarms inform sysinfo play_local_file play_local_dir list_favs clear_queue list_queue alarms create_alarms move_alarms remove_alarms enable_alarms modify_alarms snooze_alarms search_tracks_from_youtube" "${COMP_WORDS[1]}"))
}
complete -F _soco-cli-gui_completions soco-cli-gui
#complete -W "deezer_flow franceinfo franceinfo k6fm rires rtl level_11 level_13 level_15 vol+ vol- mute_off mute_on pause next prev start stop alarms inform sysinfo" soco-cli-gui.sh

File diff suppressed because it is too large Load Diff

BIN
soco-cli-logo-01-large.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB