[vimeo] Fix video password verification for videos protected by Referer HTTP header

This commit is contained in:
Sergey M․ 2019-01-20 18:21:31 +07:00
parent 73c19aaa9f
commit a1a4607598
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

View File

@ -435,6 +435,8 @@ class VimeoIE(VimeoBaseInfoExtractor):
'url': 'https://vimeo.com/160743502/abd0e13fb4', 'url': 'https://vimeo.com/160743502/abd0e13fb4',
'only_matching': True, 'only_matching': True,
} }
# https://gettingthingsdone.com/workflowmap/
# vimeo embed with check-password page protected by Referer header
] ]
@staticmethod @staticmethod
@ -465,20 +467,22 @@ def _extract_url(url, webpage):
urls = VimeoIE._extract_urls(url, webpage) urls = VimeoIE._extract_urls(url, webpage)
return urls[0] if urls else None return urls[0] if urls else None
def _verify_player_video_password(self, url, video_id): def _verify_player_video_password(self, url, video_id, headers):
password = self._downloader.params.get('videopassword') password = self._downloader.params.get('videopassword')
if password is None: if password is None:
raise ExtractorError('This video is protected by a password, use the --video-password option') raise ExtractorError('This video is protected by a password, use the --video-password option')
data = urlencode_postdata({ data = urlencode_postdata({
'password': base64.b64encode(password.encode()), 'password': base64.b64encode(password.encode()),
}) })
pass_url = url + '/check-password' headers = merge_dicts(headers, {
password_request = sanitized_Request(pass_url, data) 'Content-Type': 'application/x-www-form-urlencoded',
password_request.add_header('Content-Type', 'application/x-www-form-urlencoded') })
password_request.add_header('Referer', url) checked = self._download_json(
return self._download_json( url + '/check-password', video_id,
password_request, video_id, 'Verifying the password', data=data, headers=headers)
'Verifying the password', 'Wrong password') if checked is False:
raise ExtractorError('Wrong video password', expected=True)
return checked
def _real_initialize(self): def _real_initialize(self):
self._login() self._login()
@ -591,7 +595,7 @@ def _real_extract(self, url):
cause=e) cause=e)
else: else:
if config.get('view') == 4: if config.get('view') == 4:
config = self._verify_player_video_password(redirect_url, video_id) config = self._verify_player_video_password(redirect_url, video_id, headers)
vod = config.get('video', {}).get('vod', {}) vod = config.get('video', {}).get('vod', {})