better error handling for command-line quality selection

This commit is contained in:
ksyasuda 2022-01-31 22:47:06 -08:00
parent 50af29a5bd
commit dad456eac9

View File

@ -103,8 +103,14 @@ get_quality() {
-sep '|' -only-match <<< "$QUALITIES")
QUALITY=$(awk '{print $2}' <<< "$selection")
else
printf "%s" "Enter quality [$QUALITIES]: "
qualities="best|1080p|720p|480p|360p|worst"
printf "%s" "Choose quality: [$qualities]: "
read -r QUALITY
while [[ ! "$QUALITY" =~ ($qualities) ]]; do
lg "$QUALITY not a valid quality -> [$qualities]"
printf "%s" "Choose quality: [$qualities]: "
read -r QUALITY
done
fi
lg "selected quality: $QUALITY"
}