mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-16 21:33:19 +00:00
[vk] Fix authentication (Closes #6105)
This commit is contained in:
parent
af214c3a79
commit
226b886ca8
|
@ -121,20 +121,27 @@ def _login(self):
|
||||||
if username is None:
|
if username is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
login_form = {
|
login_page = self._download_webpage(
|
||||||
'act': 'login',
|
'https://vk.com', None, 'Downloading login page')
|
||||||
'role': 'al_frame',
|
|
||||||
'expire': '1',
|
login_form = dict(re.findall(
|
||||||
|
r'<input\s+type="hidden"\s+name="([^"]+)"\s+(?:id="[^"]+"\s+)?value="([^"]*)"',
|
||||||
|
login_page))
|
||||||
|
|
||||||
|
login_form.update({
|
||||||
'email': username.encode('cp1251'),
|
'email': username.encode('cp1251'),
|
||||||
'pass': password.encode('cp1251'),
|
'pass': password.encode('cp1251'),
|
||||||
}
|
})
|
||||||
|
|
||||||
request = compat_urllib_request.Request('https://login.vk.com/?act=login',
|
request = compat_urllib_request.Request(
|
||||||
|
'https://login.vk.com/?act=login',
|
||||||
compat_urllib_parse.urlencode(login_form).encode('utf-8'))
|
compat_urllib_parse.urlencode(login_form).encode('utf-8'))
|
||||||
login_page = self._download_webpage(request, None, note='Logging in as %s' % username)
|
login_page = self._download_webpage(
|
||||||
|
request, None, note='Logging in as %s' % username)
|
||||||
|
|
||||||
if re.search(r'onLoginFailed', login_page):
|
if re.search(r'onLoginFailed', login_page):
|
||||||
raise ExtractorError('Unable to login, incorrect username and/or password', expected=True)
|
raise ExtractorError(
|
||||||
|
'Unable to login, incorrect username and/or password', expected=True)
|
||||||
|
|
||||||
def _real_initialize(self):
|
def _real_initialize(self):
|
||||||
self._login()
|
self._login()
|
||||||
|
|
Loading…
Reference in a new issue