MPlayer youtube script

From MultimediaWiki
Revision as of 02:38, 14 August 2008 by Elte (talk | contribs) (remove dependencies on grep, awk and tr - beautify a little)
Jump to navigation Jump to search

bash script for playing youtube videos

  1. save it as youtube.sh
  2. chmod +x youtube.sh
  3. place it somewhere in PATH (like /usr/local/bin )

Usage:

#!/bin/bash

if [ -z "$1" ]
then
    echo "usage: $0 <youtube-URL> [mplayer args]"
    exit
fi

url="$1"
shift

echo \"http://www.youtube.com/get_video?video_id=$(wget -q -O - "$url"          \
                                                   | sed -e '/fullscreenUrl/!d' \
                                                         -e 's/.*video_id=//'   \
                                                         -e 's/ /_/g'           \
                                                         -e "s/[';]//g"         \
                                                  )\"                           \
| xargs mplayer "$@"

created by enouf and n3kl and amphi

modified by Elte