mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-03 02:03:23 +01:00
[vimeo] Modernize login code and improve error messaging
This commit is contained in:
parent
81dc74966a
commit
26ad6bcdfc
@ -41,21 +41,30 @@ def _login(self):
|
|||||||
if self._LOGIN_REQUIRED:
|
if self._LOGIN_REQUIRED:
|
||||||
raise ExtractorError('No login info available, needed for using %s.' % self.IE_NAME, expected=True)
|
raise ExtractorError('No login info available, needed for using %s.' % self.IE_NAME, expected=True)
|
||||||
return
|
return
|
||||||
self.report_login()
|
webpage = self._download_webpage(
|
||||||
webpage = self._download_webpage(self._LOGIN_URL, None, False)
|
self._LOGIN_URL, None, 'Downloading login page')
|
||||||
token, vuid = self._extract_xsrft_and_vuid(webpage)
|
token, vuid = self._extract_xsrft_and_vuid(webpage)
|
||||||
data = urlencode_postdata({
|
data = {
|
||||||
'action': 'login',
|
'action': 'login',
|
||||||
'email': username,
|
'email': username,
|
||||||
'password': password,
|
'password': password,
|
||||||
'service': 'vimeo',
|
'service': 'vimeo',
|
||||||
'token': token,
|
'token': token,
|
||||||
})
|
}
|
||||||
login_request = sanitized_Request(self._LOGIN_URL, data)
|
|
||||||
login_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
|
|
||||||
login_request.add_header('Referer', self._LOGIN_URL)
|
|
||||||
self._set_vimeo_cookie('vuid', vuid)
|
self._set_vimeo_cookie('vuid', vuid)
|
||||||
self._download_webpage(login_request, None, False, 'Wrong login info')
|
try:
|
||||||
|
self._download_webpage(
|
||||||
|
self._LOGIN_URL, None, 'Logging in',
|
||||||
|
data=urlencode_postdata(data), headers={
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
'Referer': self._LOGIN_URL,
|
||||||
|
})
|
||||||
|
except ExtractorError as e:
|
||||||
|
if isinstance(e.cause, compat_HTTPError) and e.cause.code == 418:
|
||||||
|
raise ExtractorError(
|
||||||
|
'Unable to log in: bad username or password',
|
||||||
|
expected=True)
|
||||||
|
raise ExtractorError('Unable to log in')
|
||||||
|
|
||||||
def _verify_video_password(self, url, video_id, webpage):
|
def _verify_video_password(self, url, video_id, webpage):
|
||||||
password = self._downloader.params.get('videopassword')
|
password = self._downloader.params.get('videopassword')
|
||||||
|
Loading…
Reference in New Issue
Block a user