X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=videosite%2FMyVideoGrabber.pm;h=7be3806a3254bacad619d8c5568834511212c6ae;hb=4d0981a45ce2331721226a9c3fc154a82d7fc7fa;hp=4b413870f1ab3ce47424799d259a3a769909ce76;hpb=911eeb36e674f916d08b04cd9c48bb33e96bf108;p=videosite.git diff --git a/videosite/MyVideoGrabber.pm b/videosite/MyVideoGrabber.pm index 4b41387..7be3806 100644 --- a/videosite/MyVideoGrabber.pm +++ b/videosite/MyVideoGrabber.pm @@ -8,7 +8,6 @@ package videosite::MyVideoGrabber; use videosite::GrabberBase; @ISA = qw(videosite::GrabberBase); -use LWP::Simple qw(!get); use HTML::Parser; use Data::Dumper; @@ -16,15 +15,13 @@ use strict; sub new { my $class = shift; - my $self = $class->SUPER::new(); + my $self = $class->SUPER::new( + NAME => 'myvideo', + PATTERNS => ['(http://(?:[-a-zA-Z0-9_.]+\.)*myvideo.de/watch/(\d+))'], + @_, + ); - $self->{'NAME'} = 'myvideo'; - $self->{'PATTERNS'} = ['(http://(?:[-a-zA-Z0-9_.]+\.)*myvideo.de/watch/(\d+))']; - - bless($self, $class); - $self->_prepare_parameters(); - - return $self; + return bless($self, $class); } sub _parse { @@ -48,14 +45,13 @@ sub _parse { $metadata->{'TITLE'} = undef; $metadata->{'DLURL'} = undef; - unless(defined($content = LWP::Simple::get(sprintf('http://www.myvideo.de/watch/%s', $2)))) { + unless(defined($content = $self->simple_get(sprintf('http://www.myvideo.de/watch/%s', $2)))) { $self->error('Could not download %s', $url); return undef; } $p->handler(start => \@accum, "tagname, attr"); - $p->handler(text => \@text, "text"); - $p->report_tags(qw(meta script)); + $p->report_tags(qw(meta link)); $p->utf8_mode(1); $p->parse($content); @@ -64,15 +60,23 @@ sub _parse { if ('meta' eq $e->[0]) { if ('title' eq $e->[1]->{'name'}) { $metadata->{'TITLE'} = $e->[1]->{'content'}; - $metadata->{'TITLE'} =~ s/\s*-\s*MyVideo$//; + $metadata->{'TITLE'} =~ s/\s+Video\s+-\s+\S+\s+-\s+MyVideo$//; + $self->debug("Found title: %s", $metadata->{'TITLE'}); + last; } } } # Look for the download URL - foreach $e (@text) { - if ($e->[0] =~ m|SWFObject\(.*?\.swf\?([^\&]+)\&|) { - $metadata->{'DLURL'} = $1; + foreach $e (@accum) { + if ('link' eq $e->[0]) { + if (exists($e->[1]->{'rel'}) and ('image_src' eq $e->[1]->{'rel'})) { + $metadata->{'DLURL'} = $e->[1]->{'href'}; + $metadata->{'DLURL'} =~ s,thumbs/[^/]*$,,; + $metadata->{'DLURL'} .= $metadata->{'ID'} . ".flv"; + $self->debug("Found URL: %s", $metadata->{'DLURL'}); + last; + } } }