/usr/share/perl5/FlashVideo/Site/Nfb.pm is in get-flash-videos 1.25~git2012.06.27-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 89 | # Part of get-flash-videos. See get_flash_videos for copyright.
# Except the CCR bits, thanks to Fogerty for those.
package FlashVideo::Site::Nfb;
use strict;
use FlashVideo::Utils;
sub find_video {
my ($self, $browser, $embed_url, $prefs) = @_;
# get the flash player url to use as the referer and the url of the config file
my($refer, $cURL) = $browser->content =~ /<link rel="video_src" href="([^?]+)\?configURL=([^&]+)&/;
# get the config file with the stream info
$browser->post(
$cURL,
"X-NFB-Referer" => $refer,
Content_Type => "application/x-www-form-urlencoded",
Content => "getConfig=true",
);
if (!$browser->success) {
die "Getting config info failed: " . $browser->response->status_line();
}
my $xml = from_xml($browser->content);
# find the video stream info
my $media;
foreach (@{$xml->{player}->{stream}->{media}}) {
if ($_->{"type"} eq "video") {
$media = $_;
last;
}
}
my $title = $media->{title};
# The video might be available in different qualities. Try to download the
# highest quality by default. Qualities in descending order: M1M, M415K, M48K.
my @assets = sort { _get_quality_from_url($b->{default}->{url}) <=> _get_quality_from_url($a->{default}->{url}) }
(@{$media->{assets}->{asset}});
if (!@assets) {
die "Couldn't find any streams in the config file";
}
my $quality = $prefs->{quality};
my $asset;
if ($quality eq "high") {
$asset = $assets[0];
} elsif ($quality eq "low") {
$asset = $assets[-1];
} elsif ($quality eq "medium") {
if (scalar(@assets) > 1) {
$asset = $assets[1];
} else {
$asset = $assets[0];
}
} else {
die "Unknown quality setting";
}
my $rtmp_url = $asset->{default}->{streamerURI};
my($host, $app) = $rtmp_url =~ m'rtmp://([^/]+)/(\w+)';
my $playpath = $asset->{default}->{url};
return {
flv => title_to_filename($title),
rtmp => $rtmp_url,
app => $app,
playpath => $playpath
};
}
sub _get_quality_from_url {
my($url) = @_;
if ($url =~ m'/streams/[A-Z](\d+)([A-Z])') {
my ($size, $units) = ($1, $2);
$size *= 1024 if $units eq 'M';
return $size;
}
}
1;
|