From 4ef72a91e5f6bbbf9a28e0bf9c280ba5f0c8de7c Mon Sep 17 00:00:00 2001 From: Xoconoch Date: Thu, 28 Aug 2025 07:37:34 -0600 Subject: [PATCH] fix: spotify_credentials_path in deezer class --- deezspot/deezloader/__init__.py | 9 +++++++-- deezspot/libutils/librespot.py | 12 +++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/deezspot/deezloader/__init__.py b/deezspot/deezloader/__init__.py index e2351cd..1bbbf04 100644 --- a/deezspot/deezloader/__init__.py +++ b/deezspot/deezloader/__init__.py @@ -91,6 +91,7 @@ class DeeLogin: password=None, spotify_client_id=None, spotify_client_secret=None, + spotify_credentials_path=None, progress_callback=None, silent=False ) -> None: @@ -98,8 +99,12 @@ class DeeLogin: # Store Spotify credentials self.spotify_client_id = spotify_client_id self.spotify_client_secret = spotify_client_secret - # Optional path to Spotify credentials.json (env override or CWD default) - self.spotify_credentials_path = os.environ.get("SPOTIFY_CREDENTIALS_PATH") or os.path.join(os.getcwd(), "credentials.json") + # Optional path to Spotify credentials.json (explicit param > env override > CWD default) + self.spotify_credentials_path = ( + spotify_credentials_path + or os.environ.get("SPOTIFY_CREDENTIALS_PATH") + or os.path.join(os.getcwd(), "credentials.json") + ) # Initialize Spotify API if credentials are provided if spotify_client_id and spotify_client_secret: diff --git a/deezspot/libutils/librespot.py b/deezspot/libutils/librespot.py index fc01526..6f7971f 100644 --- a/deezspot/libutils/librespot.py +++ b/deezspot/libutils/librespot.py @@ -2,6 +2,7 @@ from __future__ import annotations import base64 import datetime +import time from concurrent.futures import ThreadPoolExecutor from typing import Any, Dict, List, Optional, Union @@ -144,7 +145,16 @@ class LibrespotClient: ) builder = Session.Builder(conf) builder.stored_file(stored_credentials_path) - return builder.create() + last_exc: Optional[Exception] = None + for attempt in range(1, 4): + try: + return builder.create() + except Exception as exc: + last_exc = exc + if attempt < 3: + time.sleep(1) + else: + raise last_exc def _get_session_country_code(self) -> str: try: