aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzakflash <zakflashvideo@gmail.com>2012-10-30 13:25:34 -0700
committerzakflash <zakflashvideo@gmail.com>2012-10-30 13:25:34 -0700
commit1538eeae6e6e3c2d7a3689bf4c0431d45759e1f0 (patch)
tree6189ad9e2974135570fe8f76297d3f8704dd852c
parent0e4fe5bccee04b5a651c62e1eaeb99fa180005c9 (diff)
parentb6f17738dea64ae5cd3f1a099b5e129e2edaef95 (diff)
downloadget-flash-videos-1538eeae6e6e3c2d7a3689bf4c0431d45759e1f0.tar.gz
Merge pull request #79 from karjonas/master
Svtplay: Gives ffmpeg command for unsupported video
-rw-r--r--lib/FlashVideo/Site/Svtplay.pm42
1 files changed, 41 insertions, 1 deletions
diff --git a/lib/FlashVideo/Site/Svtplay.pm b/lib/FlashVideo/Site/Svtplay.pm
index 56e3ec1..d64a356 100644
--- a/lib/FlashVideo/Site/Svtplay.pm
+++ b/lib/FlashVideo/Site/Svtplay.pm
@@ -26,8 +26,9 @@ sub find_video {
}
my $video_data = from_json($browser->content);
- my $bitrate = 0;
+ my $bitrate = -1;
my $rtmp_url;
+ my $m3u8 = "";
foreach my $video (@{ $video_data->{video}->{videoReferences} }) {
my $rate = int $video->{bitrate};
@@ -36,6 +37,45 @@ sub find_video {
$rtmp_url = $video->{url};
$bitrate = $rate;
}
+ if ($video->{url} =~ /.*\.m3u8/) {
+ $m3u8 = $video->{url};
+ }
+ }
+
+
+ # If we found an m3u8 file we generate the ffmpeg download command
+ if (!($m3u8 eq "")) {
+
+ $browser->get($m3u8);
+
+ if (!$browser->success) {
+ die "Couldn't download $m3u8: " . $browser->response->status_line;
+ }
+ my @lines = split(/\r?\n/, $browser->content);
+
+ $bitrate = -1;
+ my $video_url = "";
+ my $i = 0;
+
+ # Select highest bitrate available
+ foreach my $line (@lines) {
+ if ($line =~ /BANDWIDTH/) {
+ $line =~ /BANDWIDTH=([0-9]*),/;
+ my $this_rate = $1;
+
+ if($bitrate < $this_rate) {
+ $video_url = $lines[$i + 1];
+ $bitrate = $this_rate;
+ }
+ }
+ $i++;
+ }
+
+ my $flv_filename = title_to_filename($name, "mp4");
+ die "Not yet supported, use ffmpeg (http://ffmpeg.org/):\n\n"
+ . "ffmpeg -i '" . $video_url . "' -acodec copy -vcodec copy "
+ . "-absf aac_adtstoasc -f mp4 '" . $flv_filename . "'\n";
+
}
if ($prefs->{subtitles}) {