From 1f643d78f852c9a7db8c73fa2cdaf04f7faf7eaf Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Tue, 26 Oct 2021 01:28:48 +0200 Subject: [PATCH] Add search endpoint to YT API utility script --- scripts/yt-api-helper.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/yt-api-helper.sh b/scripts/yt-api-helper.sh index 2a85922..3149f86 100755 --- a/scripts/yt-api-helper.sh +++ b/scripts/yt-api-helper.sh @@ -36,6 +36,7 @@ print_endpoints() echo "next" echo "next-continuation" echo "player" + echo "search" echo "resolve" } @@ -318,6 +319,19 @@ case $endpoint_option in 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) endpoint="navigation/resolve_url" @@ -344,7 +358,7 @@ if [ $interactive = true ] then case $endpoint_option in - browse|player) + browse|player|search) params=$(query_with_default "Enter optional parameters (base64-encoded protobuf)" "") if [ ! -z $params ]; then