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

20 lines
413 B
Bash

#!/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