mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-09-06 03:35:13 +02:00
[vimeo] Use compat_urllib_request_Request
This commit is contained in:
parent
82d8a8b6e2
commit
e4c4bcf36f
@ -8,7 +8,7 @@ import itertools
|
|||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import (
|
from ..compat import (
|
||||||
compat_HTTPError,
|
compat_HTTPError,
|
||||||
compat_urllib_request,
|
compat_urllib_request_Request,
|
||||||
compat_urlparse,
|
compat_urlparse,
|
||||||
)
|
)
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
@ -47,7 +47,7 @@ class VimeoBaseInfoExtractor(InfoExtractor):
|
|||||||
'service': 'vimeo',
|
'service': 'vimeo',
|
||||||
'token': token,
|
'token': token,
|
||||||
}))
|
}))
|
||||||
login_request = compat_urllib_request.Request(self._LOGIN_URL, data)
|
login_request = compat_urllib_request_Request(self._LOGIN_URL, data)
|
||||||
login_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
|
login_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
|
||||||
login_request.add_header('Referer', self._LOGIN_URL)
|
login_request.add_header('Referer', self._LOGIN_URL)
|
||||||
self._set_vimeo_cookie('vuid', vuid)
|
self._set_vimeo_cookie('vuid', vuid)
|
||||||
@ -222,7 +222,7 @@ class VimeoIE(VimeoBaseInfoExtractor):
|
|||||||
if url.startswith('http://'):
|
if url.startswith('http://'):
|
||||||
# vimeo only supports https now, but the user can give an http url
|
# vimeo only supports https now, but the user can give an http url
|
||||||
url = url.replace('http://', 'https://')
|
url = url.replace('http://', 'https://')
|
||||||
password_request = compat_urllib_request.Request(url + '/password', data)
|
password_request = compat_urllib_request_Request(url + '/password', data)
|
||||||
password_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
|
password_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
|
||||||
password_request.add_header('Referer', url)
|
password_request.add_header('Referer', url)
|
||||||
self._set_vimeo_cookie('vuid', vuid)
|
self._set_vimeo_cookie('vuid', vuid)
|
||||||
@ -236,7 +236,7 @@ class VimeoIE(VimeoBaseInfoExtractor):
|
|||||||
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(encode_dict({'password': password}))
|
data = urlencode_postdata(encode_dict({'password': password}))
|
||||||
pass_url = url + '/check-password'
|
pass_url = url + '/check-password'
|
||||||
password_request = compat_urllib_request.Request(pass_url, data)
|
password_request = compat_urllib_request_Request(pass_url, data)
|
||||||
password_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
|
password_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
|
||||||
return self._download_json(
|
return self._download_json(
|
||||||
password_request, video_id,
|
password_request, video_id,
|
||||||
@ -265,7 +265,7 @@ class VimeoIE(VimeoBaseInfoExtractor):
|
|||||||
url = 'https://vimeo.com/' + video_id
|
url = 'https://vimeo.com/' + video_id
|
||||||
|
|
||||||
# Retrieve video webpage to extract further information
|
# Retrieve video webpage to extract further information
|
||||||
request = compat_urllib_request.Request(url, None, headers)
|
request = compat_urllib_request_Request(url, None, headers)
|
||||||
try:
|
try:
|
||||||
webpage = self._download_webpage(request, video_id)
|
webpage = self._download_webpage(request, video_id)
|
||||||
except ExtractorError as ee:
|
except ExtractorError as ee:
|
||||||
@ -481,7 +481,7 @@ class VimeoChannelIE(VimeoBaseInfoExtractor):
|
|||||||
password_path = self._search_regex(
|
password_path = self._search_regex(
|
||||||
r'action="([^"]+)"', login_form, 'password URL')
|
r'action="([^"]+)"', login_form, 'password URL')
|
||||||
password_url = compat_urlparse.urljoin(page_url, password_path)
|
password_url = compat_urlparse.urljoin(page_url, password_path)
|
||||||
password_request = compat_urllib_request.Request(password_url, post)
|
password_request = compat_urllib_request_Request(password_url, post)
|
||||||
password_request.add_header('Content-type', 'application/x-www-form-urlencoded')
|
password_request.add_header('Content-type', 'application/x-www-form-urlencoded')
|
||||||
self._set_vimeo_cookie('vuid', vuid)
|
self._set_vimeo_cookie('vuid', vuid)
|
||||||
self._set_vimeo_cookie('xsrft', token)
|
self._set_vimeo_cookie('xsrft', token)
|
||||||
@ -640,7 +640,7 @@ class VimeoWatchLaterIE(VimeoChannelIE):
|
|||||||
|
|
||||||
def _page_url(self, base_url, pagenum):
|
def _page_url(self, base_url, pagenum):
|
||||||
url = '%s/page:%d/' % (base_url, pagenum)
|
url = '%s/page:%d/' % (base_url, pagenum)
|
||||||
request = compat_urllib_request.Request(url)
|
request = compat_urllib_request_Request(url)
|
||||||
# Set the header to get a partial html page with the ids,
|
# Set the header to get a partial html page with the ids,
|
||||||
# the normal page doesn't contain them.
|
# the normal page doesn't contain them.
|
||||||
request.add_header('X-Requested-With', 'XMLHttpRequest')
|
request.add_header('X-Requested-With', 'XMLHttpRequest')
|
||||||
|
Loading…
Reference in New Issue
Block a user