+# Grabber for collegehumor.com
+#
+# (c) 2007 by Ralf Ertzinger <ralf@camperquake.de>
+# licensed under GNU GPL v2
+
package CollegeHumorGrabber;
use GrabberBase;
@ISA = qw(GrabberBase);
+use HTMLHelper;
use LWP::Simple qw(!get);
use XML::Simple;
use Data::Dumper;
my $content;
my $metadata = {};
my $p = XML::Simple->new();
+ my @accum;
my $t;
$url =~ m|$pattern|;
$metadata->{'URL'} = $url;
$metadata->{'ID'} = $2;
$metadata->{'TYPE'} = 'video';
- $metadata->{'SOURCE'} = 'collegehumor';
+ $metadata->{'SOURCE'} = $self->{'NAME'};
$metadata->{'TITLE'} = undef;
$metadata->{'DLURL'} = undef;
}
$metadata->{'DLURL'} = $t->{'video'}->{'file'};
- $metadata->{'TITLE'} = $t->{'video'}->{'caption'};
+
+ # The XML does not contain the full title of the video, for
+ # reasons possibly known to some jerk at CollegeHumor.
+ # So we'll have to parse the actual HTML, too.
+ $p = HTMLHelper->new();
+ unless(defined($content = $p->load(sprintf('http://www.collegehumor.com/video:%s', $2)))) {
+ $self->error('Could not download HTML');
+ return undef;
+ }
+
+ $t = $p->findnodes('meta[@name="title"]');
+ if (defined($t)) {
+ $metadata->{'TITLE'} = $t->{'content'};
+ }
unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
$self->error('Could not extract download URL and title');