1 # Grabber for collegehumor.com
3 # (c) 2007 by Ralf Ertzinger <ralf@camperquake.de>
4 # licensed under GNU GPL v2
6 package videosite::CollegeHumorGrabber;
8 use videosite::GrabberBase;
9 @ISA = qw(videosite::GrabberBase);
11 use videosite::HTMLHelper;
19 my $self = $class->SUPER::new(
20 NAME => 'collegehumor',
21 _SELFTESTURL => 'http://www.collegehumor.com/video/5635400/pixar-intro-parody',
22 _SELFTESTTITLE => 'Pixar Intro Parody',
23 PATTERNS => ['(http://www.collegehumor.com/video:(\d+))',
24 '(http://www.collegehumor.com/video/(\d+))'],
27 return bless($self, $class);
36 my $p = XML::Simple->new();
43 $metadata->{'URL'} = $url;
44 $metadata->{'ID'} = $2;
45 $metadata->{'TYPE'} = 'video';
46 $metadata->{'SOURCE'} = $self->{'NAME'};
47 $metadata->{'TITLE'} = undef;
48 $metadata->{'DLURL'} = undef;
50 # Get the XML file containing the video metadata
51 unless(defined($content = $self->simple_get(sprintf('http://www.collegehumor.com/moogaloop/video/%s', $2)))) {
52 $self->error('Could not download XML metadata');
56 unless(defined($t = $p->XMLin($content))) {
57 $self->error('Could not parse XML metadata');
61 $metadata->{'DLURL'} = $t->{'video'}->{'file'};
62 $metadata->{'TITLE'} = $t->{'video'}->{'caption'};
64 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
65 $self->error('Could not extract download URL and title');