X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=videosite%2FSevenloadGrabber.pm;h=c36070a62390ac44447515dfc60b96eb7a35fb5a;hb=9257f7504905acaae56297cf7f1a479853e68fe7;hp=1c7a37ba8b5e22eb790f93ca0488718ad07ebba6;hpb=3bcd460c7694af376cfcf05c0bf2d16f5ca003ee;p=videosite.git diff --git a/videosite/SevenloadGrabber.pm b/videosite/SevenloadGrabber.pm index 1c7a37b..c36070a 100644 --- a/videosite/SevenloadGrabber.pm +++ b/videosite/SevenloadGrabber.pm @@ -9,21 +9,22 @@ use videosite::GrabberBase; @ISA = qw(videosite::GrabberBase); use XML::Simple; +use HTML::TokeParser; use Data::Dumper; use strict; sub new { my $class = shift; - my $self = $class->SUPER::new(); - - $self->{'NAME'} = 'sevenload'; - $self->{'PATTERNS'} = ['(http://(?:[-a-zA-Z0-9_.]+\.)*sevenload.com/videos/(\w+?)-.*)']; - - bless($self, $class); - $self->_prepare_parameters(); - - return $self; + my $self = $class->SUPER::new( + NAME => 'sevenload', + _SELFTESTURL => 'http://www.sevenload.com/videos/twins-one-guitar-5122ed655a1cb35c41003c64', + _SELFTESTTITLE => 'Twins one guitar', + PATTERNS => ['(http://(?:[-a-zA-Z0-9_.]+\.)*sevenload\.com/videos/.+-([[:alnum:]]+))'], + @_, + ); + + return bless($self, $class); } sub _parse { @@ -32,7 +33,7 @@ sub _parse { my $pattern = shift; my $content; my $metadata = {}; - my $p = XML::Simple->new(); + my $p; my $t; $url =~ m|$pattern|; @@ -45,24 +46,35 @@ sub _parse { $metadata->{'TITLE'} = undef; $metadata->{'DLURL'} = undef; + # Get the HTML page for the title + unless(defined($content = $self->simple_get($url))) { + $self->error('Could not download HTM'); + return undef; + } + + $p = HTML::TokeParser->new(\$content); + while ($t = $p->get_tag('meta')) { + if ('meta' eq $t->[0]) { + if (exists($t->[1]->{'property'}) and ($t->[1]->{'property'} eq 'og:title')) { + $metadata->{'TITLE'} = $t->[1]->{'content'}; + } + } + } + # Get the XML file containing the video metadata - unless(defined($content = $self->simple_get(sprintf('http://flash.sevenload.com/player?itemId=%s', $2)))) { + unless(defined($content = $self->simple_get(sprintf('http://player-services.sevenload.com/p/1/sp/1/playManifest/entryId/%s', $2)))) { $self->error('Could not download XML metadata'); return undef; } + $p = XML::Simple->new(); unless(defined($t = $p->XMLin($content, KeepRoot => 1))) { $self->error('Could not parse XML metadata'); return undef; } # Loop through the video streams - foreach(@{$t->{'playerconfig'}->{'playlists'}->{'playlist'}->{'items'}->{'item'}->{'videos'}->{'video'}->{'streams'}->{'stream'}}) { - if ($_->{'quality'} eq 'high') { - $metadata->{'DLURL'} = $_->{'locations'}->{'location'}->{'content'}; - } - } - $metadata->{'TITLE'} = $t->{'playerconfig'}->{'playlists'}->{'playlist'}->{'items'}->{'item'}->{'title'}; + $metadata->{'DLURL'} = $t->{'manifest'}->{'media'}->{'url'}; unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) { $self->error('Could not extract download URL and title');