yt-dlp/yt-dlp · error · ExtractorError
Invalid cookie consent redirect URL
Error message
Invalid cookie consent redirect URL
What it means
YoutubeCookieConsentRedirectIE handles consent redirect URLs by reading the continue query parameter (last value, checked with url_or_none). If continue is missing or not a valid URL string, it raises expected=True instead of passing a broken URL downstream.
Source
Thrown at yt_dlp/extractor/youtube/_redirect.py:247
'channel_follower_count': int,
'channel_id': 'UCIdEIHpS0TdkqRkHL5OkLtA',
'categories': ['Entertainment'],
'live_status': 'was_live',
'release_timestamp': 1671793345,
'channel': 'さなちゃんねる',
'description': 'md5:6aebf95cc4a1d731aebc01ad6cc9806d',
'uploader': 'さなちゃんねる',
'channel_is_verified': True,
'heatmap': 'count:100',
},
'add_ie': ['Youtube'],
'params': {'skip_download': 'Youtube'},
}]
def _real_extract(self, url):
redirect_url = url_or_none(parse_qs(url).get('continue', [None])[-1])
if not redirect_url:
raise ExtractorError('Invalid cookie consent redirect URL', expected=True)
return self.url_result(redirect_url)
View on GitHub (pinned to 81ecd58b13)
Solutions
- Skip the consent wrapper entirely and give yt-dlp the intended target URL (the value that should be in continue=)
- When harvesting redirect links from HTML, unescape entities first and preserve the full query string
- Re-copy the complete consent URL including all parameters
Example fix
# before yt-dlp "https://consent.youtube.com/m" # -> Invalid cookie consent redirect URL # after: use the real destination directly yt-dlp "https://www.youtube.com/watch?v=YE7VzlLtp-4"
Defensive patterns
Strategy: validation
Validate before calling
from urllib.parse import urlparse, parse_qs
from yt_dlp.utils import url_or_none
def usable_consent_url(url: str) -> bool:
if 'consent.youtube.com' not in (host := urlparse(url).netloc):
return True # not a consent redirect
continue_vals = parse_qs(urlparse(url).query).get('continue', [])
return bool(continue_vals) and url_or_none(continue_vals[-1]) is not None Prevention
- Store and hand yt-dlp the final target URL, not consent interstitials
- When scraping redirect hrefs from HTML, unescape entities and keep the full query string
- Reject harvested consent URLs lacking a continue parameter at ingest
When it happens
Trigger: Feeding yt-dlp a consent.youtube.com/m?... URL whose continue parameter was stripped, empty, or HTML-escaped into a non-URL value; typically these URLs are harvested programmatically from page HTML or logs rather than typed by hand.
Common situations: Scrapers extracting the consent redirect href but losing the query string; manually cleaning URLs and dropping params; double-escaping (&&) making parse_qs yield an unusable value.
Related errors
- The channel/playlist does not exist and the URL redirected t
- A video URL was given without video ID
- Unsupported URL: {redirect_url}
- Invalid facebook redirect URL
- Redirect failed
AI-assisted analysis of yt-dlp/yt-dlp@81ecd58b13 (2026-08-22).
Data as JSON: /api/errors/796dbfd2582c09db.
Report an issue: GitHub.