mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-23 02:25:11 +00:00
[common] recognize hls manifests that contain video only formats(#11394)
This commit is contained in:
parent
0d7d9f9404
commit
8821a718cf
3 changed files with 10 additions and 13 deletions
|
@ -283,11 +283,6 @@ def _real_extract(self, url):
|
||||||
formats = self._extract_m3u8_formats(re.sub(r'/([^/]+)/[^/?]+\.m3u8', r'/\1/\1.m3u8', m3u8_url), video_id, 'mp4', fatal=False)
|
formats = self._extract_m3u8_formats(re.sub(r'/([^/]+)/[^/?]+\.m3u8', r'/\1/\1.m3u8', m3u8_url), video_id, 'mp4', fatal=False)
|
||||||
if len(formats) < 2:
|
if len(formats) < 2:
|
||||||
formats = self._extract_m3u8_formats(m3u8_url, video_id, 'mp4')
|
formats = self._extract_m3u8_formats(m3u8_url, video_id, 'mp4')
|
||||||
# Despite metadata in m3u8 all video+audio formats are
|
|
||||||
# actually video-only (no audio)
|
|
||||||
for f in formats:
|
|
||||||
if f.get('acodec') != 'none' and f.get('vcodec') != 'none':
|
|
||||||
f['acodec'] = 'none'
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
info = {
|
info = {
|
||||||
|
|
|
@ -1224,6 +1224,7 @@ def _extract_m3u8_formats(self, m3u8_url, video_id, ext=None,
|
||||||
'protocol': entry_protocol,
|
'protocol': entry_protocol,
|
||||||
'preference': preference,
|
'preference': preference,
|
||||||
}]
|
}]
|
||||||
|
audio_groups = set()
|
||||||
last_info = {}
|
last_info = {}
|
||||||
last_media = {}
|
last_media = {}
|
||||||
for line in m3u8_doc.splitlines():
|
for line in m3u8_doc.splitlines():
|
||||||
|
@ -1239,15 +1240,18 @@ def _extract_m3u8_formats(self, m3u8_url, video_id, ext=None,
|
||||||
for v in (media.get('GROUP-ID'), media.get('NAME')):
|
for v in (media.get('GROUP-ID'), media.get('NAME')):
|
||||||
if v:
|
if v:
|
||||||
format_id.append(v)
|
format_id.append(v)
|
||||||
formats.append({
|
f = {
|
||||||
'format_id': '-'.join(format_id),
|
'format_id': '-'.join(format_id),
|
||||||
'url': format_url(media_url),
|
'url': format_url(media_url),
|
||||||
'language': media.get('LANGUAGE'),
|
'language': media.get('LANGUAGE'),
|
||||||
'vcodec': 'none' if media_type == 'AUDIO' else None,
|
|
||||||
'ext': ext,
|
'ext': ext,
|
||||||
'protocol': entry_protocol,
|
'protocol': entry_protocol,
|
||||||
'preference': preference,
|
'preference': preference,
|
||||||
})
|
}
|
||||||
|
if media_type == 'AUDIO':
|
||||||
|
f['vcodec'] = 'none'
|
||||||
|
audio_groups.add(media['GROUP-ID'])
|
||||||
|
formats.append(f)
|
||||||
else:
|
else:
|
||||||
# When there is no URI in EXT-X-MEDIA let this tag's
|
# When there is no URI in EXT-X-MEDIA let this tag's
|
||||||
# data be used by regular URI lines below
|
# data be used by regular URI lines below
|
||||||
|
@ -1295,6 +1299,9 @@ def _extract_m3u8_formats(self, m3u8_url, video_id, ext=None,
|
||||||
'abr': abr,
|
'abr': abr,
|
||||||
})
|
})
|
||||||
f.update(parse_codecs(last_info.get('CODECS')))
|
f.update(parse_codecs(last_info.get('CODECS')))
|
||||||
|
if last_info.get('AUDIO') in audio_groups:
|
||||||
|
# TODO: update acodec for for audio only formats with the same GROUP-ID
|
||||||
|
f['acodec'] = 'none'
|
||||||
formats.append(f)
|
formats.append(f)
|
||||||
last_info = {}
|
last_info = {}
|
||||||
last_media = {}
|
last_media = {}
|
||||||
|
|
|
@ -78,11 +78,6 @@ def _real_extract(self, url):
|
||||||
m3u8_formats = self._extract_m3u8_formats(
|
m3u8_formats = self._extract_m3u8_formats(
|
||||||
format_url, display_id, 'mp4',
|
format_url, display_id, 'mp4',
|
||||||
m3u8_id='hls', fatal=False)
|
m3u8_id='hls', fatal=False)
|
||||||
# Despite metadata in m3u8 all video+audio formats are
|
|
||||||
# actually video-only (no audio)
|
|
||||||
for f in m3u8_formats:
|
|
||||||
if f.get('acodec') != 'none' and f.get('vcodec') != 'none':
|
|
||||||
f['acodec'] = 'none'
|
|
||||||
formats.extend(m3u8_formats)
|
formats.extend(m3u8_formats)
|
||||||
else:
|
else:
|
||||||
formats.append({
|
formats.append({
|
||||||
|
|
Loading…
Reference in a new issue