mirror of
https://gitea.invidious.io/iv-org/youtube-utils.git
synced 2024-08-15 00:53:16 +00:00
Fix issues reported by shellcheck
This commit is contained in:
parent
07e6aeecb9
commit
fd739cc5ea
1 changed files with 16 additions and 16 deletions
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# shellcheck disable=SC2236
|
||||||
|
|
||||||
|
|
||||||
print_help()
|
print_help()
|
||||||
|
@ -47,7 +48,7 @@ query_with_default()
|
||||||
default="$2"
|
default="$2"
|
||||||
|
|
||||||
printf "\n%s [%s]: " "$prompt" "$default" >&2
|
printf "\n%s [%s]: " "$prompt" "$default" >&2
|
||||||
read data
|
read -r data
|
||||||
|
|
||||||
if [ -z "$data" ]; then
|
if [ -z "$data" ]; then
|
||||||
echo "$default"
|
echo "$default"
|
||||||
|
@ -62,7 +63,7 @@ query_with_error()
|
||||||
error_message="$2"
|
error_message="$2"
|
||||||
|
|
||||||
printf "\n%s []: " "$prompt" >&2
|
printf "\n%s []: " "$prompt" >&2
|
||||||
read data
|
read -r data
|
||||||
|
|
||||||
if [ -z "$data" ]; then
|
if [ -z "$data" ]; then
|
||||||
echo "Error: $error_message"
|
echo "Error: $error_message"
|
||||||
|
@ -111,7 +112,7 @@ while :; do
|
||||||
-c|--client)
|
-c|--client)
|
||||||
shift
|
shift
|
||||||
|
|
||||||
if [ $# -eq 0 ] || $(is_arg "$1"); then
|
if [ $# -eq 0 ] || is_arg "$1"; then
|
||||||
echo "Error: missing argument after -c/--client"
|
echo "Error: missing argument after -c/--client"
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
|
@ -122,7 +123,7 @@ while :; do
|
||||||
-d|--data)
|
-d|--data)
|
||||||
shift
|
shift
|
||||||
|
|
||||||
if [ $# -eq 0 ] || $(is_arg "$1"); then
|
if [ $# -eq 0 ] || is_arg "$1"; then
|
||||||
echo "Error: missing argument after -d/--data"
|
echo "Error: missing argument after -d/--data"
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
|
@ -133,7 +134,7 @@ while :; do
|
||||||
-e|--endpoint)
|
-e|--endpoint)
|
||||||
shift
|
shift
|
||||||
|
|
||||||
if [ $# -eq 0 ] || $(is_arg "$1"); then
|
if [ $# -eq 0 ] || is_arg "$1"; then
|
||||||
echo "Error: missing argument after -e/--endpoint"
|
echo "Error: missing argument after -e/--endpoint"
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
|
@ -153,7 +154,7 @@ while :; do
|
||||||
-o|--output)
|
-o|--output)
|
||||||
shift
|
shift
|
||||||
|
|
||||||
if [ $# -eq 0 ] || $(is_arg "$1"); then
|
if [ $# -eq 0 ] || is_arg "$1"; then
|
||||||
echo "Error: missing argument after -o/--output"
|
echo "Error: missing argument after -o/--output"
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
|
@ -183,13 +184,13 @@ if [ ! -z "$data" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Can't pass client in non-interactive mode (must be part of data)
|
# Can't pass client in non-interactive mode (must be part of data)
|
||||||
if [ ! -z $client_option ]; then
|
if [ ! -z "$client_option" ]; then
|
||||||
echo "Error: -c/--client can't be used with -d/--data"
|
echo "Error: -c/--client can't be used with -d/--data"
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Endpoint must be given if non-interactive mode
|
# Endpoint must be given if non-interactive mode
|
||||||
if [ -z $endpoint_option ]; then
|
if [ -z "$endpoint_option" ]; then
|
||||||
echo "Error: In non-interactive mode, an endpoint must be passed with -e/--endpoint"
|
echo "Error: In non-interactive mode, an endpoint must be passed with -e/--endpoint"
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
|
@ -203,9 +204,9 @@ fi
|
||||||
|
|
||||||
if [ -z "$output" ] && [ $interactive = true ]; then
|
if [ -z "$output" ] && [ $interactive = true ]; then
|
||||||
printf "\nIt is recommended to use --output in interactive mode.\nContinue? [y/N]: "
|
printf "\nIt is recommended to use --output in interactive mode.\nContinue? [y/N]: "
|
||||||
read confirm
|
read -r confirm
|
||||||
|
|
||||||
if [ -z $confirm ]; then confirm="n"; fi
|
if [ -z "$confirm" ]; then confirm="n"; fi
|
||||||
|
|
||||||
case $confirm in
|
case $confirm in
|
||||||
[Yy]|[Yy][Ee][Ss]) ;;
|
[Yy]|[Yy][Ee][Ss]) ;;
|
||||||
|
@ -218,7 +219,7 @@ fi
|
||||||
# Client selection
|
# Client selection
|
||||||
#
|
#
|
||||||
|
|
||||||
if [ -z $client_option ]; then
|
if [ -z "$client_option" ]; then
|
||||||
client_option=$(query_with_default "Enter a client to use" "web")
|
client_option=$(query_with_default "Enter a client to use" "web")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -247,7 +248,7 @@ case $client_option in
|
||||||
;;
|
;;
|
||||||
|
|
||||||
android)
|
android)
|
||||||
apikey= "AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w"
|
apikey="AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w"
|
||||||
client_name="ANDROID"
|
client_name="ANDROID"
|
||||||
client_vers="16.20"
|
client_vers="16.20"
|
||||||
;;
|
;;
|
||||||
|
@ -271,9 +272,8 @@ esac
|
||||||
# Endpoint selection
|
# Endpoint selection
|
||||||
#
|
#
|
||||||
|
|
||||||
if [ -z $endpoint_option ]; then
|
if [ -z "$endpoint_option" ]; then
|
||||||
printf "Enter an endpoint to request []: "
|
endpoint_option=$(query_with_default "Enter an endpoint to request" "")
|
||||||
read endpoint_option
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $endpoint_option in
|
case $endpoint_option in
|
||||||
|
@ -361,7 +361,7 @@ then
|
||||||
browse|player|search)
|
browse|player|search)
|
||||||
params=$(query_with_default "Enter optional parameters (base64-encoded protobuf)" "")
|
params=$(query_with_default "Enter optional parameters (base64-encoded protobuf)" "")
|
||||||
|
|
||||||
if [ ! -z $params ]; then
|
if [ ! -z "$params" ]; then
|
||||||
partial_data="${partial_data},\"params\":\"${params}\""
|
partial_data="${partial_data},\"params\":\"${params}\""
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue