Created
June 5, 2012 13:19
-
-
Save 013/2874931 to your computer and use it in GitHub Desktop.
Perl-Youtube-Downloader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use LWP::Simple; | |
my $url = $ARGV[0]; | |
die"URL Needed\n" unless defined $url; | |
$url =~ /[\?&]v=(.{11})/g; | |
my $video_id = $1; | |
my $info_url = "http://www.youtube.com/get_video_info?video_id=" . $video_id; | |
my $content = get $info_url; | |
$content = urldecode(urldecode(urldecode($content))); # That decoding.... | |
my @matches = $content =~ /url=(http:\/\/[^:]*);/g; | |
foreach(@matches) { | |
print "$_\n\n"; | |
} | |
sub urldecode { | |
my $str = shift; | |
$str =~ s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg; | |
$str =~ s/\+/ /g; | |
return $str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This no longer works, but was cool at the time.