ytdl-org/youtube-dl · error · ValueError
Invalid integer value %r in filter part %r
Error message
Invalid integer value %r in filter part %r
What it means
Raised by _match_one() in youtube_dl.utils while evaluating a --match-filter expression. The comparison value was parsed as a number but int() failed and parse_filesize() could not interpret it either as-is (e.g. '100K') or with a 'B' suffix appended (e.g. '100KB'). The filter part therefore contains something in the numeric slot that is neither an integer, a bare size multiplier, nor a valid filesize string.
Source
Thrown at youtube_dl/utils.py:4912
# 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')
return op(actual_value, comparison_value)
UNARY_OPERATORS = {
'': lambda v: (v is True) if isinstance(v, bool) else (v is not None),
'!': lambda v: (v is False) if isinstance(v, bool) else (v is None),
}
operator_rex = re.compile(r'''(?x)\s*
(?P<op>%s)\s*(?P<key>[a-z_]+)
\s*$
''' % '|'.join(map(re.escape, UNARY_OPERATORS.keys())))
m = operator_rex.search(filter_part)
if m:
op = UNARY_OPERATORS[m.group('op')]
actual_value = dct.get(m.group('key'))View on GitHub (pinned to 956b8c5855)
Solutions
- Use plain integers for numeric fields: --match-filter "view_count>=1000".
- For filesize use recognized units: --match-filter "filesize<50M" (K, M, G, optionally with B).
- Remove stray characters/typos after the number in the filter part.
- If you need float comparisons (e.g. average_rating>4.5), filter in a wrapper script with --dump-json instead of the filter DSL.
Example fix
# before youtube-dl --match-filter "filesize<50MBs" URL # ValueError: Invalid integer value '50MBs' in filter part 'filesize<50MBs' youtube-dl --match-filter "average_rating>4.5" URL # floats rejected # after youtube-dl --match-filter "filesize<50M" URL
Defensive patterns
Strategy: validation
Validate before calling
import re
from youtube_dl.utils import parse_filesize
def valid_numeric_part(part):
m = re.match(r'^[a-z_]+\s*(=|!=|<|<=|>|>=|~=)\s*(.+)$', part)
if not m:
return False
v = m.group(2)
if m.group(1) not in ('=', '!='):
return v.isdigit() or (parse_filesize(v) is not None) or (parse_filesize(v + 'B') is not None)
return True Type guard
def is_supported_filter_value(value: str) -> bool:
return value.isdigit() or parse_filesize(value) is not None or parse_filesize(value + 'B') is not None Try / catch
from youtube_dl.utils import match_str
try:
match_str('filesize<50X', info)
except ValueError as e:
# tell the user which part is malformed and abort before downloading
raise SystemExit('bad --match-filter: %s' % e) Prevention
- Use plain integers or K/M/G filesize units in filters.
- No floats or decimals in the filter DSL; pre-filter with --dump-json + jq/script instead.
- Run --simulate once with a new filter to catch syntax errors before real downloads.
When it happens
Trigger: Running --match-filter with a malformed comparison such as filesize>10x, duration>1.5 (floats are not supported), filesize<1oKB, or any field>token where token is not an integer or a recognized filesize unit (K/M/G with optional B). parse_filesize accepts forms like '100K'/'100MB' via the implicit +'B' retry.
Common situations: Typos in match-filter expressions; assuming float or decimal values are supported (only ints and file sizes are); using unusual unit suffixes parse_filesize does not recognize; missing spaces or stray characters after the number.
Related errors
- Operator %s does not support string values!
- 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/ac8f662d9504fc6c.
Report an issue: GitHub.