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+)(?:/.*)*)'],
24 return bless($self, $class);
33 my $p = XML::Simple->new();
39 $metadata->{'URL'} = $url;
40 $metadata->{'ID'} = $2;
41 $metadata->{'TYPE'} = 'video';
42 $metadata->{'SOURCE'} = $self->{'NAME'};
43 $metadata->{'TITLE'} = undef;
44 $metadata->{'DLURL'} = undef;
46 # Get the XML file containing the video metadata
47 unless(defined($content = $self->simple_get(sprintf('http://www.spikedhumor.com/playxml/%s/data.xml', $2)))) {
48 $self->error('Could not download XML metadata');
52 unless(defined($t = $p->XMLin($content, KeepRoot => 1))) {
53 $self->error('Could not parse XML metadata');
57 $metadata->{'DLURL'} = $t->{'playlist'}->{'listitem'}->{'url'};
58 $metadata->{'TITLE'} = $t->{'playlist'}->{'listitem'}->{'name'};
60 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
61 $self->error('Could not extract download URL and title');