//View Tip #701
Similar Tips
» Using Perl instead of Sed
» Using sed across multiple lines
» BBC Weather
» Print until no match
» Check low space

 

Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
YouTube is great, but the embedded flash player doesn't offer a lot in the way of customizing your viewing experience. There are quite a few options for downloading flv video files from YouTube, but adding the following function to your bashrc will let you stream them directly to your choice of media player.

function mtube {
  video_id=$(curl -s $1 | sed -n "/watch_fullscreen/s;.*\(video_id.\+\)&title.*;\1;p");
  mplayer -fs $(echo "http://youtube.com/get_video.php?$video_id");
}

This should work with any URL of the form http://www.youtube.com/watch?v=[video id here], for example:

mtube http://www.youtube.com/watch?v=evQ0QNi2CzA


View Comments »




Comments 

Add your comment

Comments are currently disabled
mplayer opens and shows the first frame of the movies but does not play. does this require a specific plug-in or package to be installed?
Posted 2009-04-20 17:27:50
tankmiche
Great function :)
if wanting to use wget instead of curl, try

"wget -O - $1" in the script above.
Posted 2009-04-20 19:57:50
According to Synaptic Package Manager,
mplayer isn't supported by Ubuntu.
Posted 2009-04-22 04:09:56
jacob schuschel
LMAO, nice youtube video.  I had to, and i got rolled.
Posted 2009-04-22 08:26:16

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit