|
|
@ -1047,6 +1047,8 @@ class YoutubeDL(object):
|
|
|
|
if not formats:
|
|
|
|
if not formats:
|
|
|
|
raise ExtractorError('No video formats found!')
|
|
|
|
raise ExtractorError('No video formats found!')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
formats_dict = {}
|
|
|
|
|
|
|
|
|
|
|
|
# We check that all the formats have the format and format_id fields
|
|
|
|
# We check that all the formats have the format and format_id fields
|
|
|
|
for i, format in enumerate(formats):
|
|
|
|
for i, format in enumerate(formats):
|
|
|
|
if 'url' not in format:
|
|
|
|
if 'url' not in format:
|
|
|
@ -1054,6 +1056,18 @@ class YoutubeDL(object):
|
|
|
|
|
|
|
|
|
|
|
|
if format.get('format_id') is None:
|
|
|
|
if format.get('format_id') is None:
|
|
|
|
format['format_id'] = compat_str(i)
|
|
|
|
format['format_id'] = compat_str(i)
|
|
|
|
|
|
|
|
format_id = format['format_id']
|
|
|
|
|
|
|
|
if format_id not in formats_dict:
|
|
|
|
|
|
|
|
formats_dict[format_id] = []
|
|
|
|
|
|
|
|
formats_dict[format_id].append(format)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Make sure all formats have unique format_id
|
|
|
|
|
|
|
|
for format_id, ambiguous_formats in formats_dict.items():
|
|
|
|
|
|
|
|
if len(ambiguous_formats) > 1:
|
|
|
|
|
|
|
|
for i, format in enumerate(ambiguous_formats):
|
|
|
|
|
|
|
|
format['format_id'] = '%s-%d' % (format_id, i)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for i, format in enumerate(formats):
|
|
|
|
if format.get('format') is None:
|
|
|
|
if format.get('format') is None:
|
|
|
|
format['format'] = '{id} - {res}{note}'.format(
|
|
|
|
format['format'] = '{id} - {res}{note}'.format(
|
|
|
|
id=format['format_id'],
|
|
|
|
id=format['format_id'],
|
|
|
|