mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-07 07:51:26 +01:00
Compare commits
2 Commits
7ce9d33cc2
...
3ab50a288d
Author | SHA1 | Date | |
---|---|---|---|
|
3ab50a288d | ||
|
0dda7cf8a0 |
2
setup.py
2
setup.py
|
@ -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',
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user