mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 17:51:24 +01:00
Compare commits
No commits in common. "e418906bfd3e5142ed9c2ee21286db533139a7b9" and "d644aeb2c344b542284dc3b79eb2223f9b8fc0e2" have entirely different histories.
e418906bfd
...
d644aeb2c3
|
@ -52,7 +52,6 @@ from yt_dlp.networking.exceptions import (
|
|||
)
|
||||
from yt_dlp.networking.impersonate import ImpersonateRequestHandler, ImpersonateTarget
|
||||
from yt_dlp.utils._utils import _YDLLogger as FakeLogger
|
||||
from yt_dlp.utils import YoutubeDLError
|
||||
from yt_dlp.utils.networking import (
|
||||
HTTPHeaderDict,
|
||||
std_headers,
|
||||
|
@ -763,18 +762,6 @@ class TestClientCertificate:
|
|||
})
|
||||
|
||||
|
||||
@pytest.mark.parametrize('handler', ['CurlCFFI'], indirect=True)
|
||||
class TestHTTPImpersonateRequestHandler(TestRequestHandlerBase):
|
||||
def test_supported_impersonate_targets(self, handler):
|
||||
with handler(headers=std_headers) as rh:
|
||||
# note: this assumes the impersonate request handler supports the impersonate extension
|
||||
for target in rh.supported_targets:
|
||||
res = validate_and_send(rh, Request(
|
||||
f'http://127.0.0.1:{self.http_port}/headers', extensions={'impersonate': target}))
|
||||
assert res.status == 200
|
||||
assert std_headers['user-agent'].lower() not in res.read().decode().lower()
|
||||
|
||||
|
||||
class TestUrllibRequestHandler(TestRequestHandlerBase):
|
||||
@pytest.mark.parametrize('handler', ['Urllib'], indirect=True)
|
||||
def test_file_urls(self, handler):
|
||||
|
@ -1457,7 +1444,7 @@ class TestYoutubeDLNetworking:
|
|||
with FakeImpersonationRHYDL() as ydl:
|
||||
with pytest.raises(
|
||||
RequestError,
|
||||
match=r'Impersonate target "test" is not available'
|
||||
match=r'Impersonate target "test" is not available. This request requires browser impersonation'
|
||||
):
|
||||
ydl.urlopen(Request('http://', extensions={'impersonate': ImpersonateTarget('test', None, None, None)}))
|
||||
|
||||
|
@ -1478,14 +1465,14 @@ class TestYoutubeDLNetworking:
|
|||
with FakeHTTPRHYDL() as ydl:
|
||||
with pytest.raises(
|
||||
RequestError,
|
||||
match=r'Impersonate target "test" is not available'
|
||||
match=r'Impersonate target "test" is not available. This request requires browser impersonation'
|
||||
):
|
||||
ydl.urlopen(Request('http://', extensions={'impersonate': ImpersonateTarget('test', None, None, None)}))
|
||||
|
||||
def test_raise_impersonate_error(self):
|
||||
with pytest.raises(
|
||||
YoutubeDLError,
|
||||
match=r'Impersonate target "test" is not available'
|
||||
ValueError,
|
||||
match=r'Impersonate target "test" is not available. Use --list-impersonate-targets to see available targets.'
|
||||
):
|
||||
FakeYDL({'impersonate': ImpersonateTarget('test', None, None, None)})
|
||||
|
||||
|
|
|
@ -112,11 +112,11 @@ class CurlCFFIRH(ImpersonateRequestHandler, InstanceStoreMixin):
|
|||
ImpersonateTarget('chrome', '104', 'windows', '10'): curl_cffi.requests.BrowserType.chrome104,
|
||||
ImpersonateTarget('chrome', '101', 'windows', '10'): curl_cffi.requests.BrowserType.chrome101,
|
||||
ImpersonateTarget('chrome', '99', 'windows', '10'): curl_cffi.requests.BrowserType.chrome99,
|
||||
ImpersonateTarget('chrome', '99', 'android', '12'): curl_cffi.requests.BrowserType.chrome99_android,
|
||||
ImpersonateTarget('edge', '101', 'windows', '10'): curl_cffi.requests.BrowserType.edge101,
|
||||
ImpersonateTarget('edge', '99', 'windows', '10'): curl_cffi.requests.BrowserType.edge99,
|
||||
ImpersonateTarget('safari', '15.5', 'macos', '12'): curl_cffi.requests.BrowserType.safari15_5,
|
||||
ImpersonateTarget('safari', '15.3', 'macos', '11'): curl_cffi.requests.BrowserType.safari15_3,
|
||||
ImpersonateTarget('chrome', '99', 'android', '12'): curl_cffi.requests.BrowserType.chrome99_android,
|
||||
ImpersonateTarget('safari', '15.5', 'macos', '12.4'): curl_cffi.requests.BrowserType.safari15_5,
|
||||
ImpersonateTarget('safari', '15.3', 'macos', '11.6.4'): curl_cffi.requests.BrowserType.safari15_3,
|
||||
}
|
||||
|
||||
def _create_instance(self, cookiejar=None):
|
||||
|
|
Loading…
Reference in New Issue
Block a user