# (c) 2007 by Ralf Ertzinger <ralf@camperquake.de>
# licensed under GNU GPL v2
-package CollegeHumorGrabber;
+package videosite::CollegeHumorGrabber;
-use GrabberBase;
-@ISA = qw(GrabberBase);
+use videosite::GrabberBase;
+@ISA = qw(videosite::GrabberBase);
-use HTMLHelper;
-use LWP::Simple qw(!get);
+use videosite::HTMLHelper;
use XML::Simple;
use Data::Dumper;
my $self = $class->SUPER::new();
$self->{'NAME'} = 'collegehumor';
- $self->{'PATTERNS'} = ['(http://www.collegehumor.com/video:(\d+))'];
+ $self->{_SELFTESTURL} = 'http://www.collegehumor.com/video/5635400/pixar-intro-parody';
+ $self->{_SELFTESTTITLE} = 'Pixar Intro Parody';
+ $self->{'PATTERNS'} = ['(http://www.collegehumor.com/video:(\d+))',
+ '(http://www.collegehumor.com/video/(\d+))'];
bless($self, $class);
$self->_prepare_parameters();
$metadata->{'DLURL'} = undef;
# Get the XML file containing the video metadata
- unless(defined($content = LWP::Simple::get(sprintf('http://www.collegehumor.com/moogaloop/video:%s', $2)))) {
+ unless(defined($content = $self->simple_get(sprintf('http://www.collegehumor.com/moogaloop/video/%s', $2)))) {
$self->error('Could not download XML metadata');
return undef;
}
}
$metadata->{'DLURL'} = $t->{'video'}->{'file'};
-
- # 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'};
- }
+ $metadata->{'TITLE'} = $t->{'video'}->{'caption'};
unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
$self->error('Could not extract download URL and title');