Avoid redundant code for interactive parameters query

This commit is contained in:
Samantaz Fox 2021-10-26 00:51:16 +02:00
parent c7eb46c7bb
commit 0a9b21ce5f

View File

@ -262,12 +262,6 @@ case $endpoint_option in
if [ -z $browse_id ]; then browse_id="UCXuqSBlHAE6Xw-yeJA0Tunw"; fi if [ -z $browse_id ]; then browse_id="UCXuqSBlHAE6Xw-yeJA0Tunw"; fi
partial_data="\"browseId\":\"${browse_id}\"" partial_data="\"browseId\":\"${browse_id}\""
printf "Enter optional parameters (base64-encoded protobuf) []: "
read params
if [ ! -z $params ]; then
partial_data="${partial_data},\"params\":\"${params}\""
fi
fi fi
;; ;;
@ -292,16 +286,6 @@ case $endpoint_option in
if [ -z $vid ]; then vid="dQw4w9WgXcQ"; fi if [ -z $vid ]; then vid="dQw4w9WgXcQ"; fi
partial_data="\"videoId\":\"${vid}\"" partial_data="\"videoId\":\"${vid}\""
if [ "$endpoint_option" = "player" ]; then
printf "Enter optional parameters (base64-encoded protobuf) []: "
read params
if [ ! -z $params ]; then
partial_data="${partial_data},\"params\":\"${params}\""
fi
fi
fi fi
;; ;;
@ -338,6 +322,28 @@ case $endpoint_option in
esac esac
#
# Interactively request additional parameters for the supported endpoints
#
if [ $interactive = true ]
then
case $endpoint_option in
browse|player)
params=$(query_with_default "Enter optional parameters (base64-encoded protobuf)" "")
if [ ! -z $params ]; then
partial_data="${partial_data},\"params\":\"${params}\""
fi
;;
esac
fi
# new line
echo
# #
# Interactive language/region selection # Interactive language/region selection
# #