1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-02-11 07:45:34 +08:00

extractor: youtube: Allow format number as output template.

Since many video formats map to the same extension, we get problems when
trying to download more than one format of the same audio/video with the
same ID.

This commit introduces a numeric version of the template of the video
format, which can help users who start downloading with a format (say, 720p
mp4), stop and then resume with another format (say, 360p mp4). See:

* http://bugs.debian.org/689294
* http://bugs.debian.org/643831

An output template like '%(title)s-%(id)s.%(format_num)s.%(ext)s' would,
unmistakenly, solve such problems.

This is also helpful to know what format was effectively downloaded when a
user expected something else (like, for instance, in issue #1578 or many of
its duplicates).

Another application of this is in separate downloads of audio video (as in
issue #1612).

Signed-off-by: Rogério Brito <rbrito@ime.usp.br>
This commit is contained in:
Rogério Brito 2013-10-18 18:30:57 -03:00
parent cce722b79c
commit 01b9d2b490

View File

@ -1485,7 +1485,9 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
# Extension # Extension
video_extension = self._video_extensions.get(format_param, 'flv') video_extension = self._video_extensions.get(format_param, 'flv')
video_format = '{0} - {1}{2}'.format(format_param if format_param else video_extension, numeric_video_format = '{0}'.format(format_param if format_param else video_extension)
video_format = '{0} - {1}{2}'.format(numeric_video_format,
self._video_dimensions.get(format_param, '???'), self._video_dimensions.get(format_param, '???'),
' ('+self._special_itags[format_param]+')' if format_param in self._special_itags else '') ' ('+self._special_itags[format_param]+')' if format_param in self._special_itags else '')
@ -1498,6 +1500,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
'title': video_title, 'title': video_title,
'ext': video_extension, 'ext': video_extension,
'format': video_format, 'format': video_format,
'format_num': numeric_video_format,
'thumbnail': video_thumbnail, 'thumbnail': video_thumbnail,
'description': video_description, 'description': video_description,
'player_url': player_url, 'player_url': player_url,