[nebula] Prevent cookies from breaking Nebula auth

When the 'sessionid' cookie is submitted to the `/auth/login/` endpoint,
the response is always a 403. This typically happens when youtube_dl is
run with both `--netrc` and `--cookies` as your default configuration.
In that situation, the first authentication succeeds and stores the
`sessionid` cookie in the cookie jar. During subsequent authentication
attempts, the cookie is sent alongside and causes the authentication to
fail.

This is very unexpected and we therefore specifically handle this case.
This commit is contained in:
Henrik Heimbuerger 2021-01-17 15:46:33 +01:00
parent 59c0e6e3d8
commit 9fdfd6d3ba

View File

@ -85,7 +85,12 @@ class NebulaIE(InfoExtractor):
request = sanitized_Request(method='POST', request = sanitized_Request(method='POST',
url='https://api.watchnebula.com/api/v1/auth/login/', url='https://api.watchnebula.com/api/v1/auth/login/',
data=data, data=data,
headers={'content-type': 'application/json'}) headers={
'content-type': 'application/json',
# Overwrite the cookie headers, because
# submitting the 'sessionid' cookie
# always causes a 403 on auth endpoint
'cookie': ''})
response = self._download_json(request, fatal=False, video_id=video_id, response = self._download_json(request, fatal=False, video_id=video_id,
note='Authenticating to Nebula with supplied credentials', note='Authenticating to Nebula with supplied credentials',
errnote='Authentication failed or rejected') errnote='Authentication failed or rejected')
@ -105,6 +110,9 @@ class NebulaIE(InfoExtractor):
the error message, because probably highly unpopular) the error message, because probably highly unpopular)
If none of these are successful, an end user-intended error message is If none of these are successful, an end user-intended error message is
raised, listing some solutions. raised, listing some solutions.
Returns a Nebula API token, which subsequently can be used to make
authenticated calls to the Nebula API.
""" """
nebula_token = None nebula_token = None