#
# Grabber for sevenload.com/de
-package SevenloadGrabber;
+package videosite::SevenloadGrabber;
-use GrabberBase;
-@ISA = qw(GrabberBase);
+use videosite::GrabberBase;
+@ISA = qw(videosite::GrabberBase);
-use LWP::Simple qw(!get);
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/([^/]+)(?:/.*)*)'];
-
- 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 {
my $pattern = shift;
my $content;
my $metadata = {};
- my $p = XML::Simple->new();
+ my $p;
my $t;
$url =~ m|$pattern|;
$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 = LWP::Simple::get(sprintf('http://api.sevenload.com/api/player/id/%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;
}
- unless(defined($t = $p->XMLin($content))) {
+ $p = XML::Simple->new();
+ unless(defined($t = $p->XMLin($content, KeepRoot => 1))) {
$self->error('Could not parse XML metadata');
return undef;
}
- $metadata->{'DLURL'} = $t->{'item'}->{'video'}->{'url'};
- $metadata->{'TITLE'} = $t->{'item'}->{'title'};
+ # Loop through the video streams
+ $metadata->{'DLURL'} = $t->{'manifest'}->{'media'}->{'url'};
unless(defined($metadata->{'DLURL'}) && defined($metadata->{'TITLE'})) {
$self->error('Could not extract download URL and title');