about summary refs log tree commit diff
path: root/youtube_dl/extractor/common.py
diff options
context:
space:
mode:
authorRemita Amine <remitamine@gmail.com>2019-01-19 21:25:15 +0100
committerRemita Amine <remitamine@gmail.com>2019-01-19 21:25:15 +0100
commit2bfc1d9d68dec097fd8093dc0284dd0cd64beb2e (patch)
tree5dc09c86da58e09306105466c4c29e53302e761d /youtube_dl/extractor/common.py
parente2dd132f054df5b6c09b7c274752a77d8ba44f8d (diff)
downloadyoutube-dl-2bfc1d9d68dec097fd8093dc0284dd0cd64beb2e.tar.gz
youtube-dl-2bfc1d9d68dec097fd8093dc0284dd0cd64beb2e.tar.xz
youtube-dl-2bfc1d9d68dec097fd8093dc0284dd0cd64beb2e.zip
[extractor/common] imporove HLS video only format detection(closes #18923)
Diffstat (limited to 'youtube_dl/extractor/common.py')
-rw-r--r--youtube_dl/extractor/common.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py
index 9e7febcad..af621b74b 100644
--- a/youtube_dl/extractor/common.py
+++ b/youtube_dl/extractor/common.py
@@ -1596,6 +1596,7 @@ class InfoExtractor(object):
         # References:
         # 1. https://tools.ietf.org/html/draft-pantos-http-live-streaming-21
         # 2. https://github.com/rg3/youtube-dl/issues/12211
+        # 3. https://github.com/rg3/youtube-dl/issues/18923
 
         # We should try extracting formats only from master playlists [1, 4.3.4],
         # i.e. playlists that describe available qualities. On the other hand
@@ -1667,11 +1668,16 @@ class InfoExtractor(object):
             rendition = stream_group[0]
             return rendition.get('NAME') or stream_group_id
 
+        # parse EXT-X-MEDIA tags before EXT-X-STREAM-INF inorder to have the
+        # chance to detect video only formats when EXT-X-STREAM-INF tags
+        # precede EXT-X-MEDIA tags in HLS manifest such as [3].
+        for line in m3u8_doc.splitlines():
+            if line.startswith('#EXT-X-MEDIA:'):
+                extract_media(line)
+
         for line in m3u8_doc.splitlines():
             if line.startswith('#EXT-X-STREAM-INF:'):
                 last_stream_inf = parse_m3u8_attributes(line)
-            elif line.startswith('#EXT-X-MEDIA:'):
-                extract_media(line)
             elif line.startswith('#') or not line.strip():
                 continue
             else: