Dotfiles/bin/.bin/dmenu/open-youtube
Jonathan Hodgson ffcb63d5a5 Adds the ability to use multiple sources for opening youtube
An entry called best of both will now be in the list that will stream
the best audio and the best video

There is also now the ability to select a video only and an audio only
track and they will be combined
2020-05-25 12:02:56 +01:00

25 lines
589 B
Bash
Executable file

#!/bin/bash
isxclient=$( readlink /dev/fd/2 | grep -q 'tty' && [[ -n $DISPLAY ]] ; echo $? )
if [[ ! -t 2 || $isxclient == "0" ]]; then
DMENU="rofi -dmenu -p"
else
DMENU="fzf --prompt"
fi
url="$1"
if [ -z "$url" ]; then
url=$($DMENU 'URL')
fi
code=$( ( youtube-dl "$url" -F; echo "bb Best of both") | sed -n '/format code/,$ p' | tail -n +2 | $DMENU "Quality " -m | awk '{print $1}')
code="$(echo "$code" | tr '\n' '+' | sed 's/+$//')"
notify-send "$code"
case "$code" in
"bb") mpv "$url" --ytdl-format="bestvideo+bestaudio" ;;
*) mpv "$url" --ytdl-format="$code"
esac