diff options
Diffstat (limited to 'test/test_YoutubeDL.py')
| -rw-r--r-- | test/test_YoutubeDL.py | 46 | 
1 files changed, 46 insertions, 0 deletions
diff --git a/test/test_YoutubeDL.py b/test/test_YoutubeDL.py index f0f5a8470..df8994b84 100644 --- a/test/test_YoutubeDL.py +++ b/test/test_YoutubeDL.py @@ -239,6 +239,52 @@ class TestFormatSelection(unittest.TestCase):          downloaded = ydl.downloaded_info_dicts[0]          self.assertEqual(downloaded['format_id'], 'vid-vcodec-dot') +    def test_format_selection_string_ops(self): +        formats = [ +            {'format_id': 'abc-cba', 'ext': 'mp4', 'url': TEST_URL}, +        ] +        info_dict = _make_result(formats) + +        # equals (=) +        ydl = YDL({'format': '[format_id=abc-cba]'}) +        ydl.process_ie_result(info_dict.copy()) +        downloaded = ydl.downloaded_info_dicts[0] +        self.assertEqual(downloaded['format_id'], 'abc-cba') + +        # does not equal (!=) +        ydl = YDL({'format': '[format_id!=abc-cba]'}) +        self.assertRaises(ExtractorError, ydl.process_ie_result, info_dict.copy()) + +        # starts with (^=) +        ydl = YDL({'format': '[format_id^=abc]'}) +        ydl.process_ie_result(info_dict.copy()) +        downloaded = ydl.downloaded_info_dicts[0] +        self.assertEqual(downloaded['format_id'], 'abc-cba') + +        # does not start with (!^=) +        ydl = YDL({'format': '[format_id!^=abc-cba]'}) +        self.assertRaises(ExtractorError, ydl.process_ie_result, info_dict.copy()) + +        # ends with ($=) +        ydl = YDL({'format': '[format_id$=cba]'}) +        ydl.process_ie_result(info_dict.copy()) +        downloaded = ydl.downloaded_info_dicts[0] +        self.assertEqual(downloaded['format_id'], 'abc-cba') + +        # does not end with (!$=) +        ydl = YDL({'format': '[format_id!$=abc-cba]'}) +        self.assertRaises(ExtractorError, ydl.process_ie_result, info_dict.copy()) + +        # contains (*=) +        ydl = YDL({'format': '[format_id*=-]'}) +        ydl.process_ie_result(info_dict.copy()) +        downloaded = ydl.downloaded_info_dicts[0] +        self.assertEqual(downloaded['format_id'], 'abc-cba') + +        # does not contain (!*=) +        ydl = YDL({'format': '[format_id!*=-]'}) +        self.assertRaises(ExtractorError, ydl.process_ie_result, info_dict.copy()) +      def test_youtube_format_selection(self):          order = [              '38', '37', '46', '22', '45', '35', '44', '18', '34', '43', '6', '5', '17', '36', '13',  | 
