You're viewing a comment by Trizen and its responses.

August 27, 2011, 21:31

New youtube downloader code based entirely on LWP::UserAgent

use strict;
use LWP::UserAgent;
use URI::Escape qw(uri_unescape);
my $lwp = LWP::UserAgent->new;
foreach $_ (@ARGV) {
s[.*[=/]?([\w-]{11}).*][$1];
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 =~ s[\+|/][ ]g; print $t. $/ } if $t =~ /&title=([^&]+)&/;
$lwp->show_progress(1), $lwp->mirror(uri_unescape(($c =~ /map=url=([^&]+)&/)), "$t.mp4")
unless -e "$t.mp4", $lwp->show_progress(0);
}

Reply To This Comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type first 3 letters of your name: (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.