diff options
author | Sergey M․ <dstftw@gmail.com> | 2015-06-27 14:04:55 +0600 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2015-06-27 14:04:55 +0600 |
commit | 226b886ca85b5843d2cb9638fb6d88223e9dd5b2 (patch) | |
tree | e101d6b09aa86a8ad8d36cd99bfec013097f6d9c /youtube_dl/extractor/vk.py | |
parent | af214c3a79bb598d3a13559c5ebddcca4584669a (diff) |
[vk] Fix authentication (Closes #6105)
Diffstat (limited to 'youtube_dl/extractor/vk.py')
-rw-r--r-- | youtube_dl/extractor/vk.py | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/youtube_dl/extractor/vk.py b/youtube_dl/extractor/vk.py index 38ff3c1a9..f2ae109f9 100644 --- a/youtube_dl/extractor/vk.py +++ b/youtube_dl/extractor/vk.py @@ -121,20 +121,27 @@ class VKIE(InfoExtractor): if username is None: return - login_form = { - 'act': 'login', - 'role': 'al_frame', - 'expire': '1', + login_page = self._download_webpage( + 'https://vk.com', None, 'Downloading login page') + + 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'), 'pass': password.encode('cp1251'), - } + }) - request = compat_urllib_request.Request('https://login.vk.com/?act=login', - compat_urllib_parse.urlencode(login_form).encode('utf-8')) - login_page = self._download_webpage(request, None, note='Logging in as %s' % username) + request = compat_urllib_request.Request( + 'https://login.vk.com/?act=login', + compat_urllib_parse.urlencode(login_form).encode('utf-8')) + login_page = self._download_webpage( + request, None, note='Logging in as %s' % username) 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): self._login() |