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

[YoutubeDL] Raise syntax error for format selection expressions with multiple + operators (closes #27803)

This commit is contained in:
Sergey M․ 2021-01-14 00:37:51 +07:00
parent 7c2d18a13f
commit d81a213cfb
No known key found for this signature in database
GPG key ID: 2C393E0F18A9236D
2 changed files with 3 additions and 0 deletions

View file

@ -464,6 +464,7 @@ class TestFormatSelection(unittest.TestCase):
assert_syntax_error('+bestaudio') assert_syntax_error('+bestaudio')
assert_syntax_error('bestvideo+') assert_syntax_error('bestvideo+')
assert_syntax_error('/') assert_syntax_error('/')
assert_syntax_error('bestvideo+bestvideo+bestaudio')
def test_format_filtering(self): def test_format_filtering(self):
formats = [ formats = [

View file

@ -1226,6 +1226,8 @@ class YoutubeDL(object):
group = _parse_format_selection(tokens, inside_group=True) group = _parse_format_selection(tokens, inside_group=True)
current_selector = FormatSelector(GROUP, group, []) current_selector = FormatSelector(GROUP, group, [])
elif string == '+': elif string == '+':
if inside_merge:
raise syntax_error('Unexpected "+"', start)
video_selector = current_selector video_selector = current_selector
audio_selector = _parse_format_selection(tokens, inside_merge=True) audio_selector = _parse_format_selection(tokens, inside_merge=True)
if not video_selector or not audio_selector: if not video_selector or not audio_selector: