Posts Tagged ‘perl’

Perl-Tube

April 28, 2008 - 8:22 pm No Comments
  1. #!/usr/bin/perl -w
  2. use WWW::Mechanize;
  3. $_ = shift @ARGV;
  4. s[http://|www\.|youtube\.com/|watch\?|v=|][]g;
  5. my $mech = WWW::Mechanize->new(); #creates a new object
  6. ($t = $mech->get("http://www.youtube.com/v/$_")->request->uri) =~ s/.*&t=(.+)/$1/; #code to give the right url for the video
  7. $mech->get("http://www.youtube.com/get_video?video_id=$_&t=$t", ":content_file" => "$_.flv" ); # code for download the video