Compare commits

..

No commits in common. "3ab50a288dd7af3e80f2660531f2e1d550bba3c5" and "7ce9d33cc2ec64441009492e5fe6ff0d55db1e97" have entirely different histories.

3 changed files with 8 additions and 9 deletions

View File

@ -152,7 +152,7 @@ def main():
url='https://github.com/yt-dlp/yt-dlp',
packages=packages(),
install_requires=REQUIREMENTS,
extras_require={'curl_cffi': ['curl-cffi >= 0.5.10b4']},
extras_require={'curl_cffi': ['curl-cffi >= 0.5.10b3']},
python_requires='>=3.7',
project_urls={
'Documentation': 'https://github.com/yt-dlp/yt-dlp#readme',

View File

@ -891,9 +891,9 @@ class TestCurlCFFIRequestHandler(TestRequestHandlerBase):
@pytest.mark.parametrize('handler', ['CurlCFFI'], indirect=True)
@pytest.mark.parametrize('params,extensions', [
({}, {'impersonate': 'chrome:110'}),
({'impersonate': 'chrome:110'}, {}),
({'impersonate': 'chrome:99'}, {'impersonate': 'chrome:110'})
({}, {'impersonate': 'chrome110'}),
({'impersonate': 'chrome110'}, {}),
({'impersonate': 'chrome99'}, {'impersonate': 'chrome110'})
])
def test_impersonate(self, handler, params, extensions):
with handler(headers=std_headers, **params) as rh:
@ -909,7 +909,7 @@ class TestCurlCFFIRequestHandler(TestRequestHandlerBase):
# Ensure curl-impersonate overrides our standard headers (usually added
res = validate_and_send(
rh, Request(f'http://127.0.0.1:{self.http_port}/headers', extensions={
'impersonate': 'safari'}, headers={'x-custom': 'test', 'sec-fetch-mode': 'custom'})).read().decode().lower()
'impersonate': 'safari15_3'}, headers={'x-custom': 'test', 'sec-fetch-mode': 'custom'})).read().decode().lower()
assert std_headers['user-agent'].lower() not in res
assert std_headers['accept-language'].lower() not in res
@ -1047,7 +1047,7 @@ class TestRequestHandlerValidation:
({'unsupported': 'value'}, UnsupportedRequest),
({'impersonate': 'badtarget'}, UnsupportedRequest),
({'impersonate': 123}, AssertionError),
({'impersonate': 'chrome'}, False)
({'impersonate': 'chrome110'}, False)
]),
(NoCheckRH, [
({'cookiejar': 'notacookiejar'}, False),

View File

@ -120,7 +120,7 @@ class ImpersonateRequestHandler(RequestHandler, ABC):
self._logger.stdout(
f'{self.RH_NAME}: resolved impersonate target "{compile_impersonate_target(*target)}" '
f'to "{compile_impersonate_target(*supported_target)}"')
return supported_target
return target
def get_supported_targets(self) -> tuple[str]:
return tuple(compile_impersonate_target(*target) for target in self._get_supported_target_tuples())
@ -143,9 +143,8 @@ class ImpersonateRequestHandler(RequestHandler, ABC):
def _get_mapped_target(self, request):
"""Get the resolved mapped target for the request target"""
resolved_target = self._resolve_target_tuple(self._get_target_tuple(request))
return self._SUPPORTED_IMPERSONATE_TARGET_TUPLE_MAP.get(
resolved_target, None)
self._resolve_target_tuple(self._get_target_tuple(request)), None)
def _get_impersonate_headers(self, request):
headers = self._merge_headers(request.headers)