在perl中使用WWW :: YouTube ::下载时出错

时间:2014-07-17 11:42:11

标签: perl youtube perl-module

我安装了WWW::YouTube::Download模块,用于下载YouTube视频并使用以下代码实现

#!C:\strawberry\perl\bin\perl.exe
use strict;
use warnings;
use WWW::YouTube::Download;

my $video_id="http://www.youtube.com/watch?feature=player_detailpage&list=TLNsL47LmBlyoKYinLLPSOkS7jlnl2V6u_&v=hzrGAZnMOMQ";
my $client = WWW::YouTube::Download->new;
$client->download($video_id);

my $video_url = $client->get_video_url($video_id);
my $title     = $client->get_title($video_id);     # maybe encoded utf8 string.
my $fmt       = $client->get_fmt($video_id);       # maybe highest quality.
my $suffix    = $client->get_suffix($video_id);    # maybe highest quality file suffix 

显示以下错误

JSON对象之后的垃圾,在C:/strawberry/perl/site/lib/www/YouTube/Download.pm第226行的字符偏移25151(在“;(function(){var en ...”之前)

如何解决错误?

1 个答案:

答案 0 :(得分:2)

$video_id的{​​{1}}参数应为download,而不是完整的视频URI。