Browse Source

[YoutubeDL] Introduce CSS3 like string operators

Yen Chi Hsuan 9 năm trước cách đây
mục cha
commit
10d33b3473
1 tập tin đã thay đổi với 3 bổ sung0 xóa
  1. 3 0
      youtube_dl/YoutubeDL.py

+ 3 - 0
youtube_dl/YoutubeDL.py

@@ -898,6 +898,9 @@ class YoutubeDL(object):
             STR_OPERATORS = {
                 '=': operator.eq,
                 '!=': operator.ne,
+                '^=': lambda attr, value: attr.startswith(value),
+                '$=': lambda attr, value: attr.endswith(value),
+                '*=': lambda attr, value: value in attr,
             }
             str_operator_rex = re.compile(r'''(?x)
                 \s*(?P<key>ext|acodec|vcodec|container|protocol)