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();
21 $self->{'NAME'} = 'collegehumor';
22 $self->{'PATTERNS'} = ['(http://www.collegehumor.com/video:(\d+))',
23 '(http://www.collegehumor.com/video/(\d+))'];
26 $self->_prepare_parameters();
37 my $p = XML::Simple->new();
44 $metadata->{'URL'} = $url;
45 $metadata->{'ID'} = $2;
46 $metadata->{'TYPE'} = 'video';
47 $metadata->{'SOURCE'} = $self->{'NAME'};
48 $metadata->{'TITLE'} = undef;
49 $metadata->{'DLURL'} = undef;
51 # Get the XML file containing the video metadata
52 unless(defined($content = $self->simple_get(sprintf('http://www.collegehumor.com/moogaloop/video/%s', $2)))) {
53 $self->error('Could not download XML metadata');
57 unless(defined($t = $p->XMLin($content))) {
58 $self->error('Could not parse XML metadata');
62 $metadata->{'DLURL'} = $t->{'video'}->{'file'};
63 $metadata->{'TITLE'} = $t->{'video'}->{'caption'};
65 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
66 $self->error('Could not extract download URL and title');