Compare commits

..

2 Commits

Author SHA1 Message Date
coletdjnz
3ab50a288d
bump min dep 2023-11-14 20:05:12 +13:00
coletdjnz
0dda7cf8a0
fix minor bugs and issues with tests 2023-11-14 20:03:49 +13:00
3 changed files with 9 additions and 8 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.10b3']},
extras_require={'curl_cffi': ['curl-cffi >= 0.5.10b4']},
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': 'chrome110'}),
({'impersonate': 'chrome110'}, {}),
({'impersonate': 'chrome99'}, {'impersonate': 'chrome110'})
({}, {'impersonate': 'chrome:110'}),
({'impersonate': 'chrome:110'}, {}),
({'impersonate': 'chrome:99'}, {'impersonate': 'chrome:110'})
])
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': 'safari15_3'}, headers={'x-custom': 'test', 'sec-fetch-mode': 'custom'})).read().decode().lower()
'impersonate': 'safari'}, 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': 'chrome110'}, False)
({'impersonate': 'chrome'}, 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 target
return supported_target
def get_supported_targets(self) -> tuple[str]:
return tuple(compile_impersonate_target(*target) for target in self._get_supported_target_tuples())
@ -143,8 +143,9 @@ 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(
self._resolve_target_tuple(self._get_target_tuple(request)), None)
resolved_target, None)
def _get_impersonate_headers(self, request):
headers = self._merge_headers(request.headers)