[downloader/hls] move check for m3u8 live streams to get_suitable_downloader
authorRemita Amine <remitamine@gmail.com>
Sat, 25 Mar 2017 22:06:33 +0000 (23:06 +0100)
committerRemita Amine <remitamine@gmail.com>
Sat, 25 Mar 2017 22:07:05 +0000 (23:07 +0100)
youtube_dl/downloader/__init__.py
youtube_dl/downloader/hls.py

index 16952e359bc19337dc4f8682061d169ff956e264..2e485df9dac09e197af6183ded3570e57805fad2 100644 (file)
@@ -43,6 +43,9 @@ def get_suitable_downloader(info_dict, params={}):
         if ed.can_download(info_dict):
             return ed
 
+    if protocol.startswith('m3u8') and info_dict.get('is_live'):
+        return FFmpegFD
+
     if protocol == 'm3u8' and params.get('hls_prefer_native') is True:
         return HlsFD
 
index 7534e4da5e3dbea6d3a304b9abcaf62e223b4c30..4989abce12ee236e5c528778e5b95f67d92e165e 100644 (file)
@@ -30,15 +30,6 @@ class HlsFD(FragmentFD):
 
     FD_NAME = 'hlsnative'
 
-    def _delegate_to_ffmpeg(self, filename, info_dict):
-        self.report_warning(
-            'hlsnative has detected features it does not support, '
-            'extraction will be delegated to ffmpeg')
-        fd = FFmpegFD(self.ydl, self.params)
-        for ph in self._progress_hooks:
-            fd.add_progress_hook(ph)
-        return fd.real_download(filename, info_dict)
-
     @staticmethod
     def can_download(manifest, info_dict):
         UNSUPPORTED_FEATURES = (
@@ -62,12 +53,10 @@ class HlsFD(FragmentFD):
         )
         check_results = [not re.search(feature, manifest) for feature in UNSUPPORTED_FEATURES]
         check_results.append(can_decrypt_frag or '#EXT-X-KEY:METHOD=AES-128' not in manifest)
+        check_results.append(not info_dict.get('is_live'))
         return all(check_results)
 
     def real_download(self, filename, info_dict):
-        if info_dict.get('is_live'):
-            return self._delegate_to_ffmpeg(filename, info_dict)
-
         man_url = info_dict['url']
         self.to_screen('[%s] Downloading m3u8 manifest' % self.FD_NAME)
 
@@ -79,7 +68,13 @@ class HlsFD(FragmentFD):
             if info_dict.get('extra_param_to_segment_url'):
                 self.report_error('pycrypto not found. Please install it.')
                 return False
-            return self._delegate_to_ffmpeg(filename, info_dict)
+            self.report_warning(
+                'hlsnative has detected features it does not support, '
+                'extraction will be delegated to ffmpeg')
+            fd = FFmpegFD(self.ydl, self.params)
+            for ph in self._progress_hooks:
+                fd.add_progress_hook(ph)
+            return fd.real_download(filename, info_dict)
 
         total_frags = 0
         for line in s.splitlines():