ytdl-org/youtube-dl · error · ExtractorError
Unable to log in
Error message
Unable to log in
What it means
Raised by the Safari/O'Reilly login helper after the full flow (auth POST, cookie application, redirect completion) when is_logged(urlh) is still false: the sequence completed without an explicit credentials error, but the session is not authenticated. NOT marked expected=True, so it surfaces as an unexpected extraction error.
Source
Thrown at youtube_dl/extractor/safari.py:82
credentials = auth.get('credentials')
if (not auth.get('logged_in') and not auth.get('redirect_uri')
and credentials):
raise ExtractorError(
'Unable to login: %s' % credentials, expected=True)
# oreilly serves two same instances of the following cookies
# in Set-Cookie header and expects first one to be actually set
for cookie in ('groot_sessionid', 'orm-jwt', 'orm-rt'):
self._apply_first_set_cookie_header(urlh, cookie)
_, urlh = self._download_webpage_handle(
auth.get('redirect_uri') or next_uri, None, 'Completing login',)
if is_logged(urlh):
self.LOGGED_IN = True
return
raise ExtractorError('Unable to log in')
class SafariIE(SafariBaseIE):
IE_NAME = 'safari'
IE_DESC = 'safaribooksonline.com online video'
_VALID_URL = r'''(?x)
https?://
(?:www\.)?(?:safaribooksonline|(?:learning\.)?oreilly)\.com/
(?:
library/view/[^/]+/(?P<course_id>[^/]+)/(?P<part>[^/?\#&]+)\.html|
videos/[^/]+/[^/]+/(?P<reference_id>[^-]+-[^/?\#&]+)
)
'''
_TESTS = [{
'url': 'https://www.safaribooksonline.com/library/view/hadoop-fundamentals-livelessons/9780133392838/part00.html',
'md5': 'dcc5a425e79f2564148652616af1f2a3',
'info_dict': {View on GitHub (pinned to 956b8c5855)
Solutions
- Update youtube-dl to the latest version - login-flow breakage is usually fixed upstream quickly.
- Confirm the account can log in on the web with the same password (rules out MFA/lockout).
- If you do not actually need member content, run without --username/--password for public chapters.
- If it persists, report the regression with a trace; the is_logged probe or cookie names likely changed.
Defensive patterns
Strategy: retry
Try / catch
try:
ydl.extract_info(url)
except ExtractorError as e:
if 'Unable to log in' in str(e):
# not expected=True: usually a site-flow change; retry after updating
update_and_retry_once()
else:
raise Prevention
- Keep youtube-dl current - O'Reilly login flow changes frequently and fixes land upstream fast.
- Confirm the account can complete plain password login on the web (no MFA challenge).
- Run without credentials for public chapters to isolate whether login is the failing step.
When it happens
Trigger: Passing --username/--password where the auth succeeds at HTTP level but the final next_uri page does not show a logged-in state - cookie handling breaks (the code applies only the FIRST Set-Cookie instance for groot_sessionid/orm-jwt/orm-rt), or O'Reilly changed its login flow/cookies.
Common situations: Site-side login flow changes after an O'Reilly deploy; two-instance Set-Cookie behavior changing; MFA/SSO accounts that cannot complete a plain password POST.
Related errors
- Unable to login: %s
- No chapters found for course %s
- We're sorry, but either the User ID or Password entered is n
- Unable to login: %s said: %s
- Unable to login: %s
AI-assisted analysis of ytdl-org/youtube-dl@956b8c5855 (2026-08-14).
Data as JSON: /api/errors/8adfcca52ca27529.
Report an issue: GitHub.