#!/bin/sh
#
# and google keeps changing its API to fuck us up...

#curl "$(youtube-dl -g $*)" | mplayer -cache 1024 -
#mplayer -really-quiet -cache 1024 "$(youtube-dl -g $* | head -n1)"

# audio only, video only, both
case $1 in
	-a) shift 1; mplayer -quiet -cache 1024 "$(youtube-dl -g $* | sed -n '$p')" ;;
	-v) shift 1; mplayer -really-quiet -cache 1024 "$(youtube-dl -g $* | sed -n '1p')" ;;
	 *) youtube-dl "$*" -o - | mplayer -really-quiet -cache 1024 - ;;
esac