From 47320aeff77e29c9d4eef0815dce2799b7c8d3c0 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Thu, 29 Jul 2021 20:14:29 +0100 Subject: [PATCH] Bin: Allows yt to use pup instead of hq --- bin/.bin/yt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/.bin/yt b/bin/.bin/yt index c13986ef..1ff56bc1 100755 --- a/bin/.bin/yt +++ b/bin/.bin/yt @@ -3,8 +3,9 @@ # Requires: # * curl # * fzf -# * viu # * jq +# * hq +# * youtube-dl ttyecho(){ # Same as echo but always to tty echo "$@" > /dev/tty @@ -63,7 +64,14 @@ performSearch(){ # Returns the json object yt gives us local raw="$1" local url="https://www.youtube.com/results?search_query=$(urlencodespecial "$raw")" - curl -s "$url" | hq script data | grep 'ytInitialData' | head -n 1 | grep -o '{.*}' + if type -p hq > /dev/null; then + curl -s "$url" | hq script data | grep 'ytInitialData' | head -n 1 | grep -o '{.*}' + elif type -p pup > /dev/null; then + curl -s "$url" | pup script | grep 'ytInitialData' | head -n 1 | grep -o '{.*}' + else + echo "You need to install hq or pup" + fi + } extractVideoInfo(){