Bin: Allows yt to use pup instead of hq
This commit is contained in:
parent
6c09cc5c39
commit
7775ec7539
1 changed files with 10 additions and 2 deletions
12
bin/.bin/yt
12
bin/.bin/yt
|
@ -3,8 +3,9 @@
|
||||||
# Requires:
|
# Requires:
|
||||||
# * curl
|
# * curl
|
||||||
# * fzf
|
# * fzf
|
||||||
# * viu
|
|
||||||
# * jq
|
# * jq
|
||||||
|
# * hq
|
||||||
|
# * youtube-dl
|
||||||
ttyecho(){
|
ttyecho(){
|
||||||
# Same as echo but always to tty
|
# Same as echo but always to tty
|
||||||
echo "$@" > /dev/tty
|
echo "$@" > /dev/tty
|
||||||
|
@ -63,7 +64,14 @@ performSearch(){
|
||||||
# Returns the json object yt gives us
|
# Returns the json object yt gives us
|
||||||
local raw="$1"
|
local raw="$1"
|
||||||
local url="https://www.youtube.com/results?search_query=$(urlencodespecial "$raw")"
|
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(){
|
extractVideoInfo(){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue