ytdl-org/youtube-dl · error · ValueError
Operator %s does not support string values!
Error message
Operator %s does not support string values!
What it means
Raised by _match_one() in youtube_dl.utils while evaluating a --match-filter expression. The filter compares a field to a quoted or bare string value using a comparison operator other than = or != (e.g. <, <=, >, >=, ~=). Ordering/regex operators only work on numeric values, so applying one to a string comparison value is rejected with ValueError. The check also fires when the field's actual value is a string but the filter supplies a bare number (e.g. likes>100 against a string field), honoring the field's origin (issue #11082).
Source
Thrown at youtube_dl/utils.py:4898
(?P<quote>["\'])(?P<quotedstrval>(?:\\.|(?!(?P=quote)|\\).)+?)(?P=quote)|
(?P<strval>(?![0-9.])[a-z0-9A-Z]*)
)
\s*$
''' % '|'.join(map(re.escape, COMPARISON_OPERATORS.keys())))
m = operator_rex.search(filter_part)
if m:
op = COMPARISON_OPERATORS[m.group('op')]
actual_value = dct.get(m.group('key'))
if (m.group('quotedstrval') is not None
or m.group('strval') is not None
# If the original field is a string and matching comparisonvalue is
# a number we should respect the origin of the original field
# and process comparison value as a string (see
# https://github.com/ytdl-org/youtube-dl/issues/11082).
or actual_value is not None and m.group('intval') is not None
and isinstance(actual_value, compat_str)):
if m.group('op') not in ('=', '!='):
raise ValueError(
'Operator %s does not support string values!' % m.group('op'))
comparison_value = m.group('quotedstrval') or m.group('strval') or m.group('intval')
quote = m.group('quote')
if quote is not None:
comparison_value = comparison_value.replace(r'\%s' % quote, quote)
else:
try:
comparison_value = int(m.group('intval'))
except ValueError:
comparison_value = parse_filesize(m.group('intval'))
if comparison_value is None:
comparison_value = parse_filesize(m.group('intval') + 'B')
if comparison_value is None:
raise ValueError(
'Invalid integer value %r in filter part %r' % (
m.group('intval'), filter_part))
if actual_value is None:
return m.group('none_inclusive')View on GitHub (pinned to 956b8c5855)
Solutions
- Use only = or != when comparing string fields, e.g. --match-filter "ext!=mkv".
- Compare numeric fields numerically (view_count>1000) and verify the extractor populates that field as a number.
- For substring/regex needs on strings, rely on = with the supported semantics or pre-filter downloads with your own script instead of the filter DSL.
- Quote string values only for =/!= comparisons; drop quotes for numeric comparisons.
Example fix
# before youtube-dl --match-filter "title>'Tutorial'" URL # ValueError: Operator > does not support string values! # after youtube-dl --match-filter "title!='Tutorial'" URL # equality on strings is allowed
Defensive patterns
Strategy: validation
Validate before calling
import re
# only = and != may take string comparison values
_BAD = re.compile(r"[<>]=?|~=")
def check_filter(filter_str):
for part in filter_str.split('&'):
m = re.match(r'^([a-z_]+)\s*(=|!=|<|<=|>|>=|~=)\s*(.+)$', part.strip())
if m and m.group(2) not in ('=', '!='):
val = m.group(3)
if not re.fullmatch(r'\d+([KMG]B?)?', val):
raise ValueError('operator %s cannot take string value %r' % (m.group(2), val)) Type guard
def is_safe_string_filter(op: str, value: str) -> bool:
return op in ('=', '!=') or value.lstrip('-').isdigit() Try / catch
from youtube_dl.utils import match_str
try:
ok = match_str('title>\'x\'', info)
except ValueError as e:
# rewrite filter to use =/!= or drop the part
ok = None Prevention
- Reserve <, <=, >, >=, ~= for numeric fields; use =/!= for strings.
- Check with --dump-json whether the field is numeric before writing a numeric filter.
- Test filter strings with a dry-run (--simulate) before batch downloads.
When it happens
Trigger: Running youtube-dl --match-filter "title>'foo'" or any filter like field<value / field>value / field~=value where value is quoted ('...' or "...") or bare text; or a filter like likes>100 where the extractor reports likes as a string. Only = and != accept string comparison values.
Common situations: Users writing match-filters that compare text fields lexicographically (title>'A', duration~='long'); filters written against fields that one extractor types as int and another as string; copy-pasted filter examples that assume numeric fields.
Related errors
- Invalid integer value %r in filter part %r
- Invalid filter part %r
- requested format not available
- Giving up retrying
- Invalid URL
AI-assisted analysis of ytdl-org/youtube-dl@956b8c5855 (2026-08-14).
Data as JSON: /api/errors/e1c5c61c6e0cfb5d.
Report an issue: GitHub.