use strict;
my %preflist = (
- 'insane' => [38, 37, 22, 35, 18, 34, 6, 5],
- 'hd' => [37, 22, 35, 18, 34, 6, 5, 38],
- 'h264' => [18, 34, 37, 22, 35, 6, 5, 38],
- 'high' => [34, 35, 18, 37, 22, 6, 5, 38],
- 'normal' => [6, 5, 34, 35, 18, 22, 37, 38]);
+ 'insane' => [38, 37, 22, 35, 18, 34, 6, 5, 43],
+ 'hd' => [37, 22, 35, 18, 34, 6, 5, 38, 43],
+ 'h264' => [18, 34, 37, 22, 35, 6, 5, 38, 43],
+ 'high' => [34, 35, 18, 37, 22, 6, 5, 38, 43],
+ 'normal' => [6, 5, 34, 35, 18, 22, 37, 38, 43]);
my %videoformats = (
+ 43 => 'webm,360p',
+ 44 => 'webm,480p',
+ 45 => 'webm,720p',
38 => 'mp4,h264,4k',
37 => 'mp4,h264,1080p',
35 => 'flv,h264,large',
my $id;
my $res;
- my $url =~ m|$pattern|;
- my $url = $1;
- my $id = $2;
+ $url =~ m|$pattern|;
+ $url = $1;
+ $id = $2;
$self->debug("Matched id %s from pattern %s", $id, $pattern);
my $quality = $self->_getval('QUALITY');
my $metadata;
my $videourl;
- my $ua = $self->{_ua};
+ my $ua = $self->ua();
my $preflist;
my $r;
my $content;
$urls =~ s/%(..)/chr(hex($1))/ge;
$urls = { split /[\|,]/, $urls };
- foreach (keys(%{$urls})) {
- if (exists($videoformats{$_})) {
- $self->debug('Found URL for format %s (%s): %s', $_, $videoformats{$_}, $urls->{$_});
- } else {
- $self->error('Unknown format %s: %s', $_, $urls->{$_});
- }
- }
-
- foreach (@{$preflist}) {
- if (exists($urls->{$_})) {
- $self->debug("Selected URL with quality level %s", $_);
- $metadata->{'DLURL'} = $urls->{$_};
- last;
- }
- }
-
- $self->debug('URL found: %s', $metadata->{'DLURL'});
+ $self->__pick_url($urls, $preflist, $metadata);
$metadata->{'TITLE'} = $content->{'title'};
$metadata->{'TITLE'} =~ s/\+/ /g;
$metadata->{'TITLE'} =~ s/%(..)/chr(hex($1))/ge;
+ $metadata->{'TITLE'} = decode("utf8", $metadata->{'TITLE'});
$self->debug('Title found: %s', $metadata->{'TITLE'});
my $p;
my $e;
my $tag;
- my $ua = $self->{_ua};
+ my $ua = $self->ua();
my $r;
my $videourl;
my $quality = $self->_getval('QUALITY');
if (exists($tag->[1]->{'name'}) and ('title' eq $tag->[1]->{'name'})) {
$metadata->{'TITLE'} = $tag->[1]->{'content'};
# Convert HTML entities in the title. This is a bit convoluted.
- $metadata->{'TITLE'} = encode("utf8",
- decode_entities(
- decode("utf8", $metadata->{'TITLE'})));
+ $metadata->{'TITLE'} = decode_entities(
+ decode("utf8", $metadata->{'TITLE'}));
$self->debug('Title found: %s', $metadata->{'TITLE'});
}
}
if (%urls) {
- foreach (keys(%urls)) {
- if (exists($videoformats{$_})) {
- $self->debug('Found URL for format %s (%s): %s', $_, $videoformats{$_}, $urls{$_});
- } else {
- $self->error('Unknown format %s: %s', $_, $urls{$_});
- }
- }
-
- foreach (@{$preflist}) {
- if (exists($urls{$_})) {
- $self->debug("Selected URL with quality level %s", $_);
- $metadata->{'DLURL'} = $urls{$_};
- last;
- }
- }
-
- $self->debug('URL found: %s', $metadata->{'DLURL'});
+ $self->__pick_url(\%urls, $preflist, $metadata);
last SWF_ARGS;
}
} elsif ('div' eq $tag->[0]) {
return ($ua->get($videourl), $cookie);
}
+sub __pick_url {
+ my $self = shift;
+ my $urls = shift;
+ my $preflist = shift;
+ my $metadata = shift;
+
+ foreach (keys(%{$urls})) {
+ if (exists($videoformats{$_})) {
+ $self->debug('Found URL for format %s (%s): %s', $_, $videoformats{$_}, $urls->{$_});
+ } else {
+ $self->error('Unknown format %s: %s', $_, $urls->{$_});
+ }
+ }
+
+ foreach (@{$preflist}) {
+ if (exists($urls->{$_})) {
+ $self->debug("Selected URL with quality level %s", $_);
+ $metadata->{'DLURL'} = $urls->{$_};
+ last;
+ }
+ }
+
+ $self->debug('URL found: %s', $metadata->{'DLURL'});
+}
+
1;