ytdl-org/youtube-dl · error · ExtractorError
message
Error message
message
What it means
Raised by the PacktPub extractor's login helper when the auth-v1 token endpoint returns HTTP 400/401/404. The extractor reads the response body and re-raises the server's own 'message' field as an expected ExtractorError. The literal 'message' in the catalog is the format source: the actual text (e.g. 'Invalid username or password') comes from Packt's API.
Source
Thrown at youtube_dl/extractor/packtpub.py:65
}]
_NETRC_MACHINE = 'packtpub'
_TOKEN = None
def _real_initialize(self):
username, password = self._get_login_info()
if username is None:
return
try:
self._TOKEN = self._download_json(
'https://services.packtpub.com/auth-v1/users/tokens', None,
'Downloading Authorization Token', data=json.dumps({
'username': username,
'password': password,
}).encode())['data']['access']
except ExtractorError as e:
if isinstance(e.cause, compat_HTTPError) and e.cause.code in (400, 401, 404):
message = self._parse_json(e.cause.read().decode(), None)['message']
raise ExtractorError(message, expected=True)
raise
def _real_extract(self, url):
course_id, chapter_id, video_id, display_id = re.match(self._VALID_URL, url).groups()
headers = {}
if self._TOKEN:
headers['Authorization'] = 'Bearer ' + self._TOKEN
try:
video_url = self._download_json(
'https://services.packtpub.com/products-v1/products/%s/%s/%s' % (course_id, chapter_id, video_id), video_id,
'Downloading JSON video', headers=headers)['data']
except ExtractorError as e:
if isinstance(e.cause, compat_HTTPError) and e.cause.code == 400:
self.raise_login_required('This video is locked')
raise
# TODO: find a better way to avoid duplicating course requestsView on GitHub (pinned to 956b8c5855)
Solutions
- Verify the Packt credentials by logging in at packtpub.com in a browser, then correct --username/---password or .netrc
- If credentials are correct, suspect the auth-v1 endpoint is gone — update youtube-dl/yt-dlp to a version with the fixed Packt extractor
- Test extraction anonymously (no credentials) since some free content works without a token
Example fix
# before youtube_dl --username me@example.com --password 'wrong' 'https://www.packtpub.com/application-development/some-video' # after youtube_dl --netrc 'https://www.packtpub.com/application-development/some-video' # with verified 'machine packtpub login me@example.com password correct' in ~/.netrc
Defensive patterns
Strategy: validation
Validate before calling
// Verify credentials work before batch extraction
curl -s -o /dev/null -w '%{http_code}' -X POST https://services.packtpub.com/auth-v1/users/tokens -d '{"username":"me@example.com","password":"hunter2"}'
// 200 → credentials fine; 400/401/404 → fix before invoking yt-dlp Try / catch
try:
ydl.extract_info(url)
except ExtractorError as e:
if e.expected: # server-supplied auth message
print('Packt login rejected:', str(e)) Prevention
- Keep .netrc credentials in sync with the real account
- Smoke-test auth with a single URL before long batches
- Update extractors when vendors retire auth API versions
When it happens
Trigger: Calling PacktPub extraction with --username/--password (or netrc) where services.packtpub.com/auth-v1/users/tokens rejects the credentials with 400/401/404; or when the auth endpoint moves/changes shape (404 body may not even be JSON, which would instead cause a parse error).
Common situations: Wrong or expired Packt login in .netrc; ebook-claim-only accounts lacking video access; API v1 being retired by Packt so the 404 path triggers; password containing characters mangled by JSON encoding.
Related errors
- self._parse_json(e.cause.read(), None)['errorMessage']
- Unable to login: %s
- %s said: %s
- Unable to login: %s
- Unable to login: %s some documents. Go to pluralsight.com, l
AI-assisted analysis of ytdl-org/youtube-dl@956b8c5855 (2026-08-14).
Data as JSON: /api/errors/143aa3b8be9c828f.
Report an issue: GitHub.