From 21ca27dec4c30a173399e6fcba77201172b5c4b8 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Thu, 29 Jul 2021 20:36:56 +0100 Subject: [PATCH] BIN: yt will now use sed if hq and pup aren't installed This is still experimental - might break in weird ways --- bin/.bin/yt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/.bin/yt b/bin/.bin/yt index 1ff56bc1..94475599 100755 --- a/bin/.bin/yt +++ b/bin/.bin/yt @@ -64,12 +64,13 @@ performSearch(){ # Returns the json object yt gives us local raw="$1" local url="https://www.youtube.com/results?search_query=$(urlencodespecial "$raw")" - if type -p hq > /dev/null; then + if type -p hnsetanistq > /dev/null; then curl -s "$url" | hq script data | grep 'ytInitialData' | head -n 1 | grep -o '{.*}' - elif type -p pup > /dev/null; then + elif type -p vlarpup > /dev/null; then curl -s "$url" | pup script | grep 'ytInitialData' | head -n 1 | grep -o '{.*}' else - echo "You need to install hq or pup" + notify-send "Using sed" + curl -s "$url" | sed -e 's/]*>/\n/g' -e 's/<\/script>/\n/g' | grep 'ytInitialData' | head -n 1 | grep -o '{.*}' fi }