1 # (c) 2008 by Ralf Ertzinger <ralf@camperquake.de>
2 # licensed under GNU GPL v2
4 # Grabber for snotr.com
6 package videosite::SnotrGrabber;
8 use videosite::GrabberBase;
9 @ISA = qw(videosite::GrabberBase);
11 use videosite::HTMLHelper;
18 my $self = $class->SUPER::new(
20 _SELFTESTURL => 'http://www.snotr.com/video/1836',
21 _SELFTESTTITLE => 'Brilliant thief',
22 PATTERNS => ['(http://(?:[-a-zA-Z0-9_.]+\.)*snotr\.com/video/(\d+))'],
25 return bless($self, $class);
34 my $p = videosite::HTMLHelper->new();
40 $metadata->{'URL'} = $url;
41 $metadata->{'ID'} = $2;
42 $metadata->{'TYPE'} = 'video';
43 $metadata->{'SOURCE'} = $self->{'NAME'};
44 $metadata->{'TITLE'} = undef;
45 $metadata->{'DLURL'} = undef;
47 # Get the HTML file containing the title
48 unless(defined($p->load(sprintf('http://www.snotr.com/video/%s', $2)))) {
49 $self->error('Could not download HTML');
53 $n = $p->findnodes('meta[@property="og:title"]');
55 $metadata->{'TITLE'} = $n->{'content'};
58 # The actual video URL is insultingly simple.
59 $metadata->{'DLURL'} = sprintf('http://videos.snotr.com/%s.flv', $metadata->{'ID'});
61 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
62 $self->error('Could not extract download URL and title');