mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-22 16:57:40 +00:00
[extractor/common] detect media playlist in _extract_m3u8_formats
This commit is contained in:
parent
ab180fc648
commit
7f32e5dc35
1 changed files with 24 additions and 2 deletions
|
@ -1014,6 +1014,18 @@ class InfoExtractor(object):
|
||||||
return []
|
return []
|
||||||
m3u8_doc, urlh = res
|
m3u8_doc, urlh = res
|
||||||
m3u8_url = urlh.geturl()
|
m3u8_url = urlh.geturl()
|
||||||
|
# A Media Playlist Tag MUST NOT appear in a Master Playlist
|
||||||
|
# https://tools.ietf.org/html/draft-pantos-http-live-streaming-17#section-4.3.3
|
||||||
|
# The EXT-X-TARGETDURATION tag is REQUIRED for every M3U8 Media Playlists
|
||||||
|
# https://tools.ietf.org/html/draft-pantos-http-live-streaming-17#section-4.3.3.1
|
||||||
|
if '#EXT-X-TARGETDURATION' in m3u8_doc:
|
||||||
|
return [{
|
||||||
|
'url': m3u8_url,
|
||||||
|
'format_id': m3u8_id,
|
||||||
|
'ext': ext,
|
||||||
|
'protocol': entry_protocol,
|
||||||
|
'preference': preference,
|
||||||
|
}]
|
||||||
last_info = None
|
last_info = None
|
||||||
last_media = None
|
last_media = None
|
||||||
kv_rex = re.compile(
|
kv_rex = re.compile(
|
||||||
|
@ -1164,6 +1176,7 @@ class InfoExtractor(object):
|
||||||
formats = []
|
formats = []
|
||||||
rtmp_count = 0
|
rtmp_count = 0
|
||||||
http_count = 0
|
http_count = 0
|
||||||
|
m3u8_count = 0
|
||||||
|
|
||||||
videos = smil.findall(self._xpath_ns('.//video', namespace))
|
videos = smil.findall(self._xpath_ns('.//video', namespace))
|
||||||
for video in videos:
|
for video in videos:
|
||||||
|
@ -1203,8 +1216,17 @@ class InfoExtractor(object):
|
||||||
src_url = src if src.startswith('http') else compat_urlparse.urljoin(base, src)
|
src_url = src if src.startswith('http') else compat_urlparse.urljoin(base, src)
|
||||||
|
|
||||||
if proto == 'm3u8' or src_ext == 'm3u8':
|
if proto == 'm3u8' or src_ext == 'm3u8':
|
||||||
formats.extend(self._extract_m3u8_formats(
|
m3u8_formats = self._extract_m3u8_formats(
|
||||||
src_url, video_id, ext or 'mp4', m3u8_id='hls', fatal=False))
|
src_url, video_id, ext or 'mp4', m3u8_id='hls', fatal=False)
|
||||||
|
if len(m3u8_formats) == 1:
|
||||||
|
m3u8_count += 1
|
||||||
|
m3u8_formats[0].update({
|
||||||
|
'format_id': 'hls-%d' % (m3u8_count if bitrate is None else bitrate),
|
||||||
|
'tbr': bitrate,
|
||||||
|
'width': width,
|
||||||
|
'height': height,
|
||||||
|
})
|
||||||
|
formats.extend(m3u8_formats)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if src_ext == 'f4m':
|
if src_ext == 'f4m':
|
||||||
|
|
Loading…
Reference in a new issue