/usr/share/perl5/FlashVideo/Site/Dailymotion.pm is in get-flash-videos 1.25~git2014.03.23-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | # Part of get-flash-videos. See get_flash_videos for copyright.
package FlashVideo::Site::Dailymotion;
use strict;
use FlashVideo::Utils;
use URI::Escape;
sub find_video {
my ($self, $browser, $embed_url, $prefs) = @_;
if ($browser->content =~ /content.is.not.available.for.your.country/i) {
error "Can't (yet) download this video because it's not available " .
"in your area";
exit 1;
}
$browser->allow_redirects;
$browser->content =~ /<h1[^>]*>(.*?)<\//;
my $filename = title_to_filename($1);
my $video;
if ($browser->content =~ /"video", "([^"]+)/) {
$video = uri_unescape($1);
}
if (!$video && $browser->content =~ /"sequence", *"([^"]+)/) {
my $data = json_unescape(uri_unescape($1));
my ($low) = $data =~ /"sdURL" *: *"([^"]+)"/i;
my ($high) = $data =~ /"hqURL" *: *"([^"]+)"/i;
if($data =~ /"videoTitle" *: *"([^"]+)"/i){
my $title = uri_unescape($1);
$title =~ s/\+/ /g;
$filename = title_to_filename($title);
}
if( $prefs->{quality} == 'high' && $high ){ $video = $high; }
elsif( $low ){ $video = $low; }
}
if(!$video) {
if ($embed_url !~ m!/swf/!) {
$browser->uri =~ m!video(?:%2F|/)([^_]+)!;
$embed_url = "http://www.dailymotion.com/swf/$1";
}
$browser->get($embed_url);
die "Must have Compress::Zlib for embedded Dailymotion videos\n"
unless eval { require Compress::Zlib; };
my $data = Compress::Zlib::uncompress(substr $browser->content, 8);
$data =~ /\{\{video\}\}\{\{(.*?)\}\}/;
$video = $1;
if($data =~ /videotitle=([^&]+)/) {
$filename = title_to_filename(uri_unescape($1));
}
}
if(!$video) {
# Sometimes dailymotion actually embeds another site, so check that..
my($package, $possible_url) = FlashVideo::URLFinder->find_package($browser->uri, $browser);
if($package ne __PACKAGE__) {
return $package->find_video($browser, $possible_url, $prefs);
}
}
die "Couldn't find video parameter." unless $video;
my @streams;
for(split /\|\|/, $video) {
my($path, $type) = split /@@/;
my($width, $height) = $path =~ /(\d+)x(\d+)/;
push @streams, {
width => $width,
height => $height,
url => URI->new_abs($path, $browser->uri)->as_string
};
}
my $url = (sort { $b->{width} <=> $a->{width} } @streams)[0]->{url};
return $url, $filename;
}
1;
|