1 # (c) 2007 by Ralf Ertzinger <ralf@camperquake.de>
2 # licensed under GNU GPL v2
4 # Grabber for spikedhumor.com
6 package videosite::SpikedHumorGrabber;
8 use videosite::GrabberBase;
9 @ISA = qw(videosite::GrabberBase);
18 my $self = $class->SUPER::new(
19 NAME => 'spikedhumor',
20 PATTERNS => ['(http://(?:[-a-zA-Z0-9_.]+\.)*spikedhumor.com/articles/(\d+)(?:/.*)*)'],
23 return bless($self, $class);
32 my $p = XML::Simple->new();
38 $metadata->{'URL'} = $url;
39 $metadata->{'ID'} = $2;
40 $metadata->{'TYPE'} = 'video';
41 $metadata->{'SOURCE'} = $self->{'NAME'};
42 $metadata->{'TITLE'} = undef;
43 $metadata->{'DLURL'} = undef;
45 # Get the XML file containing the video metadata
46 unless(defined($content = $self->simple_get(sprintf('http://www.spikedhumor.com/playxml/%s/data.xml', $2)))) {
47 $self->error('Could not download XML metadata');
51 unless(defined($t = $p->XMLin($content, KeepRoot => 1))) {
52 $self->error('Could not parse XML metadata');
56 $metadata->{'DLURL'} = $t->{'playlist'}->{'listitem'}->{'url'};
57 $metadata->{'TITLE'} = $t->{'playlist'}->{'listitem'}->{'name'};
59 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
60 $self->error('Could not extract download URL and title');