fixed break outside of loop and unimplemented max retries
This commit is contained in:
parent
3981686040
commit
d3d4fd02dd
10
getvods.sh
10
getvods.sh
|
@ -63,6 +63,7 @@ access_token="$(grep -o "access_token\":\"[a-zA-Z0-9]\+" "${CFG_DIR}/token.json"
|
||||||
# get the username to search for
|
# get the username to search for
|
||||||
declare -i retries=0
|
declare -i retries=0
|
||||||
[ ! -z "${1}" ] && {
|
[ ! -z "${1}" ] && {
|
||||||
|
while :; do
|
||||||
[ "${#1}" -ge "4" ] && [ "${#1}" -le "25" ] && grep "[a-zA-Z0-9_]\{4,25\}" <<< "${1}" >/dev/null && {
|
[ "${#1}" -ge "4" ] && [ "${#1}" -le "25" ] && grep "[a-zA-Z0-9_]\{4,25\}" <<< "${1}" >/dev/null && {
|
||||||
login="${1}"
|
login="${1}"
|
||||||
break
|
break
|
||||||
|
@ -70,6 +71,7 @@ declare -i retries=0
|
||||||
printf "username must be between 4 and 25 characters long\n"
|
printf "username must be between 4 and 25 characters long\n"
|
||||||
printf "username may have only characters a-z A-Z 0-9 and _\n"
|
printf "username may have only characters a-z A-Z 0-9 and _\n"
|
||||||
retries+=1
|
retries+=1
|
||||||
|
done
|
||||||
}
|
}
|
||||||
[ -z "${login}" ] && {
|
[ -z "${login}" ] && {
|
||||||
while :; do
|
while :; do
|
||||||
|
@ -154,10 +156,12 @@ for i in {0..19}; do
|
||||||
printf "%s:\t%s %s\n" "$((${i}+1))" "${titles[${i}]}" "${duration[${i}]}"
|
printf "%s:\t%s %s\n" "$((${i}+1))" "${titles[${i}]}" "${duration[${i}]}"
|
||||||
done
|
done
|
||||||
|
|
||||||
declare -i retries
|
retries=0
|
||||||
while :; do
|
while :; do
|
||||||
read -p "choose a video from the list (type 1-20) >" choice
|
read -p "choose a video from the list (type 1-20) >" choice
|
||||||
grep "[0-9]\{1,2\}" <<< "${choice}" && [ "${choice}" -ge 0 ] && [ "${choice}" -le 20 ] && break
|
grep "[0-9]\{1,2\}" <<< "${choice}" >/dev/null && [ "${choice}" -ge 0 ] && [ "${choice}" -le 20 ] && break
|
||||||
printf "%s is not a number from 1-20\n" "${choice}"
|
printf "%s is not a number from 1-20\n" "${choice}"
|
||||||
|
retries+=1
|
||||||
|
[ "${retries}" -ge 3 ] && on_fail "exceeded max retries" "1"
|
||||||
done
|
done
|
||||||
printf "%s\n" "${urls[$((${choice}-1))]}" | xclip -selection clipboard
|
printf "%s" "${urls[$((${choice}-1))]}" | xclip -selection clipboard
|
||||||
|
|
Loading…
Reference in New Issue