@ISA = qw(videosite::GrabberBase);
use XML::Simple;
+use HTML::TokeParser;
use Data::Dumper;
use strict;
my $class = shift;
my $self = $class->SUPER::new(
NAME => 'sevenload',
- _SELFTESTURL => 'http://de.sevenload.com/videos/uqDvKzh-vilogo-TV-Spot',
- _SELFTESTTITLE => 'vilogo TV-Spot',
- PATTERNS => ['(http://(?:[-a-zA-Z0-9_.]+\.)*sevenload.com/videos/(\w+?)-.*)'],
+ _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);
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 = $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');