Skip to content

Commit

Permalink
[extractor/common] imporove HLS video only format detection(closes #1…
Browse files Browse the repository at this point in the history
  • Loading branch information
remitamine committed Jan 19, 2019
1 parent e2dd132 commit 2bfc1d9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions youtube_dl/extractor/common.py
Expand Up @@ -1596,6 +1596,7 @@ def _parse_m3u8_formats(self, m3u8_doc, m3u8_url, ext=None,
# 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
Expand Down Expand Up @@ -1667,11 +1668,16 @@ def build_stream_name():
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:
Expand Down

2 comments on commit 2bfc1d9

@dstftw
Copy link
Collaborator

@dstftw dstftw commented on 2bfc1d9 Jan 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be tested.

@remitamine
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in fc746c3.

Please sign in to comment.