[YoutubeDL] Raise syntax error for format selection expressions with multiple + opera...
authorSergey M․ <dstftw@gmail.com>
Wed, 13 Jan 2021 17:37:51 +0000 (00:37 +0700)
committerSergey M․ <dstftw@gmail.com>
Wed, 13 Jan 2021 17:38:31 +0000 (00:38 +0700)
test/test_YoutubeDL.py
youtube_dl/YoutubeDL.py

index 62f916d11eaffb9d5c7d24e4b15273e29bb16094..4d62ba1457ba107aad8d889d02bce55ac41eb37f 100644 (file)
@@ -464,6 +464,7 @@ class TestFormatSelection(unittest.TestCase):
         assert_syntax_error('+bestaudio')
         assert_syntax_error('bestvideo+')
         assert_syntax_error('/')
+        assert_syntax_error('bestvideo+bestvideo+bestaudio')
 
     def test_format_filtering(self):
         formats = [
index aaac149e9bb5f3c43b5b56140d9c812b5f45d0a4..3f1f03379d3eb5a5deee61a4ed10fdccaabc97db 100755 (executable)
@@ -1226,6 +1226,8 @@ class YoutubeDL(object):
                         group = _parse_format_selection(tokens, inside_group=True)
                         current_selector = FormatSelector(GROUP, group, [])
                     elif string == '+':
+                        if inside_merge:
+                            raise syntax_error('Unexpected "+"', start)
                         video_selector = current_selector
                         audio_selector = _parse_format_selection(tokens, inside_merge=True)
                         if not video_selector or not audio_selector: