You're viewing a comment by Jake and its responses.
You're viewing a comment by Jake and its responses.
I am being sponsored by Syntress! They bought me an amazing dedicated server to run catonmat on. If you're looking web services, I highly recommend the Syntress guys!
I am being sponsored by A-Writer! If you ever need help with essay writing, look no further than A-Writer! They will help you with your writing in as quickly as 3 hours!
I love to read science books. They make my day and I get ideas for awesome blog posts, such as Busy Beaver, On Functors, Recursive Regular Expressions and many others.
Take a look at my
Amazon wish list, if you're curious about what I have planned reading next, and want to surprise me. :)
If you are interested in advertising on catonmat.net, contact me.
Free tools for coding on Vietstarsoft.com.
Programming homework help.


youtube must have changed its format since you posted this, since what was being returned did not have a t get variable. The t value was stored in the javascript of the page, so i used the following regex to get it:
which i found out after looking at a python script youtube-dl at http://www.arrakis.es/~rggi3/youtube-dl/ but while their downloader is very robust and object oriented, this one is quick and perl-like but gets the job done. Heres one that works as of february 2009:
use WWW::Mechanize; use Number::Bytes::Human qw(format_bytes); for (@ARGV) { s{http://|www\.|youtube\.com/|watch\?|v=|}{}g; $m = WWW::Mechanize->new; $m->get("http://www.youtube.com/watch?v=$_&gl=US&hl=en"); ($t) = $m->content =~ /, "t": "([^"]+)"/; open $f, "> $_.flv"; binmode $f; $m->get( "http://youtube.com/get_video?video_id=$_&t=$t", ':content_cb' => sub { ($c, $r) = @_; $b += length($c); if ($r->content_length) { printf STDERR "$_: %.2f%%: %s of %s \r", 100. * $b / $r->content_length, format_bytes($b), format_bytes($r->content_length); } print $f $c; }); $b = 0; print "\n"; close $f; }I combined some things that i liked from the previous posts (such as the callback).
Reply To This Comment