mirror of
https://github.com/l1ving/youtube-dl
synced 2025-02-04 02:12:54 +08:00
[nhl] add --auth-provider option to support rogers logins
Addresses https://github.com/rg3/youtube-dl/pull/11366#issuecomment-271127084
This commit is contained in:
parent
7d4af4d53c
commit
379cf94726
@ -357,6 +357,7 @@ which means you can modify it, redistribute it or use it however you like.
|
||||
-2, --twofactor TWOFACTOR Two-factor auth code
|
||||
-n, --netrc Use .netrc authentication data
|
||||
--video-password PASSWORD Video password (vimeo, smotri, youku)
|
||||
--auth-provider PROVIDER Authentication provider (nhl, rogers)
|
||||
|
||||
## Adobe Pass Options:
|
||||
--ap-mso MSO Adobe Pass multiple-system operator (TV
|
||||
|
@ -131,6 +131,7 @@ class YoutubeDL(object):
|
||||
username: Username for authentication purposes.
|
||||
password: Password for authentication purposes.
|
||||
videopassword: Password for accessing a video.
|
||||
auth_provider: Authentication provider
|
||||
ap_mso: Adobe Pass multiple-system operator identifier.
|
||||
ap_username: Multiple-system operator account username.
|
||||
ap_password: Multiple-system operator account password.
|
||||
|
@ -300,6 +300,7 @@ def _real_main(argv=None):
|
||||
'password': opts.password,
|
||||
'twofactor': opts.twofactor,
|
||||
'videopassword': opts.videopassword,
|
||||
'auth_provider': opts.auth_provider,
|
||||
'ap_mso': opts.ap_mso,
|
||||
'ap_username': opts.ap_username,
|
||||
'ap_password': opts.ap_password,
|
||||
|
@ -715,6 +715,16 @@ class InfoExtractor(object):
|
||||
|
||||
return username, password
|
||||
|
||||
def _get_auth_provider(self):
|
||||
"""
|
||||
Get the authentication provider (e.g. nhl / rogers)
|
||||
"""
|
||||
if self._downloader is None:
|
||||
return None
|
||||
|
||||
downloader_params = self._downloader.params
|
||||
return downloader_params.get('auth_provider')
|
||||
|
||||
def _get_tfa_info(self, note='two-factor verification code'):
|
||||
"""
|
||||
Get the two-factor authentication info
|
||||
|
@ -359,7 +359,8 @@ class NHLTVIE(InfoExtractor):
|
||||
IE_NAME = 'nhl.com:nhltv'
|
||||
_VALID_URL = r'https?://(?:www\.)?nhl.com/tv/(?P<gameId>\d+)(/[^/]+)*(/(?P<id>\d+))?'
|
||||
_OAUTH_URL = 'https://user.svc.nhl.com/oauth/token?grant_type=client_credentials'
|
||||
_LOGIN_URL = 'https://gateway.web.nhl.com/ws/subscription/flow/nhlPurchase.login'
|
||||
_NHL_LOGIN_URL = 'https://gateway.web.nhl.com/ws/subscription/flow/nhlPurchase.login'
|
||||
_ROGERS_LOGIN_URL = 'https://activation-rogers.svc.nhl.com/ws/subscription/flow/rogers.login-check'
|
||||
_NETRC_MACHINE = 'nhltv'
|
||||
_TESTS = [{
|
||||
# This is a free video that can be accessed by anyone with an NHL TV login
|
||||
@ -409,24 +410,52 @@ class NHLTVIE(InfoExtractor):
|
||||
'Unable to get OAuth access token')
|
||||
access_token = oauth_response['access_token']
|
||||
|
||||
auth_provider = self._get_auth_provider()
|
||||
if auth_provider == 'rogers':
|
||||
login_request = self._create_rogers_login_request(username, password, access_token)
|
||||
elif auth_provider == 'nhl' or auth_provider is None:
|
||||
login_request = self._create_nhl_login_request(username, password, access_token)
|
||||
else:
|
||||
raise ExtractorError('Unknown authentication provider: %s. Valid values are nhl, rogers' % auth_provider)
|
||||
|
||||
# sets up the cookies we need to download
|
||||
self._download_webpage(
|
||||
login_request, None, 'Logging in', 'Unable to log in')
|
||||
|
||||
def _create_nhl_login_request(self, username, password, access_token):
|
||||
login_data = {
|
||||
'nhlCredentials': {
|
||||
'email': username,
|
||||
'password': password,
|
||||
}
|
||||
}
|
||||
login_request = sanitized_Request(
|
||||
self._LOGIN_URL,
|
||||
return sanitized_Request(
|
||||
self._NHL_LOGIN_URL,
|
||||
data=json.dumps(login_data, sort_keys=True).encode('utf-8'),
|
||||
headers={
|
||||
'Referer': 'https://www.nhl.com/login',
|
||||
'Referer': 'https://www.nhl.com/login/nhl',
|
||||
'Accept': 'application/json, text/javascript, */*; q=0.01',
|
||||
'Authorization': access_token,
|
||||
'Content-Type': 'application/json'
|
||||
})
|
||||
|
||||
|
||||
def _create_rogers_login_request(self, username, password, access_token):
|
||||
login_data = {
|
||||
'rogerCredentials': {
|
||||
'email': username,
|
||||
'password': password,
|
||||
}
|
||||
}
|
||||
return sanitized_Request(
|
||||
self._ROGERS_LOGIN_URL,
|
||||
data=json.dumps(login_data, sort_keys=True).encode('utf-8'),
|
||||
headers={
|
||||
'Referer': 'https://www.nhl.com/login/rogers',
|
||||
'Accept': 'application/json, text/javascript, */*; q=0.01',
|
||||
'Authorization': access_token,
|
||||
'Content-Type': 'application/json'
|
||||
})
|
||||
# sets up the cookies we need to download
|
||||
self._download_webpage(
|
||||
login_request, None, 'Logging in', 'Unable to log in')
|
||||
|
||||
def _real_initialize(self):
|
||||
self._login()
|
||||
|
@ -350,6 +350,10 @@ def parseOpts(overrideArguments=None):
|
||||
'--video-password',
|
||||
dest='videopassword', metavar='PASSWORD',
|
||||
help='Video password (vimeo, smotri, youku)')
|
||||
authentication.add_option(
|
||||
'--auth-provider',
|
||||
dest='auth_provider', metavar='AUTH_PROVIDER',
|
||||
help='Authentication provider (nhl, rogers, ...)')
|
||||
|
||||
adobe_pass = optparse.OptionGroup(parser, 'Adobe Pass Options')
|
||||
adobe_pass.add_option(
|
||||
|
Loading…
Reference in New Issue
Block a user