More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason - including blind stupidity.
My pleasure. I came back with few shorter youtube-downloaders.
For Perl>=5.14.1 use LWP;use URI::Escape;$u=\&uri_unescape;for(@ARGV){($y,$_)=m[(.+m)/.+[=/]([\w-]{11})] or next;&$u(($l=new LWP::UserAgent)->
get("$y/get_video_info?&video_id=$_")->content)=~/ap=url=([^&]+).+&title=([^&]+)/;$l->mirror(&$u($1),&$u("$2.mp4"=~y#+/# #r))}
For all versions of Perl use LWP;use URI::Escape;$u=\&uri_unescape;for(@ARGV){($y,$_)=m[(.+m)/.+[=/]([\w-]{11})] or next;&$u(($l=new LWP::UserAgent)->get(
"$y/get_video_info?&video_id=$_")->content)=~/ap=url=([^&]+).+&title=([^&]+)/;$l->mirror(&$u($1),do{$t=&$u($2);$t=~y#+/# #;"$t.mp4"})}
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!
Education Sponsors
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!
Update code (the above code has been broken by Youtube changes)
#!/usr/bin/perl -w
#################### Coded by TRIZEN under the GPL. ####################
use strict;use LWP::UserAgent;use URI::Escape('uri_unescape');my $lwp=new
LWP::UserAgent;foreach $_(@ARGV){($_) = m[[=/]?([\w-]{11})] or next;my $c
=uri_unescape(my $t = $lwp->get("http://www.youtube.com/get_video_info?&"
."video_id=$_&el=detailpage&ps=default&eurl=&gl=US&hl=en")->content);do{#
$t=uri_unescape $1;$t=~tr[\+/][ ];print"** $t\n"}if$t=~/&title=([^&]+)/;#
$lwp->show_progress(1),$lwp->mirror(uri_unescape(($c=~/map=url=([^&]+)&/)
),"$t.mp4")unless -e "$t.mp4";$lwp->show_progress(0)}# Youtube Downloader
Comment Responses
Awesome. Thanks for posting these!
My pleasure. I came back with few shorter youtube-downloaders.
For Perl>=5.14.1
use LWP;use URI::Escape;$u=\&uri_unescape;for(@ARGV){($y,$_)=m[(.+m)/.+[=/]([\w-]{11})] or next;&$u(($l=new LWP::UserAgent)->get("$y/get_video_info?&video_id=$_")->content)=~/ap=url=([^&]+).+&title=([^&]+)/;$l->mirror(&$u($1),&$u("$2.mp4"=~y#+/# #r))}
For all versions of Perl
use LWP;use URI::Escape;$u=\&uri_unescape;for(@ARGV){($y,$_)=m[(.+m)/.+[=/]([\w-]{11})] or next;&$u(($l=new LWP::UserAgent)->get("$y/get_video_info?&video_id=$_")->content)=~/ap=url=([^&]+).+&title=([^&]+)/;$l->mirror(&$u($1),do{$t=&$u($2);$t=~y#+/# #;"$t.mp4"})}
One-liner version:
perl -MLWP -MURI::Escape -e '$u=\&uri_unescape;for(@ARGV){($y,$_)=m[(.+m)/.+[=/]([\w-]{11})] or next;&$u(($l=new LWP::UserAgent)->get("$y/get_video_info?&video_id=$_")->content)=~/ap=url=([^&]+).+&title=([^&]+)/;$l->mirror(&$u($1),do{$t=&$u($2);$t=~y#+/# #;"$t.mp4"})}'Reply To This Comment