1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-25 11:41:52 +00:00

[YoutubeDL] format spec: fix handling of '/' with ','

When using 'bestvideo/best,bestaudio', 'bestvideo/best' must be set as the current_selector (instead of appending it to the selectors), otherwise when it gets the ',' it would append 'None' to the selectors.
This commit is contained in:
Jaime Marquínez Ferrándiz 2015-07-04 21:30:26 +02:00
parent cf2ac6df68
commit f5f4a27a96
2 changed files with 9 additions and 2 deletions

View file

@ -253,6 +253,14 @@ class TestFormatSelection(unittest.TestCase):
downloaded = ydl.downloaded_info_dicts[0] downloaded = ydl.downloaded_info_dicts[0]
self.assertEqual(downloaded['format_id'], '38') self.assertEqual(downloaded['format_id'], '38')
info_dict = _make_result(list(formats_order), extractor='youtube')
ydl = YDL({'format': 'bestvideo/best,bestaudio'})
yie = YoutubeIE(ydl)
yie._sort_formats(info_dict['formats'])
ydl.process_ie_result(info_dict)
downloaded_ids = [info['format_id'] for info in ydl.downloaded_info_dicts]
self.assertEqual(downloaded_ids, ['137', '141'])
info_dict = _make_result(list(formats_order), extractor='youtube') info_dict = _make_result(list(formats_order), extractor='youtube')
ydl = YDL({'format': '(bestvideo[ext=mp4],bestvideo[ext=webm])+bestaudio'}) ydl = YDL({'format': '(bestvideo[ext=mp4],bestvideo[ext=webm])+bestaudio'})
yie = YoutubeIE(ydl) yie = YoutubeIE(ydl)

View file

@ -958,8 +958,7 @@ class YoutubeDL(object):
elif string == '/': elif string == '/':
first_choice = current_selector first_choice = current_selector
second_choice = _parse_format_selection(tokens, inside_choice=True) second_choice = _parse_format_selection(tokens, inside_choice=True)
current_selector = None current_selector = FormatSelector(PICKFIRST, (first_choice, second_choice), [])
selectors.append(FormatSelector(PICKFIRST, (first_choice, second_choice), []))
elif string == '[': elif string == '[':
if not current_selector: if not current_selector:
current_selector = FormatSelector(SINGLE, 'best', []) current_selector = FormatSelector(SINGLE, 'best', [])