dotfiles/xhelperscripts/watch-video-select-format.sh

20 lines
413 B
Bash
Raw Normal View History

2020-04-02 20:25:41 +02:00
#!/usr/bin/env sh
select_format() {
youtube-dl -F "$1" | awk '/format code/{p=1;next}{if(p){print}}' |
cut -d ' ' -f 1 | tac | dmenu -i
}
watch="$1"
if [ -z $(printf "No\nYes" | dmenu -i) ]; then
$VIDEOPLAYER "$watch"
else
format=$(select_format "$watch")
if [ -n "$format" ]; then
$VIDEOPLAYER_SELECT_YTDLFORMAT$format "$watch"
else
$VIDEOPLAYER "$watch"
fi
fi