1 # (c) 2008 by Ralf Ertzinger <ralf@camperquake.de>
2 # licensed under GNU GPL v2
4 # Grabber for snotr.com
9 @ISA = qw(GrabberBase);
11 use LWP::Simple qw(!get);
19 my $self = $class->SUPER::new();
21 $self->{'NAME'} = 'snotr';
22 $self->{'PATTERNS'} = ['(http://(?:[-a-zA-Z0-9_.]+\.)*snotr\.com/video/(\d+))'];
25 $self->_prepare_parameters();
43 $metadata->{'URL'} = $url;
44 $metadata->{'ID'} = $2;
45 $metadata->{'TYPE'} = 'video';
46 $metadata->{'SOURCE'} = $self->{'NAME'};
47 $metadata->{'TITLE'} = undef;
48 $metadata->{'DLURL'} = undef;
50 # Get the HTML file containing the title
51 unless(defined($content = LWP::Simple::get(sprintf('http://www.snotr.com/video/%s', $2)))) {
52 $self->error('Could not download HTML');
56 $p = HTML::Parser->new(api_version => 3);
58 $p->handler(start => \@accum, "tagname, attr");
59 $p->report_tags(qw(meta));
63 # Look for the title in the meta tags
65 if ('meta' eq $t->[0]) {
66 if (exists($t->[1]->{'name'}) and ('title' eq $t->[1]->{'name'})) {
67 $metadata->{'TITLE'} = $t->[1]->{'content'};
73 # The actual video URL is insultingly simple.
74 $metadata->{'DLURL'} = sprintf('http://videos.snotr.com/%s.flv', $metadata->{'ID'});
76 unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
77 $self->error('Could not extract download URL and title');