fix: spotify_credentials_path in deezer class

This commit is contained in:
Xoconoch
2025-08-28 07:37:34 -06:00
parent 6d33201a71
commit 4ef72a91e5
2 changed files with 18 additions and 3 deletions

View File

@@ -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:

View File

@@ -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: