mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-12-25 21:59:04 +01:00
[ie/vimeo] Support browser impersonation (#10327)
Some checks are pending
CodeQL / Analyze (python) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, 3.10) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, 3.11) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, 3.12) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, 3.9) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, pypy-3.10) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, pypy-3.8) (push) Waiting to run
Core Tests / Core Tests (windows-latest, 3.12) (push) Waiting to run
Core Tests / Core Tests (windows-latest, 3.8) (push) Waiting to run
Core Tests / Core Tests (windows-latest, pypy-3.9) (push) Waiting to run
Download Tests / Quick Download Tests (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, 3.10) (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, 3.11) (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, 3.12) (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, pypy-3.10) (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, pypy-3.8) (push) Waiting to run
Download Tests / Full Download Tests (windows-latest, 3.8) (push) Waiting to run
Download Tests / Full Download Tests (windows-latest, pypy-3.9) (push) Waiting to run
Quick Test / Core Test (push) Waiting to run
Quick Test / Code check (push) Waiting to run
Release (master) / release (push) Waiting to run
Some checks are pending
CodeQL / Analyze (python) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, 3.10) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, 3.11) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, 3.12) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, 3.9) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, pypy-3.10) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, pypy-3.8) (push) Waiting to run
Core Tests / Core Tests (windows-latest, 3.12) (push) Waiting to run
Core Tests / Core Tests (windows-latest, 3.8) (push) Waiting to run
Core Tests / Core Tests (windows-latest, pypy-3.9) (push) Waiting to run
Download Tests / Quick Download Tests (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, 3.10) (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, 3.11) (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, 3.12) (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, pypy-3.10) (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, pypy-3.8) (push) Waiting to run
Download Tests / Full Download Tests (windows-latest, 3.8) (push) Waiting to run
Download Tests / Full Download Tests (windows-latest, pypy-3.9) (push) Waiting to run
Quick Test / Core Test (push) Waiting to run
Quick Test / Code check (push) Waiting to run
Release (master) / release (push) Waiting to run
Closes #10325 Authored by: bashonly
This commit is contained in:
parent
1d6ab17d07
commit
d4b99a2333
2 changed files with 25 additions and 12 deletions
|
@ -316,7 +316,8 @@ class PatreonIE(PatreonBaseIE):
|
||||||
r'(https(?:%3A%2F%2F|://)player\.vimeo\.com.+app_id(?:=|%3D)+\d+)',
|
r'(https(?:%3A%2F%2F|://)player\.vimeo\.com.+app_id(?:=|%3D)+\d+)',
|
||||||
traverse_obj(attributes, ('embed', 'html', {str})), 'vimeo url', fatal=False) or '')
|
traverse_obj(attributes, ('embed', 'html', {str})), 'vimeo url', fatal=False) or '')
|
||||||
if url_or_none(v_url) and self._request_webpage(
|
if url_or_none(v_url) and self._request_webpage(
|
||||||
v_url, video_id, 'Checking Vimeo embed URL', headers=headers, fatal=False, errnote=False):
|
v_url, video_id, 'Checking Vimeo embed URL', headers=headers,
|
||||||
|
fatal=False, errnote=False, expected_status=429): # 429 is TLS fingerprint rejection
|
||||||
entries.append(self.url_result(
|
entries.append(self.url_result(
|
||||||
VimeoIE._smuggle_referrer(v_url, 'https://patreon.com/'),
|
VimeoIE._smuggle_referrer(v_url, 'https://patreon.com/'),
|
||||||
VimeoIE, url_transparent=True))
|
VimeoIE, url_transparent=True))
|
||||||
|
|
|
@ -829,21 +829,33 @@ class VimeoIE(VimeoBaseInfoExtractor):
|
||||||
url = 'https://vimeo.com/' + video_id
|
url = 'https://vimeo.com/' + video_id
|
||||||
|
|
||||||
self._try_album_password(url)
|
self._try_album_password(url)
|
||||||
|
is_secure = urllib.parse.urlparse(url).scheme == 'https'
|
||||||
try:
|
try:
|
||||||
# Retrieve video webpage to extract further information
|
# Retrieve video webpage to extract further information
|
||||||
webpage, urlh = self._download_webpage_handle(
|
webpage, urlh = self._download_webpage_handle(
|
||||||
url, video_id, headers=headers)
|
url, video_id, headers=headers, impersonate=is_secure)
|
||||||
redirect_url = urlh.url
|
redirect_url = urlh.url
|
||||||
except ExtractorError as ee:
|
except ExtractorError as error:
|
||||||
if isinstance(ee.cause, HTTPError) and ee.cause.status == 403:
|
if not isinstance(error.cause, HTTPError) or error.cause.status not in (403, 429):
|
||||||
errmsg = ee.cause.response.read()
|
raise
|
||||||
if b'Because of its privacy settings, this video cannot be played here' in errmsg:
|
errmsg = error.cause.response.read()
|
||||||
raise ExtractorError(
|
if b'Because of its privacy settings, this video cannot be played here' in errmsg:
|
||||||
'Cannot download embed-only video without embedding '
|
raise ExtractorError(
|
||||||
'URL. Please call yt-dlp with the URL of the page '
|
'Cannot download embed-only video without embedding URL. Please call yt-dlp '
|
||||||
'that embeds this video.',
|
'with the URL of the page that embeds this video.', expected=True)
|
||||||
expected=True)
|
# 403 == vimeo.com TLS fingerprint or DC IP block; 429 == player.vimeo.com TLS FP block
|
||||||
raise
|
status = error.cause.status
|
||||||
|
dcip_msg = 'If you are using a data center IP or VPN/proxy, your IP may be blocked'
|
||||||
|
if target := error.cause.response.extensions.get('impersonate'):
|
||||||
|
raise ExtractorError(
|
||||||
|
f'Got HTTP Error {status} when using impersonate target "{target}". {dcip_msg}')
|
||||||
|
elif not is_secure:
|
||||||
|
raise ExtractorError(f'Got HTTP Error {status}. {dcip_msg}', expected=True)
|
||||||
|
raise ExtractorError(
|
||||||
|
'This request has been blocked due to its TLS fingerprint. Install a '
|
||||||
|
'required impersonation dependency if possible, or else if you are okay with '
|
||||||
|
f'{self._downloader._format_err("compromising your security/cookies", "light red")}, '
|
||||||
|
f'try replacing "https:" with "http:" in the input URL. {dcip_msg}.', expected=True)
|
||||||
|
|
||||||
if '://player.vimeo.com/video/' in url:
|
if '://player.vimeo.com/video/' in url:
|
||||||
config = self._search_json(
|
config = self._search_json(
|
||||||
|
|
Loading…
Reference in a new issue