monsieurvideo / get-flash-videos

Download or play videos from various Flash-based video hosting sites, without having to use the Flash player.
Apache License 2.0
240 stars 68 forks source link

Relative URLs in m3u8 #189

Open norenh opened 8 years ago

norenh commented 8 years ago

I have noticed that SVTPlay sometime use relative URLs in their m3u8-file which causes get_flash_videos to call ffmpeg with a invalid URI. The problem can be seen for the video below (for 5 more days): http://www.svtplay.se/video/7707206/ockupationen/ockupationen-sasong-1-avsnitt-1

I am neither familiar with get_flash_videos or the m3u8 format but I assume that the proper way to deal with it is in read_hls_playlist as the problem might exist at other sites as well. I made the following quick and dirty workaround to deal with it in my end:


diff --git a/lib/FlashVideo/Utils.pm b/lib/FlashVideo/Utils.pm
index d621f00..805b4f4 100644
--- a/lib/FlashVideo/Utils.pm
+++ b/lib/FlashVideo/Utils.pm
@@ -7,6 +7,7 @@ use base 'Exporter';
 use HTML::Entities;
 use HTML::TokeParser;
 use Encode;
+use URI;

 use constant FP_KEY => "Genuine Adobe Flash Player 001";
 use constant EXTENSIONS => qr/\.(?:flv|mp4|mov|wmv|avi|m4v)/i;
@@ -563,7 +564,7 @@ sub read_hls_playlist {
   foreach my $line (@lines) {
     if ($line =~ /BANDWIDTH/) {
       $line =~ /BANDWIDTH=([0-9]*)/;
-      $urltable{int($1)} = $lines[$i + 1];
+      $urltable{int($1)} = URI->new("$lines[$i + 1]")->abs("$url")->canonical();
     }
     $i++;
   }
-- 
karjonas commented 8 years ago

I cannot reproduce this problem. Please run this command and provide the output: ./get_flash_videos --debug http://www.svtplay.se/video/7707206/ockupationen/ockupationen-sasong-1-avsnitt-1

norenh commented 8 years ago

Oops, it seems like you are correct. It is not a problem with latest git and I totally missed reproducing with latest. I can now see that you ffmpeg is replaced with a hlsdownloader and that seems to deal with it properly, although the problem exist in latest released version (1.25.91).

Feel free to close this and thanks for the quick response!

karjonas commented 8 years ago

Great, thanks for reporting.