[twitch] 2fa fix
This commit is contained in:
parent
93bb6b1bae
commit
bc909621e7
@ -40,6 +40,7 @@ class TwitchBaseIE(InfoExtractor):
|
|||||||
_LOGIN_POST_URL = 'https://passport.twitch.tv/login'
|
_LOGIN_POST_URL = 'https://passport.twitch.tv/login'
|
||||||
_CLIENT_ID = 'kimne78kx3ncx6brgo4mv6wki5h1ko'
|
_CLIENT_ID = 'kimne78kx3ncx6brgo4mv6wki5h1ko'
|
||||||
_NETRC_MACHINE = 'twitch'
|
_NETRC_MACHINE = 'twitch'
|
||||||
|
_AUTHY_ERROR_CODE = 3011
|
||||||
|
|
||||||
def _handle_error(self, response):
|
def _handle_error(self, response):
|
||||||
if not isinstance(response, dict):
|
if not isinstance(response, dict):
|
||||||
@ -92,7 +93,19 @@ class TwitchBaseIE(InfoExtractor):
|
|||||||
post_url, None, note, data=json.dumps(form).encode(),
|
post_url, None, note, data=json.dumps(form).encode(),
|
||||||
headers=headers, expected_status=400)
|
headers=headers, expected_status=400)
|
||||||
error = response.get('error_description') or response.get('error_code')
|
error = response.get('error_description') or response.get('error_code')
|
||||||
if error:
|
|
||||||
|
if response.get('error_code') == self._AUTHY_ERROR_CODE:
|
||||||
|
# Authy code request
|
||||||
|
tfa_token = self._get_tfa_info('two-factor authentication token')
|
||||||
|
response = self._download_json(
|
||||||
|
post_url, None, note, data=json.dumps({
|
||||||
|
'username': username,
|
||||||
|
'password': password,
|
||||||
|
'client_id': self._CLIENT_ID,
|
||||||
|
'authy_token': tfa_token,
|
||||||
|
'remember_2fa': 'true',
|
||||||
|
}).encode(), headers=headers, expected_status=400)
|
||||||
|
else:
|
||||||
fail(error)
|
fail(error)
|
||||||
|
|
||||||
if 'Authenticated successfully' in response.get('message', ''):
|
if 'Authenticated successfully' in response.get('message', ''):
|
||||||
@ -123,14 +136,6 @@ class TwitchBaseIE(InfoExtractor):
|
|||||||
if not redirect_page:
|
if not redirect_page:
|
||||||
return
|
return
|
||||||
|
|
||||||
if re.search(r'(?i)<form[^>]+id="two-factor-submit"', redirect_page) is not None:
|
|
||||||
# TODO: Add mechanism to request an SMS or phone call
|
|
||||||
tfa_token = self._get_tfa_info('two-factor authentication token')
|
|
||||||
login_step(redirect_page, handle, 'Submitting TFA token', {
|
|
||||||
'authy_token': tfa_token,
|
|
||||||
'remember_2fa': 'true',
|
|
||||||
})
|
|
||||||
|
|
||||||
def _prefer_source(self, formats):
|
def _prefer_source(self, formats):
|
||||||
try:
|
try:
|
||||||
source = next(f for f in formats if f['format_id'] == 'Source')
|
source = next(f for f in formats if f['format_id'] == 'Source')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user