mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-27 05:35:52 +01:00
[twitch] Fix login (Closes #6186)
This commit is contained in:
parent
bf20b9c540
commit
9296e92e1c
@ -22,8 +22,8 @@ class TwitchBaseIE(InfoExtractor):
|
|||||||
|
|
||||||
_API_BASE = 'https://api.twitch.tv'
|
_API_BASE = 'https://api.twitch.tv'
|
||||||
_USHER_BASE = 'http://usher.twitch.tv'
|
_USHER_BASE = 'http://usher.twitch.tv'
|
||||||
_LOGIN_URL = 'https://secure.twitch.tv/user/login'
|
_LOGIN_URL = 'https://secure.twitch.tv/login'
|
||||||
_LOGIN_POST_URL = 'https://secure-login.twitch.tv/login'
|
_LOGIN_POST_URL = 'https://passport.twitch.tv/authorize'
|
||||||
_NETRC_MACHINE = 'twitch'
|
_NETRC_MACHINE = 'twitch'
|
||||||
|
|
||||||
def _handle_error(self, response):
|
def _handle_error(self, response):
|
||||||
@ -59,20 +59,14 @@ def _login(self):
|
|||||||
login_page = self._download_webpage(
|
login_page = self._download_webpage(
|
||||||
self._LOGIN_URL, None, 'Downloading login page')
|
self._LOGIN_URL, None, 'Downloading login page')
|
||||||
|
|
||||||
authenticity_token = self._search_regex(
|
login_form = dict(re.findall(
|
||||||
r'<input name="authenticity_token" type="hidden" value="([^"]+)"',
|
r'<input\s+type="hidden"\s+name="([^"]+)"\s+(?:id="[^"]+"\s+)?value="([^"]*)"',
|
||||||
login_page, 'authenticity token')
|
login_page))
|
||||||
|
|
||||||
login_form = {
|
login_form.update({
|
||||||
'utf8': '✓'.encode('utf-8'),
|
|
||||||
'authenticity_token': authenticity_token,
|
|
||||||
'redirect_on_login': '',
|
|
||||||
'embed_form': 'false',
|
|
||||||
'mp_source_action': 'login-button',
|
|
||||||
'follow': '',
|
|
||||||
'login': username,
|
'login': username,
|
||||||
'password': password,
|
'password': password,
|
||||||
}
|
})
|
||||||
|
|
||||||
request = compat_urllib_request.Request(
|
request = compat_urllib_request.Request(
|
||||||
self._LOGIN_POST_URL, compat_urllib_parse.urlencode(login_form).encode('utf-8'))
|
self._LOGIN_POST_URL, compat_urllib_parse.urlencode(login_form).encode('utf-8'))
|
||||||
|
Loading…
Reference in New Issue
Block a user