Skip to content

Commit

Permalink
[vimeo] Fix video password verification for videos protected by Refer…
Browse files Browse the repository at this point in the history
…er HTTP header
  • Loading branch information
dstftw committed Jan 20, 2019
1 parent 73c19aa commit a1a4607
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions youtube_dl/extractor/vimeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ class VimeoIE(VimeoBaseInfoExtractor):
'url': 'https://vimeo.com/160743502/abd0e13fb4',
'only_matching': True,
}
# https://gettingthingsdone.com/workflowmap/
# vimeo embed with check-password page protected by Referer header
]

@staticmethod
Expand Down Expand Up @@ -465,20 +467,22 @@ def _extract_url(url, webpage):
urls = VimeoIE._extract_urls(url, webpage)
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')
if password is None:
raise ExtractorError('This video is protected by a password, use the --video-password option')
data = urlencode_postdata({
'password': base64.b64encode(password.encode()),
})
pass_url = url + '/check-password'
password_request = sanitized_Request(pass_url, data)
password_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
password_request.add_header('Referer', url)
return self._download_json(
password_request, video_id,
'Verifying the password', 'Wrong password')
headers = merge_dicts(headers, {
'Content-Type': 'application/x-www-form-urlencoded',
})
checked = self._download_json(
url + '/check-password', video_id,
'Verifying the password', data=data, headers=headers)
if checked is False:
raise ExtractorError('Wrong video password', expected=True)
return checked

def _real_initialize(self):
self._login()
Expand Down Expand Up @@ -591,7 +595,7 @@ def _real_extract(self, url):
cause=e)
else:
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', {})

Expand Down

0 comments on commit a1a4607

Please sign in to comment.