yt-dlp/yt-dlp · error · ValueError
invalid cookies from browser arguments: {opts.cookiesfrombro
Error message
invalid cookies from browser arguments: {opts.cookiesfrombrowser} What it means
Raised while parsing --cookies-from-browser: the argument must fullmatch 'NAME[+KEYRING][:PROFILE][::CONTAINER]' where NAME excludes '+' and ':' (regex: name [^+:]+, optional '+keyring' [^:]+, optional ':profile' that may not itself start with ':', optional '::container'). If re.fullmatch returns None, this ValueError echoes the raw argument. On success the value is rewritten to a (browser, profile, keyring, container) tuple.
Source
Thrown at yt_dlp/__init__.py:404
raise ValueError(f'invalid {name} time range "{regex}". {err}')
ranges.append(dur)
return chapters, ranges, from_url
opts.remove_chapters, opts.remove_ranges, _ = parse_chapters('--remove-chapters', opts.remove_chapters)
opts.download_ranges = download_range_func(*parse_chapters('--download-sections', opts.download_ranges, True))
# Cookies from browser
if opts.cookiesfrombrowser:
container = None
mobj = re.fullmatch(r'''(?x)
(?P<name>[^+:]+)
(?:\s*\+\s*(?P<keyring>[^:]+))?
(?:\s*:\s*(?!:)(?P<profile>.+?))?
(?:\s*::\s*(?P<container>.+))?
''', opts.cookiesfrombrowser)
if mobj is None:
raise ValueError(f'invalid cookies from browser arguments: {opts.cookiesfrombrowser}')
browser_name, keyring, profile, container = mobj.group('name', 'keyring', 'profile', 'container')
browser_name = browser_name.lower()
if browser_name not in SUPPORTED_BROWSERS:
raise ValueError(f'unsupported browser specified for cookies: "{browser_name}". '
f'Supported browsers are: {", ".join(sorted(SUPPORTED_BROWSERS))}')
if keyring is not None:
keyring = keyring.upper()
if keyring not in SUPPORTED_KEYRINGS:
raise ValueError(f'unsupported keyring specified for cookies: "{keyring}". '
f'Supported keyrings are: {", ".join(sorted(SUPPORTED_KEYRINGS))}')
opts.cookiesfrombrowser = (browser_name, profile, keyring, container)
if opts.impersonate is not None:
opts.impersonate = ImpersonateTarget.from_str(opts.impersonate.lower())
# MetadataParser
def metadataparser_actions(f):
if isinstance(f, str):View on GitHub (pinned to 81ecd58b13)
Solutions
- Use the documented shape: BROWSER[+KEYRING][:PROFILE][::CONTAINER], e.g. 'chrome', 'firefox:default-release', 'chrome+kwallet5', 'chrome::Personal'.
- Remove trailing/leading separators; every separator must be followed by content.
- Quote the whole argument so shell spaces in profile names survive, e.g. --cookies-from-browser 'chrome::Profile 1'.
- Remember the first colon switches to PROFILE and '::' switches to CONTAINER — do not use '::' for profiles.
Example fix
# before yt-dlp --cookies-from-browser 'chrome:' URL # ValueError: invalid cookies from browser arguments: chrome: # after yt-dlp --cookies-from-browser 'chrome::Default' URL # BROWSER[+KEYRING][:PROFILE][::CONTAINER]
Defensive patterns
Strategy: validation
Validate before calling
import re
BROWSER_SPEC_RE = re.compile(r'(?x)(?P<name>[^+:]+)(?:\s*\+\s*(?P<keyring>[^:]+))?(?:\s*:\s*(?!:)(?P<profile>.+?))?(?:\s*::\s*(?P<container>.+))?')
def parse_spec(spec):
m = BROWSER_SPEC_RE.fullmatch(spec)
if m is None:
raise ValueError(f'invalid cookies from browser arguments: {spec}')
return m.group('name', 'keyring', 'profile', 'container') Prevention
- One colon = PROFILE, double colon = CONTAINER; '+' = KEYRING.
- Every separator must be followed by content — no trailing ':' or '+'.
- Quote the whole argument to protect spaces in profile names.
- Validate the spec with the same regex before shelling out from scripts.
When it happens
Trigger: --cookies-from-browser 'chrome:' (trailing colon with nothing after it); ':profile' (empty browser name); 'chrome+' (empty keyring); 'chrome:::x' (extra colons); browser names containing '+' such as 'chromium+beta'. Note 'chrome::Default' is valid — the double-colon form is the container slot.
Common situations: Confusing the one-colon (profile) and two-colon (container) separators; trailing separators from shell variable expansion (${BROWSER}: with empty profile); passing URLs or paths instead of a browser spec.
Related errors
- unsupported browser specified for cookies: "{browser_name}".
- unsupported keyring specified for cookies: "{keyring}". Supp
- unknown browser: {browser_name}
- invalid {name} "{value}" given
- {max_name} "{max_val}" must be must be greater than or equal
AI-assisted analysis of yt-dlp/yt-dlp@81ecd58b13 (2026-08-22).
Data as JSON: /api/errors/5ea64cf78c2ba509.
Report an issue: GitHub.