Compare commits

...

2 Commits

Author SHA1 Message Date
bashonly
81bdea03f3
[ie/soundcloud] Fix client ID extraction (#16019)
Authored by: bashonly
2026-02-21 00:21:29 +00:00
bashonly
e74076141d
[rh:curl_cffi] Deprioritize unreliable impersonate targets (#16018)
Closes #16012
Authored by: bashonly
2026-02-20 23:48:16 +00:00
2 changed files with 17 additions and 5 deletions

View File

@ -118,9 +118,9 @@ class SoundcloudBaseIE(InfoExtractor):
self.cache.store('soundcloud', 'client_id', client_id)
def _update_client_id(self):
webpage = self._download_webpage('https://soundcloud.com/', None)
webpage = self._download_webpage('https://soundcloud.com/', None, 'Downloading main page')
for src in reversed(re.findall(r'<script[^>]+src="([^"]+)"', webpage)):
script = self._download_webpage(src, None, fatal=False)
script = self._download_webpage(src, None, 'Downloading JS asset', fatal=False)
if script:
client_id = self._search_regex(
r'client_id\s*:\s*"([0-9a-zA-Z]{32})"',
@ -136,13 +136,13 @@ class SoundcloudBaseIE(InfoExtractor):
if non_fatal:
del kwargs['fatal']
query = kwargs.get('query', {}).copy()
for _ in range(2):
for is_first_attempt in (True, False):
query['client_id'] = self._CLIENT_ID
kwargs['query'] = query
try:
return self._download_json(*args, **kwargs)
except ExtractorError as e:
if isinstance(e.cause, HTTPError) and e.cause.status in (401, 403):
if is_first_attempt and isinstance(e.cause, HTTPError) and e.cause.status in (401, 403):
self._store_client_id(None)
self._update_client_id()
continue
@ -152,7 +152,10 @@ class SoundcloudBaseIE(InfoExtractor):
raise
def _initialize_pre_login(self):
self._CLIENT_ID = self.cache.load('soundcloud', 'client_id') or 'a3e059563d7fd3372b49b37f00a00bcf'
self._CLIENT_ID = self.cache.load('soundcloud', 'client_id')
if self._CLIENT_ID:
return
self._update_client_id()
def _verify_oauth_token(self, token):
if self._request_webpage(

View File

@ -175,6 +175,13 @@ _TARGETS_COMPAT_LOOKUP = {
'safari180_ios': 'safari18_0_ios',
}
# These targets are known to be insufficient, unreliable or blocked
# See: https://github.com/yt-dlp/yt-dlp/issues/16012
_DEPRIORITIZED_TARGETS = {
ImpersonateTarget('chrome', '133', 'macos', '15'), # chrome133a
ImpersonateTarget('chrome', '136', 'macos', '15'), # chrome136
}
@register_rh
class CurlCFFIRH(ImpersonateRequestHandler, InstanceStoreMixin):
@ -192,6 +199,8 @@ class CurlCFFIRH(ImpersonateRequestHandler, InstanceStoreMixin):
for version, targets in BROWSER_TARGETS.items()
if curl_cffi_version >= version
), key=lambda x: (
# deprioritize unreliable targets so they are not selected by default
x[1] not in _DEPRIORITIZED_TARGETS,
# deprioritize mobile targets since they give very different behavior
x[1].os not in ('ios', 'android'),
# prioritize tor < edge < firefox < safari < chrome