mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-02-22 08:26:00 +00:00
[ie/soundcloud] Fix client ID extraction (#16019)
Authored by: bashonly
This commit is contained in:
@@ -118,9 +118,9 @@ class SoundcloudBaseIE(InfoExtractor):
|
|||||||
self.cache.store('soundcloud', 'client_id', client_id)
|
self.cache.store('soundcloud', 'client_id', client_id)
|
||||||
|
|
||||||
def _update_client_id(self):
|
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)):
|
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:
|
if script:
|
||||||
client_id = self._search_regex(
|
client_id = self._search_regex(
|
||||||
r'client_id\s*:\s*"([0-9a-zA-Z]{32})"',
|
r'client_id\s*:\s*"([0-9a-zA-Z]{32})"',
|
||||||
@@ -136,13 +136,13 @@ class SoundcloudBaseIE(InfoExtractor):
|
|||||||
if non_fatal:
|
if non_fatal:
|
||||||
del kwargs['fatal']
|
del kwargs['fatal']
|
||||||
query = kwargs.get('query', {}).copy()
|
query = kwargs.get('query', {}).copy()
|
||||||
for _ in range(2):
|
for is_first_attempt in (True, False):
|
||||||
query['client_id'] = self._CLIENT_ID
|
query['client_id'] = self._CLIENT_ID
|
||||||
kwargs['query'] = query
|
kwargs['query'] = query
|
||||||
try:
|
try:
|
||||||
return self._download_json(*args, **kwargs)
|
return self._download_json(*args, **kwargs)
|
||||||
except ExtractorError as e:
|
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._store_client_id(None)
|
||||||
self._update_client_id()
|
self._update_client_id()
|
||||||
continue
|
continue
|
||||||
@@ -152,7 +152,10 @@ class SoundcloudBaseIE(InfoExtractor):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
def _initialize_pre_login(self):
|
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):
|
def _verify_oauth_token(self, token):
|
||||||
if self._request_webpage(
|
if self._request_webpage(
|
||||||
|
|||||||
Reference in New Issue
Block a user