# (c) 2008 by Ralf Ertzinger # licensed under GNU GPL v2 # # Grabber for motherless.com # # written by Maximilian Rehkopf package videosite::MotherlessGrabber; use videosite::GrabberBase; @ISA = qw(videosite::GrabberBase); use HTML::TokeParser; use Data::Dumper; use strict; sub new { my $class = shift; my $self = $class->SUPER::new( NAME => 'motherless', _SELFTESTURL => 'http://motherless.com/4976432', _SELFTESTTITLE => 'Teen Masturbating In Shower', PATTERNS => ['(http://(?:[-a-zA-Z0-9_.]+\.)*motherless.com/([a-zA-Z0-9]+))'], @_, ); return bless($self, $class); } sub _parse { my $self = shift; my $url = shift; my $pattern = shift; my $ua = $self->ua(); my $content; my $metadata = {}; my $p; my $r; my $tag; my $dir; my $hash; $url =~ m|$pattern|; $url = $1; $metadata->{'URL'} = $url; $metadata->{'ID'} = $2; $metadata->{'TYPE'} = 'video'; $metadata->{'SOURCE'} = $self->{'NAME'}; $metadata->{'TITLE'} = undef; $metadata->{'DLURL'} = undef; unless(defined($content = $self->simple_get(sprintf("http://motherless.com/%s", $2), $ua))) { $self->error('Could not download page'); return undef; } $p = HTML::TokeParser->new(\$content); # Look for the title while ($tag = $p->get_tag('meta', 'script')) { if (('meta' eq $tag->[0]) and ($tag->[1]->{'name'}) and ($tag->[1]->{'name'} eq 'description')) { $metadata->{'TITLE'} = $tag->[1]->{'content'}; } elsif ('script' eq $tag->[0]) { my $t = $p->get_text(); if ($t =~ m|__fileurl = '(.*)';|) { $self->debug("Found fileurl: %s", $1); $metadata->{'DLURL'} = $1; } } } unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) { $self->error('Could not extract download URL and title'); return undef; } return $metadata; } 1;