/usr/share/perl5/FlashVideo/Site/Tv4play.pm is in get-flash-videos 1.25.98-1.
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 | # Part of get-flash-videos. See get_flash_videos for copyright.
package FlashVideo::Site::Tv4play;
use strict;
use warnings;
use FlashVideo::Utils;
use List::Util qw(reduce);
our $VERSION = '0.03';
sub Version() { $VERSION;}
my $bitrate_index = {
high => 0,
medium => 1,
low => 2
};
sub find_video {
my ($self, $browser, $embed_url, $prefs) = @_;
my $video_id = ($embed_url =~ /video_id=([0-9]*)/)[0];
my $smi_url = "http://prima.tv4play.se/api/web/asset/$video_id/play?protocol=hls";
my $title = extract_title($browser);
$browser->get($smi_url);
my $content = from_xml($browser);
my $subtitle_url;
my $hls_m3u = "";
my $hls_base;
my @items;
if (ref $content->{items}->{item} eq 'HASH') {
push(@items, $content->{items}->{item});
} else {
@items = @{$content->{items}->{item}};
}
foreach my $item (@items) {
# Find playlist item
if ($item->{base} =~ m/.*\.m3u8/) {
$hls_m3u = $item->{url};
$hls_base = $item->{url};
# Strip to base
$hls_base =~ s/master\.m3u8//;
}
# Set subtitles
if ($item->{mediaFormat} eq 'smi') {
$subtitle_url = $item->{url};
}
}
if ($hls_m3u eq "") {die "No HLS stream found!"};
# Download subtitles
if ($prefs->{subtitles} == 1) {
if (not $subtitle_url eq '') {
$browser->get("$subtitle_url");
if (!$browser->success) {
info "Couldn't download subtitles: " . $browser->status_line;
} else {
my $srt_filename = title_to_filename($title, "srt");
info "Saving subtitles as " . $srt_filename;
open my $srt_fh, '>', $srt_filename
or die "Can't open subtitles file $srt_filename: $!";
binmode $srt_fh, ':utf8';
print $srt_fh $browser->content;
close $srt_fh;
}
} else {
info "No subtitles found";
}
}
my $filename = title_to_filename($title, "mp4");
return {
downloader => "hls",
flv => $filename,
args => { hls_url => $hls_m3u, prefs => $prefs }
};
}
1;
|