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();
20 $self->{'NAME'} = 'spikedhumor';
21 $self->{'PATTERNS'} = ['(http://(?:[-a-zA-Z0-9_.]+\.)*spikedhumor.com/articles/(\d+)(?:/.*)*)'];
24 $self->_prepare_parameters();
35 my $p = XML::Simple->new();
41 $metadata->{'URL'} = $url;
42 $metadata->{'ID'} = $2;
43 $metadata->{'TYPE'} = 'video';
44 $metadata->{'SOURCE'} = $self->{'NAME'};
45 $metadata->{'TITLE'} = undef;
46 $metadata->{'DLURL'} = undef;
48 # Get the XML file containing the video metadata
49 unless(defined($content = $self->simple_get(sprintf('http://www.spikedhumor.com/playxml/%s/data.xml', $2)))) {
50 $self->error('Could not download XML metadata');
54 unless(defined($t = $p->XMLin($content, KeepRoot => 1))) {
55 $self->error('Could not parse XML metadata');
59 $metadata->{'DLURL'} = $t->{'playlist'}->{'listitem'}->{'url'};
60 $metadata->{'TITLE'} = $t->{'playlist'}->{'listitem'}->{'name'};
62 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
63 $self->error('Could not extract download URL and title');