mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-02-01 03:27:03 +00:00
[ie/generic] Improve detection of blockage due to TLS fingerprint (#15426)
Authored by: bashonly
This commit is contained in:
@@ -821,13 +821,17 @@ class GenericIE(InfoExtractor):
|
|||||||
'Referer': smuggled_data.get('referer'),
|
'Referer': smuggled_data.get('referer'),
|
||||||
}), impersonate=impersonate)
|
}), impersonate=impersonate)
|
||||||
except ExtractorError as e:
|
except ExtractorError as e:
|
||||||
if not (isinstance(e.cause, HTTPError) and e.cause.status == 403
|
if not isinstance(e.cause, HTTPError) or e.cause.status != 403:
|
||||||
and e.cause.response.get_header('cf-mitigated') == 'challenge'
|
raise
|
||||||
and e.cause.response.extensions.get('impersonate') is None):
|
res = e.cause.response
|
||||||
|
already_impersonating = res.extensions.get('impersonate') is not None
|
||||||
|
if already_impersonating or (
|
||||||
|
res.get_header('cf-mitigated') != 'challenge'
|
||||||
|
and b'<title>Attention Required! | Cloudflare</title>' not in res.read()
|
||||||
|
):
|
||||||
raise
|
raise
|
||||||
cf_cookie_domain = traverse_obj(
|
cf_cookie_domain = traverse_obj(
|
||||||
LenientSimpleCookie(e.cause.response.get_header('set-cookie')),
|
LenientSimpleCookie(res.get_header('set-cookie')), ('__cf_bm', 'domain'))
|
||||||
('__cf_bm', 'domain'))
|
|
||||||
if cf_cookie_domain:
|
if cf_cookie_domain:
|
||||||
self.write_debug(f'Clearing __cf_bm cookie for {cf_cookie_domain}')
|
self.write_debug(f'Clearing __cf_bm cookie for {cf_cookie_domain}')
|
||||||
self.cookiejar.clear(domain=cf_cookie_domain, path='/', name='__cf_bm')
|
self.cookiejar.clear(domain=cf_cookie_domain, path='/', name='__cf_bm')
|
||||||
|
|||||||
Reference in New Issue
Block a user