mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-09 14:11:55 -04:00
only use secrets with 200 and 401 status code (#781)
This commit is contained in:
parent
e44ded42ff
commit
3a3f649815
1 changed files with 15 additions and 1 deletions
|
@ -382,8 +382,22 @@ class QobuzClient(Client):
|
||||||
async with QobuzSpoofer() as spoofer:
|
async with QobuzSpoofer() as spoofer:
|
||||||
return await spoofer.get_app_id_and_secrets()
|
return await spoofer.get_app_id_and_secrets()
|
||||||
|
|
||||||
|
async def _test_secret(self, secret: str) -> Optional[str]:
|
||||||
|
status, _ = await self._request_file_url("19512574", 4, secret)
|
||||||
|
if status == 400:
|
||||||
|
return None
|
||||||
|
if status == 200 or status == 401:
|
||||||
|
return secret
|
||||||
|
logger.warning("Got status %d when testing secret", status)
|
||||||
|
return None
|
||||||
|
|
||||||
async def _get_valid_secret(self, secrets: list[str]) -> str:
|
async def _get_valid_secret(self, secrets: list[str]) -> str:
|
||||||
working_secrets = [r for r in secrets]
|
results = await asyncio.gather(
|
||||||
|
*[self._test_secret(secret) for secret in secrets],
|
||||||
|
)
|
||||||
|
working_secrets = [r for r in results if r is not None]
|
||||||
|
if len(working_secrets) == 0:
|
||||||
|
raise InvalidAppSecretError(secrets)
|
||||||
|
|
||||||
return working_secrets[0]
|
return working_secrets[0]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue