mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-30 22:25:19 +00:00 
			
		
		
		
	[utils] Add support for quoted string literals in --match-filter (closes #8050, closes #12142, closes #12144)
This commit is contained in:
		| @@ -1,4 +1,5 @@ | ||||
| #!/usr/bin/env python | ||||
| # coding: utf-8 | ||||
|  | ||||
| from __future__ import unicode_literals | ||||
|  | ||||
| @@ -606,6 +607,8 @@ class TestYoutubeDL(unittest.TestCase): | ||||
|             'duration': 30, | ||||
|             'filesize': 10 * 1024, | ||||
|             'playlist_id': '42', | ||||
|             'uploader': "變態妍字幕版 太妍 тест", | ||||
|             'creator': "тест ' 123 ' тест--", | ||||
|         } | ||||
|         second = { | ||||
|             'id': '2', | ||||
| @@ -616,6 +619,7 @@ class TestYoutubeDL(unittest.TestCase): | ||||
|             'description': 'foo', | ||||
|             'filesize': 5 * 1024, | ||||
|             'playlist_id': '43', | ||||
|             'uploader': "тест 123", | ||||
|         } | ||||
|         videos = [first, second] | ||||
|  | ||||
| @@ -656,6 +660,26 @@ class TestYoutubeDL(unittest.TestCase): | ||||
|         res = get_videos(f) | ||||
|         self.assertEqual(res, ['1']) | ||||
|  | ||||
|         f = match_filter_func('uploader = "變態妍字幕版 太妍 тест"') | ||||
|         res = get_videos(f) | ||||
|         self.assertEqual(res, ['1']) | ||||
|  | ||||
|         f = match_filter_func('uploader != "變態妍字幕版 太妍 тест"') | ||||
|         res = get_videos(f) | ||||
|         self.assertEqual(res, ['2']) | ||||
|  | ||||
|         f = match_filter_func('creator = "тест \' 123 \' тест--"') | ||||
|         res = get_videos(f) | ||||
|         self.assertEqual(res, ['1']) | ||||
|  | ||||
|         f = match_filter_func("creator = 'тест \\' 123 \\' тест--'") | ||||
|         res = get_videos(f) | ||||
|         self.assertEqual(res, ['1']) | ||||
|  | ||||
|         f = match_filter_func(r"creator = 'тест \' 123 \' тест--' & duration > 30") | ||||
|         res = get_videos(f) | ||||
|         self.assertEqual(res, []) | ||||
|  | ||||
|     def test_playlist_items_selection(self): | ||||
|         entries = [{ | ||||
|             'id': compat_str(i), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Sergey M․
					Sergey M․