|
|
|
@ -4657,7 +4657,7 @@ def render_table(header_row, data, delim=False, extraGap=0, hideEmpty=False):
|
|
|
|
|
return '\n'.join(format_str % tuple(row) for row in table)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _match_one(filter_part, dct):
|
|
|
|
|
def _match_one(filter_part, dct, incomplete):
|
|
|
|
|
# TODO: Generalize code with YoutubeDL._build_format_filter
|
|
|
|
|
STRING_OPERATORS = {
|
|
|
|
|
'*=': operator.contains,
|
|
|
|
@ -4718,7 +4718,7 @@ def _match_one(filter_part, dct):
|
|
|
|
|
'Invalid integer value %r in filter part %r' % (
|
|
|
|
|
m.group('intval'), filter_part))
|
|
|
|
|
if actual_value is None:
|
|
|
|
|
return m.group('none_inclusive')
|
|
|
|
|
return incomplete or m.group('none_inclusive')
|
|
|
|
|
return op(actual_value, comparison_value)
|
|
|
|
|
|
|
|
|
|
UNARY_OPERATORS = {
|
|
|
|
@ -4733,22 +4733,25 @@ def _match_one(filter_part, dct):
|
|
|
|
|
if m:
|
|
|
|
|
op = UNARY_OPERATORS[m.group('op')]
|
|
|
|
|
actual_value = dct.get(m.group('key'))
|
|
|
|
|
if incomplete and actual_value is None:
|
|
|
|
|
return True
|
|
|
|
|
return op(actual_value)
|
|
|
|
|
|
|
|
|
|
raise ValueError('Invalid filter part %r' % filter_part)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def match_str(filter_str, dct):
|
|
|
|
|
""" Filter a dictionary with a simple string syntax. Returns True (=passes filter) or false """
|
|
|
|
|
|
|
|
|
|
def match_str(filter_str, dct, incomplete=False):
|
|
|
|
|
""" Filter a dictionary with a simple string syntax. Returns True (=passes filter) or false
|
|
|
|
|
When incomplete, all conditions passes on missing fields
|
|
|
|
|
"""
|
|
|
|
|
return all(
|
|
|
|
|
_match_one(filter_part.replace(r'\&', '&'), dct)
|
|
|
|
|
_match_one(filter_part.replace(r'\&', '&'), dct, incomplete)
|
|
|
|
|
for filter_part in re.split(r'(?<!\\)&', filter_str))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def match_filter_func(filter_str):
|
|
|
|
|
def _match_func(info_dict):
|
|
|
|
|
if match_str(filter_str, info_dict):
|
|
|
|
|
def _match_func(info_dict, *args, **kwargs):
|
|
|
|
|
if match_str(filter_str, info_dict, *args, **kwargs):
|
|
|
|
|
return None
|
|
|
|
|
else:
|
|
|
|
|
video_title = info_dict.get('title', info_dict.get('id', 'video'))
|
|
|
|
|