第一个参数应该是视频的 url。谁能向我指出为什么这不起作用?
我启动了 ubuntu 12.04 的这些 ec2 实例之一,它已经安装了 perl 和 wget http://cloud-images.ubuntu.com/precise/current/
该脚本源自这里: https ://calomel.org/youtube_wget.html
#!/usr/bin/perl
use strict;
use warnings;
## collect the URL from the command line argument
my $url = $ARGV[0] or die "\nError: You need to specify a YouTube URL\n\n";
## declare the user defined file name prefix
my $prefix = defined($ARGV[1]) ? $ARGV[1] : "";
## download the html code from the youtube page
my $html = `wget -Ncq -e "convert-links=off" --keep-session-cookies --save-cookies /dev/null --no-check-certificate "$url" -O-` or die "\nThere was a problem downloading the HTML file.\n\n";
## collect the title of the page to use as the file name
my ($title) = $html =~ m/<title>(.+)<\/title>/si;
$title =~ s/[^\w\d]+/_/g;
$title =~ s/_Youtube_//ig;
$title =~ s/^_//ig;
$title = lc ($title);
## collect the URL of the video and translate to the proper URL
my ($download) = $html =~ /url_encoded_fmt_stream_map([\s\S]+?)fallback_host/ig;
$download =~ s/\\u0026/\&/g;
$download =~ s/^\=url%3D//g;
$download =~ s/%25/%/g;
$download =~ s/%3A/:/g;
$download =~ s/%2F/\//g;
$download =~ s/%3F/\?/g;
$download =~ s/%3D/\=/g;
$download =~ s/%252C/%2C/g;
$download =~ s/%26/\?/g;
$download =~ s/%253A/\:/g;
## print the file name of the video
print "\n Download: $prefix$title.webm\n\n";
## Download the file.
my $error_code=system("wget -Ncq -e \"convert-links=off\" --load-cookies /dev/null --tries=50 --timeout=45 --no-check-certificate $download -O $prefix$title.webm &")>>8;
编辑 在我运行 perl 脚本后,视频没有下载(它的大小为 0 字节)
$ ./youtube_get_videos.pl http://www.youtube.com/watch?v=ejkm5uGoxs4
Download: radscorpion_youtube.webm
$ ls -lh
-rw-rw-r-- 1 ubuntu ubuntu 0 Sep 14 04:40 radscorpion_youtube.webm