瀏覽代碼

[turner] fix downloading of secure hls formats using ffmpeg(closes #11358)(closes #11373)(closes #11800)

Remita Amine 8 年之前
父節點
當前提交
36fce54816
共有 2 個文件被更改,包括 15 次插入2 次删除
  1. 9 0
      youtube_dl/downloader/external.py
  2. 6 2
      youtube_dl/extractor/turner.py

+ 9 - 0
youtube_dl/downloader/external.py

@@ -199,6 +199,15 @@ class FFmpegFD(ExternalFD):
 
 
         args = [ffpp.executable, '-y']
         args = [ffpp.executable, '-y']
 
 
+        seekable = info_dict.get('_seekable')
+        if seekable is not None:
+            # setting -seekable prevents ffmpeg from guessing if the server
+            # supports seeking(by adding the header `Range: bytes=0-`), which
+            # can cause problems in some cases
+            # https://github.com/rg3/youtube-dl/issues/11800#issuecomment-275037127
+            # http://trac.ffmpeg.org/ticket/6125#comment:10
+            args += ['-seekable', '1' if seekable else '0']
+
         args += self._configuration_args()
         args += self._configuration_args()
 
 
         # start_time = info_dict.get('start_time') or 0
         # start_time = info_dict.get('start_time') or 0

+ 6 - 2
youtube_dl/extractor/turner.py

@@ -100,9 +100,13 @@ class TurnerBaseIE(AdobePassIE):
                 formats.extend(self._extract_smil_formats(
                 formats.extend(self._extract_smil_formats(
                     video_url, video_id, fatal=False))
                     video_url, video_id, fatal=False))
             elif ext == 'm3u8':
             elif ext == 'm3u8':
-                formats.extend(self._extract_m3u8_formats(
+                m3u8_formats = self._extract_m3u8_formats(
                     video_url, video_id, 'mp4',
                     video_url, video_id, 'mp4',
-                    m3u8_id=format_id or 'hls', fatal=False))
+                    m3u8_id=format_id or 'hls', fatal=False)
+                if '/secure/' in video_url and '?hdnea=' in video_url:
+                    for f in m3u8_formats:
+                        f['_seekable'] = False
+                formats.extend(m3u8_formats)
             elif ext == 'f4m':
             elif ext == 'f4m':
                 formats.extend(self._extract_f4m_formats(
                 formats.extend(self._extract_f4m_formats(
                     update_url_query(video_url, {'hdcore': '3.7.0'}),
                     update_url_query(video_url, {'hdcore': '3.7.0'}),