fix: spotify_credentials_path in deezer class
This commit is contained in:
@@ -91,6 +91,7 @@ class DeeLogin:
|
|||||||
password=None,
|
password=None,
|
||||||
spotify_client_id=None,
|
spotify_client_id=None,
|
||||||
spotify_client_secret=None,
|
spotify_client_secret=None,
|
||||||
|
spotify_credentials_path=None,
|
||||||
progress_callback=None,
|
progress_callback=None,
|
||||||
silent=False
|
silent=False
|
||||||
) -> None:
|
) -> None:
|
||||||
@@ -98,8 +99,12 @@ class DeeLogin:
|
|||||||
# Store Spotify credentials
|
# Store Spotify credentials
|
||||||
self.spotify_client_id = spotify_client_id
|
self.spotify_client_id = spotify_client_id
|
||||||
self.spotify_client_secret = spotify_client_secret
|
self.spotify_client_secret = spotify_client_secret
|
||||||
# Optional path to Spotify credentials.json (env override or CWD default)
|
# Optional path to Spotify credentials.json (explicit param > env override > CWD default)
|
||||||
self.spotify_credentials_path = os.environ.get("SPOTIFY_CREDENTIALS_PATH") or os.path.join(os.getcwd(), "credentials.json")
|
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
|
# Initialize Spotify API if credentials are provided
|
||||||
if spotify_client_id and spotify_client_secret:
|
if spotify_client_id and spotify_client_secret:
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import base64
|
import base64
|
||||||
import datetime
|
import datetime
|
||||||
|
import time
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
from typing import Any, Dict, List, Optional, Union
|
from typing import Any, Dict, List, Optional, Union
|
||||||
|
|
||||||
@@ -144,7 +145,16 @@ class LibrespotClient:
|
|||||||
)
|
)
|
||||||
builder = Session.Builder(conf)
|
builder = Session.Builder(conf)
|
||||||
builder.stored_file(stored_credentials_path)
|
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:
|
def _get_session_country_code(self) -> str:
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user