Add search endpoint to YT API utility script

This commit is contained in:
Samantaz Fox 2021-10-26 01:28:48 +02:00
parent c47e949a81
commit 1f643d78f8

View file

@ -36,6 +36,7 @@ print_endpoints()
echo "next" echo "next"
echo "next-continuation" echo "next-continuation"
echo "player" echo "player"
echo "search"
echo "resolve" echo "resolve"
} }
@ -318,6 +319,19 @@ case $endpoint_option in
fi fi
;; ;;
search)
endpoint="youtubei/v1/search"
if [ $interactive = true ]; then
# Get search query, and escape backslashes and double quotes
query=$(
query_with_error "Enter your search query" "search term required" |
sed -e 's/\\/\\\\/g' -e 's/"/\\"/g'
)
partial_data="\"query\":\"${query}\""
fi
;;
resolve) resolve)
endpoint="navigation/resolve_url" endpoint="navigation/resolve_url"
@ -344,7 +358,7 @@ if [ $interactive = true ]
then then
case $endpoint_option in case $endpoint_option in
browse|player) 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