Starts making yt work with yt-dlp

This commit is contained in:
Jonathan Hodgson 2021-11-16 10:45:15 +00:00
parent f5506ada59
commit 9d7c40372e

View file

@ -93,7 +93,7 @@ performSearch(){
} }
extractVideoInfo(){ extractVideoInfo(){
jq '..|.videoRenderer?' | sed '/^null$/d' | jq '..|.videoRenderer? | values' |
jq -r '{title: .title.runs[0].text, jq -r '{title: .title.runs[0].text,
channel: .longBylineText.runs[0].text, channel: .longBylineText.runs[0].text,
views: .shortViewCountText.simpleText, views: .shortViewCountText.simpleText,
@ -122,16 +122,21 @@ chooseQuality(){
else else
videoId="$(cat - | awk -F $'\u00a0' '{print $6}')" videoId="$(cat - | awk -F $'\u00a0' '{print $6}')"
fi fi
if useRofi; then if type -p yt-dlp > /dev/null; then
code="$( ( choices=" bb Best of Both
echo "bb Best of Both" $(yt-dlp "$videoID" -F --compat-options list-formats | sed -n '/format code/,$ p' | sed 1d)"
youtube-dl "$videoId" -F | sed -n '/format code/,$ p' | sed 1d;
) | rofi -dmenu -prompt "Quality " -m | cut -d ' ' -f 1 )"
else else
code="$( ( # 249 webm audio only tiny 50k , webm_dash container, opus @ 50k (48000Hz), 49.85MiB
echo "bb Best of Both" # 250 webm audio only tiny 60k , webm_dash container, opus @ 60k (48000Hz), 59.86MiB
youtube-dl "$videoId" -F | sed -n '/format code/,$ p' | sed 1d; # 251 webm audio only tiny 115k , webm_dash container, opus @115k (48000Hz), 113.94MiB
) | fzf --prompt "Quality " -m | cut -d ' ' -f 1 )" # 140 m4a audio only tiny 129k , m4a_dash container, mp4a.40.2@129k (44100Hz), 127.36MiB
choices=" bb Best of Both
$(youtube-dl "$videoId" -F | sed -n '/format code/,$ p' | sed 1d)"
fi
if useRofi; then
code="$( echo "$choices" | rofi -dmenu -prompt "Quality " -m | cut -d ' ' -f 1 )"
else
code="$( echo "$choices" | fzf --prompt "Quality " -m | cut -d ' ' -f 1 )"
fi fi
code="$(echo "$code" | tr '\n' '+' | sed 's/+$//')" code="$(echo "$code" | tr '\n' '+' | sed 's/+$//')"