summaryrefslogtreecommitdiff
path: root/etc/functions/youtube-watch
blob: 18e473a3594f7d45b0849bd3ad26e832270c7416 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## vim:ft=zsh
## Watch a youtube video
## requires youtube-dl and mplayer
## Usage: youtube-dl [-c] <video url> [mplayer options]
typeset video
typeset -i cache=0

while [[ $* == -* ]] {
	case $1 in
		-c) cache=1 ;;
		-|--) shift; break ;;
	esac
	shift
}

video=$1
shift

if ((cache)) {
	youtube-dl -o /tmp/youtube.flv $video
	mplayer $* /tmp/youtube.flv
} else {
	mplayer $* $(youtube-dl -gb $video)
}