1
1
mirror of https://github.com/ytdl-org/youtube-dl synced 2024-11-27 06:36:49 +01:00

[common] improve detection for video only formats and m3u8 manifest(fixes #11507)

This commit is contained in:
Remita Amine 2016-12-22 10:02:56 +01:00
parent f5a723a78a
commit a07588369f

View File

@ -1225,7 +1225,7 @@ class InfoExtractor(object):
'protocol': entry_protocol, 'protocol': entry_protocol,
'preference': preference, 'preference': preference,
}] }]
audio_groups = set() audio_in_video_stream = {}
last_info = {} last_info = {}
last_media = {} last_media = {}
for line in m3u8_doc.splitlines(): for line in m3u8_doc.splitlines():
@ -1235,10 +1235,11 @@ class InfoExtractor(object):
media = parse_m3u8_attributes(line) media = parse_m3u8_attributes(line)
media_type = media.get('TYPE') media_type = media.get('TYPE')
if media_type in ('VIDEO', 'AUDIO'): if media_type in ('VIDEO', 'AUDIO'):
group_id = media.get('GROUP-ID')
media_url = media.get('URI') media_url = media.get('URI')
if media_url: if media_url:
format_id = [] format_id = []
for v in (media.get('GROUP-ID'), media.get('NAME')): for v in (group_id, media.get('NAME')):
if v: if v:
format_id.append(v) format_id.append(v)
f = { f = {
@ -1251,12 +1252,15 @@ class InfoExtractor(object):
} }
if media_type == 'AUDIO': if media_type == 'AUDIO':
f['vcodec'] = 'none' f['vcodec'] = 'none'
audio_groups.add(media['GROUP-ID']) if group_id and not audio_in_video_stream.get(group_id):
audio_in_video_stream[group_id] = False
formats.append(f) 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
last_media = media last_media = media
if media_type == 'AUDIO' and group_id:
audio_in_video_stream[group_id] = True
elif line.startswith('#') or not line.strip(): elif line.startswith('#') or not line.strip():
continue continue
else: else:
@ -1300,7 +1304,7 @@ class InfoExtractor(object):
'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: if audio_in_video_stream.get(last_info.get('AUDIO')) is False:
# TODO: update acodec for for audio only formats with the same GROUP-ID # TODO: update acodec for for audio only formats with the same GROUP-ID
f['acodec'] = 'none' f['acodec'] = 'none'
formats.append(f) formats.append(f)