mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-02 01:02:48 +01:00
[YoutubeDL] Allow downloading multiple formats with ,
This commit is contained in:
parent
e2e5dae64d
commit
1de33fafd9
@ -809,28 +809,29 @@ def process_video_result(self, info_dict, download=True):
|
|||||||
if req_format in ('-1', 'all'):
|
if req_format in ('-1', 'all'):
|
||||||
formats_to_download = formats
|
formats_to_download = formats
|
||||||
else:
|
else:
|
||||||
# We can accept formats requested in the format: 34/5/best, we pick
|
for rfstr in req_format.split(','):
|
||||||
# the first that is available, starting from left
|
# We can accept formats requested in the format: 34/5/best, we pick
|
||||||
req_formats = req_format.split('/')
|
# the first that is available, starting from left
|
||||||
for rf in req_formats:
|
req_formats = rfstr.split('/')
|
||||||
if re.match(r'.+?\+.+?', rf) is not None:
|
for rf in req_formats:
|
||||||
# Two formats have been requested like '137+139'
|
if re.match(r'.+?\+.+?', rf) is not None:
|
||||||
format_1, format_2 = rf.split('+')
|
# Two formats have been requested like '137+139'
|
||||||
formats_info = (self.select_format(format_1, formats),
|
format_1, format_2 = rf.split('+')
|
||||||
self.select_format(format_2, formats))
|
formats_info = (self.select_format(format_1, formats),
|
||||||
if all(formats_info):
|
self.select_format(format_2, formats))
|
||||||
selected_format = {
|
if all(formats_info):
|
||||||
'requested_formats': formats_info,
|
selected_format = {
|
||||||
'format': rf,
|
'requested_formats': formats_info,
|
||||||
'ext': formats_info[0]['ext'],
|
'format': rf,
|
||||||
}
|
'ext': formats_info[0]['ext'],
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
selected_format = None
|
||||||
else:
|
else:
|
||||||
selected_format = None
|
selected_format = self.select_format(rf, formats)
|
||||||
else:
|
if selected_format is not None:
|
||||||
selected_format = self.select_format(rf, formats)
|
formats_to_download.append(selected_format)
|
||||||
if selected_format is not None:
|
break
|
||||||
formats_to_download = [selected_format]
|
|
||||||
break
|
|
||||||
if not formats_to_download:
|
if not formats_to_download:
|
||||||
raise ExtractorError('requested format not available',
|
raise ExtractorError('requested format not available',
|
||||||
expected=True)
|
expected=True)
|
||||||
|
@ -218,7 +218,7 @@ def _hide_login_info(opts):
|
|||||||
|
|
||||||
video_format.add_option('-f', '--format',
|
video_format.add_option('-f', '--format',
|
||||||
action='store', dest='format', metavar='FORMAT', default=None,
|
action='store', dest='format', metavar='FORMAT', default=None,
|
||||||
help='video format code, specify the order of preference using slashes: -f 22/17/18 . -f mp4 , -f m4a and -f flv are also supported. You can also use the special names "best", "bestvideo", "bestaudio", "worst", "worstvideo" and "worstaudio". By default, youtube-dl will pick the best quality.')
|
help='video format code, specify the order of preference using slashes: -f 22/17/18 . -f mp4 , -f m4a and -f flv are also supported. You can also use the special names "best", "bestvideo", "bestaudio", "worst", "worstvideo" and "worstaudio". By default, youtube-dl will pick the best quality. Use commas to download multiple audio formats, such as -f 136/137/mp4/bestvideo,140/m4a/bestaudio')
|
||||||
video_format.add_option('--all-formats',
|
video_format.add_option('--all-formats',
|
||||||
action='store_const', dest='format', help='download all available video formats', const='all')
|
action='store_const', dest='format', help='download all available video formats', const='all')
|
||||||
video_format.add_option('--prefer-free-formats',
|
video_format.add_option('--prefer-free-formats',
|
||||||
|
Loading…
Reference in New Issue
Block a user