This commit is contained in:
@@ -51,6 +51,9 @@ spoticlub_password = "IfWeFeelLikeEnablingThis"
|
|||||||
### SPOTICLUB CLIENT SERIAL TRACKING (DO NOT EDIT) ###
|
### SPOTICLUB CLIENT SERIAL TRACKING (DO NOT EDIT) ###
|
||||||
spoticlub_client_serial: typing.Optional[str] = None
|
spoticlub_client_serial: typing.Optional[str] = None
|
||||||
spoticlub_loaded_logged: bool = False
|
spoticlub_loaded_logged: bool = False
|
||||||
|
_spoticlub_audio_key_loader_enabled: bool = False
|
||||||
|
_spoticlub_audio_key_loader_lock = threading.Lock()
|
||||||
|
########################################
|
||||||
|
|
||||||
def _spoticlub_notify_session_done() -> None:
|
def _spoticlub_notify_session_done() -> None:
|
||||||
global spoticlub_user, spoticlub_password, spoticlub_client_serial
|
global spoticlub_user, spoticlub_password, spoticlub_client_serial
|
||||||
@@ -71,7 +74,6 @@ def _spoticlub_notify_session_done() -> None:
|
|||||||
exc_info=True,
|
exc_info=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
atexit.register(_spoticlub_notify_session_done)
|
atexit.register(_spoticlub_notify_session_done)
|
||||||
########################################
|
########################################
|
||||||
|
|
||||||
@@ -442,6 +444,9 @@ class AudioKeyManager(PacketsReceiver, Closeable):
|
|||||||
try:
|
try:
|
||||||
from zotify.loader import Loader
|
from zotify.loader import Loader
|
||||||
from zotify.termoutput import PrintChannel
|
from zotify.termoutput import PrintChannel
|
||||||
|
with _spoticlub_audio_key_loader_lock:
|
||||||
|
show_loader = _spoticlub_audio_key_loader_enabled
|
||||||
|
if show_loader:
|
||||||
audio_key_loader = Loader(PrintChannel.PROGRESS_INFO, "Fetching audio key...").start()
|
audio_key_loader = Loader(PrintChannel.PROGRESS_INFO, "Fetching audio key...").start()
|
||||||
except Exception:
|
except Exception:
|
||||||
audio_key_loader = None
|
audio_key_loader = None
|
||||||
@@ -488,7 +493,7 @@ class AudioKeyManager(PacketsReceiver, Closeable):
|
|||||||
if isinstance(country, str):
|
if isinstance(country, str):
|
||||||
if AudioKeyManager._spoticlub_current_country != country:
|
if AudioKeyManager._spoticlub_current_country != country:
|
||||||
AudioKeyManager._spoticlub_current_country = country
|
AudioKeyManager._spoticlub_current_country = country
|
||||||
print(f"\n[SpotiClub API] Received {country} as the download country\n")
|
print(f"\n\n[SpotiClub API] Received {country} as the download country\n\n")
|
||||||
|
|
||||||
new_serial = data.get("client_serial")
|
new_serial = data.get("client_serial")
|
||||||
if isinstance(new_serial, str) and new_serial:
|
if isinstance(new_serial, str) and new_serial:
|
||||||
@@ -497,6 +502,10 @@ class AudioKeyManager(PacketsReceiver, Closeable):
|
|||||||
key_bytes = util.hex_to_bytes(key_hex)
|
key_bytes = util.hex_to_bytes(key_hex)
|
||||||
if len(key_bytes) != 16:
|
if len(key_bytes) != 16:
|
||||||
raise RuntimeError("[SpotiClub API] Woops, received Audio Key must be 16 bytes long")
|
raise RuntimeError("[SpotiClub API] Woops, received Audio Key must be 16 bytes long")
|
||||||
|
|
||||||
|
# After the first successful SpotiClub key fetch, enable the loader for future calls.
|
||||||
|
with _spoticlub_audio_key_loader_lock:
|
||||||
|
_spoticlub_audio_key_loader_enabled = True
|
||||||
return key_bytes
|
return key_bytes
|
||||||
except Exception as exc: # noqa: BLE001
|
except Exception as exc: # noqa: BLE001
|
||||||
last_err = exc
|
last_err = exc
|
||||||
|
|||||||
Reference in New Issue
Block a user