1 # (c) 2007 by Ralf Ertzinger <ralf@camperquake.de>
2 # licensed under GNU GPL v2
4 # Grabber for video.google.com
9 @ISA = qw(GrabberBase);
11 use LWP::Simple qw(!get);
19 my $self = $class->SUPER::new();
21 $self->{'NAME'} = 'google';
22 $self->{'PATTERNS'} = ['(http://video\.google\.com/videoplay\?docid=([-\d]+))'];
25 $self->_prepare_parameters();
42 $metadata->{'URL'} = $url;
43 $metadata->{'ID'} = $2;
44 $metadata->{'TYPE'} = 'video';
45 $metadata->{'SOURCE'} = $self->{'NAME'};
46 $metadata->{'TITLE'} = undef;
47 $metadata->{'DLURL'} = undef;
49 unless(defined($content = LWP::Simple::get(sprintf('http://video.google.com/videohosted?docid=%s', $2)))) {
50 $self->error('Could not download %s', $url);
54 $p = HTML::TokeParser->new(\$content);
57 if ($p->get_tag('title')) {
58 $metadata->{'TITLE'} = $p->get_text();
59 $metadata->{'TITLE'} =~ s/ - Google Video$//;
62 while ($e = $p->get_tag('a')) {
63 if ((exists($e->[1]{'id'})) and ('ipoddownloadlink' eq $e->[1]{'id'})) {
64 $metadata->{'DLURL'} = $e->[1]{'href'};
69 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
70 $self->error('Could not determine download URL');