From 0a9b21ce5f9e86f5cc5379d4541cd6d122a23656 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Tue, 26 Oct 2021 00:51:16 +0200 Subject: [PATCH] Avoid redundant code for interactive parameters query --- scripts/yt-api-helper.sh | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/scripts/yt-api-helper.sh b/scripts/yt-api-helper.sh index 479e6a2..c660f1b 100755 --- a/scripts/yt-api-helper.sh +++ b/scripts/yt-api-helper.sh @@ -262,12 +262,6 @@ case $endpoint_option in if [ -z $browse_id ]; then browse_id="UCXuqSBlHAE6Xw-yeJA0Tunw"; fi 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 ;; @@ -292,16 +286,6 @@ case $endpoint_option in if [ -z $vid ]; then vid="dQw4w9WgXcQ"; fi 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 ;; @@ -338,6 +322,28 @@ case $endpoint_option in 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 #