Compare commits

...

3 Commits

1 changed files with 19 additions and 6 deletions

View File

@ -42,6 +42,19 @@ class VimeoBaseInfoExtractor(InfoExtractor):
_LOGIN_REQUIRED = False
_LOGIN_URL = 'https://vimeo.com/log_in'
@staticmethod
# none of the standard library or utils.py routines does this
# join a path to a URL, removing query, fragment, with 1 / between
def _join_url(url, path):
url = compat_urlparse.urlunsplit(compat_urlparse.urlsplit(url)[:3] + (None, None))
if path:
if url.endswith('/') and path.startswith('/'):
url = url[:-1]
elif not url.endswith('/') and not path.startswith('/'):
url += '/'
return url + path
return url
def _login(self):
username, password = self._get_login_info()
if username is None:
@ -64,7 +77,7 @@ class VimeoBaseInfoExtractor(InfoExtractor):
self._LOGIN_URL, None, 'Logging in',
data=urlencode_postdata(data), headers={
'Content-Type': 'application/x-www-form-urlencoded',
'Referer': self._LOGIN_URL,
'Referer': compat_urlparse.urldefrag(self._LOGIN_URL),
})
except ExtractorError as e:
if isinstance(e.cause, compat_HTTPError) and e.cause.code == 418:
@ -87,7 +100,7 @@ class VimeoBaseInfoExtractor(InfoExtractor):
url = url.replace('http://', 'https://')
self._set_vimeo_cookie('vuid', vuid)
return self._download_webpage(
url + '/password', video_id, 'Verifying the password',
self._join_url(url, '/password'), video_id, 'Verifying the password',
'Wrong password', data=urlencode_postdata({
'password': password,
'token': token,
@ -345,7 +358,7 @@ class VimeoIE(VimeoBaseInfoExtractor):
'expected_warnings': ['Unable to download JSON metadata'],
},
{
'url': 'http://vimeo.com/68375962',
'url': 'http://vimeo.com/68375962?loop=0',
'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7',
'note': 'Video protected with password',
'info_dict': {
@ -479,7 +492,7 @@ class VimeoIE(VimeoBaseInfoExtractor):
'skip': 'this page is no longer available.',
},
{
'url': 'http://player.vimeo.com/video/68375962',
'url': 'http://player.vimeo.com/video/68375962?loop=0',
'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7',
'info_dict': {
'id': '68375962',
@ -567,7 +580,7 @@ class VimeoIE(VimeoBaseInfoExtractor):
'Content-Type': 'application/x-www-form-urlencoded',
})
checked = self._download_json(
url + '/check-password', video_id,
self._join_url(url, '/check-password'), video_id,
'Verifying the password', data=data, headers=headers)
if checked is False:
raise ExtractorError('Wrong video password', expected=True)
@ -613,7 +626,7 @@ class VimeoIE(VimeoBaseInfoExtractor):
if 'http_headers' in data:
headers.update(data['http_headers'])
if 'Referer' not in headers:
headers['Referer'] = url
headers['Referer'] = compat_urlparse.urldefrag(url)
mobj = re.match(self._VALID_URL, url).groupdict()
video_id, unlisted_hash = mobj['id'], mobj.get('unlisted_hash')