changed prgs reporting logic to be SSE
This commit is contained in:
@@ -22,6 +22,9 @@ def download_playlist(
|
||||
progress_callback=None
|
||||
):
|
||||
try:
|
||||
# DEBUG: Print parameters
|
||||
print(f"DEBUG: playlist.py received - service={service}, main={main}, fallback={fallback}")
|
||||
|
||||
# Load Spotify client credentials if available
|
||||
spotify_client_id = None
|
||||
spotify_client_secret = None
|
||||
@@ -30,9 +33,11 @@ def download_playlist(
|
||||
if service == 'spotify' and fallback:
|
||||
# If fallback is enabled, use the fallback account for Spotify search credentials
|
||||
search_creds_path = Path(f'./creds/spotify/{fallback}/search.json')
|
||||
print(f"DEBUG: Using Spotify search credentials from fallback: {search_creds_path}")
|
||||
else:
|
||||
# Otherwise use the main account for Spotify search credentials
|
||||
search_creds_path = Path(f'./creds/spotify/{main}/search.json')
|
||||
print(f"DEBUG: Using Spotify search credentials from main: {search_creds_path}")
|
||||
|
||||
if search_creds_path.exists():
|
||||
try:
|
||||
@@ -40,6 +45,7 @@ def download_playlist(
|
||||
search_creds = json.load(f)
|
||||
spotify_client_id = search_creds.get('client_id')
|
||||
spotify_client_secret = search_creds.get('client_secret')
|
||||
print(f"DEBUG: Loaded Spotify client credentials successfully")
|
||||
except Exception as e:
|
||||
print(f"Error loading Spotify search credentials: {e}")
|
||||
|
||||
@@ -56,6 +62,14 @@ def download_playlist(
|
||||
# Load Deezer credentials from 'main' under deezer directory
|
||||
deezer_creds_dir = os.path.join('./creds/deezer', main)
|
||||
deezer_creds_path = os.path.abspath(os.path.join(deezer_creds_dir, 'credentials.json'))
|
||||
|
||||
# DEBUG: Print Deezer credential paths being used
|
||||
print(f"DEBUG: Looking for Deezer credentials at:")
|
||||
print(f"DEBUG: deezer_creds_dir = {deezer_creds_dir}")
|
||||
print(f"DEBUG: deezer_creds_path = {deezer_creds_path}")
|
||||
print(f"DEBUG: Directory exists = {os.path.exists(deezer_creds_dir)}")
|
||||
print(f"DEBUG: Credentials file exists = {os.path.exists(deezer_creds_path)}")
|
||||
|
||||
with open(deezer_creds_path, 'r') as f:
|
||||
deezer_creds = json.load(f)
|
||||
# Initialize DeeLogin with Deezer credentials
|
||||
@@ -65,6 +79,7 @@ def download_playlist(
|
||||
spotify_client_secret=spotify_client_secret,
|
||||
progress_callback=progress_callback
|
||||
)
|
||||
print(f"DEBUG: Starting playlist download using Deezer credentials (download_playlistspo)")
|
||||
# Download using download_playlistspo; pass the custom formatting parameters.
|
||||
dl.download_playlistspo(
|
||||
link_playlist=url,
|
||||
@@ -82,6 +97,7 @@ def download_playlist(
|
||||
retry_delay_increase=retry_delay_increase,
|
||||
max_retries=max_retries
|
||||
)
|
||||
print(f"DEBUG: Playlist download completed successfully using Deezer credentials")
|
||||
except Exception as e:
|
||||
deezer_error = e
|
||||
# Immediately report the Deezer error
|
||||
@@ -94,6 +110,9 @@ def download_playlist(
|
||||
spo_creds_dir = os.path.join('./creds/spotify', fallback)
|
||||
spo_creds_path = os.path.abspath(os.path.join(spo_creds_dir, 'credentials.json'))
|
||||
|
||||
print(f"DEBUG: Using Spotify fallback credentials from: {spo_creds_path}")
|
||||
print(f"DEBUG: Fallback credentials exist: {os.path.exists(spo_creds_path)}")
|
||||
|
||||
# We've already loaded the Spotify client credentials above based on fallback
|
||||
|
||||
spo = SpoLogin(
|
||||
@@ -102,6 +121,7 @@ def download_playlist(
|
||||
spotify_client_secret=spotify_client_secret,
|
||||
progress_callback=progress_callback
|
||||
)
|
||||
print(f"DEBUG: Starting playlist download using Spotify fallback credentials")
|
||||
spo.download_playlist(
|
||||
link_playlist=url,
|
||||
output_dir="./downloads",
|
||||
@@ -119,8 +139,10 @@ def download_playlist(
|
||||
retry_delay_increase=retry_delay_increase,
|
||||
max_retries=max_retries
|
||||
)
|
||||
print(f"DEBUG: Playlist download completed successfully using Spotify fallback")
|
||||
except Exception as e2:
|
||||
# If fallback also fails, raise an error indicating both attempts failed
|
||||
print(f"ERROR: Spotify fallback also failed: {e2}")
|
||||
raise RuntimeError(
|
||||
f"Both main (Deezer) and fallback (Spotify) attempts failed. "
|
||||
f"Deezer error: {deezer_error}, Spotify error: {e2}"
|
||||
@@ -131,12 +153,16 @@ def download_playlist(
|
||||
quality = 'HIGH'
|
||||
creds_dir = os.path.join('./creds/spotify', main)
|
||||
credentials_path = os.path.abspath(os.path.join(creds_dir, 'credentials.json'))
|
||||
print(f"DEBUG: Using Spotify main credentials from: {credentials_path}")
|
||||
print(f"DEBUG: Credentials exist: {os.path.exists(credentials_path)}")
|
||||
|
||||
spo = SpoLogin(
|
||||
credentials_path=credentials_path,
|
||||
spotify_client_id=spotify_client_id,
|
||||
spotify_client_secret=spotify_client_secret,
|
||||
progress_callback=progress_callback
|
||||
)
|
||||
print(f"DEBUG: Starting playlist download using Spotify main credentials")
|
||||
spo.download_playlist(
|
||||
link_playlist=url,
|
||||
output_dir="./downloads",
|
||||
@@ -154,12 +180,16 @@ def download_playlist(
|
||||
retry_delay_increase=retry_delay_increase,
|
||||
max_retries=max_retries
|
||||
)
|
||||
print(f"DEBUG: Playlist download completed successfully using Spotify main")
|
||||
elif service == 'deezer':
|
||||
if quality is None:
|
||||
quality = 'FLAC'
|
||||
# Existing code for Deezer, using main as Deezer account.
|
||||
creds_dir = os.path.join('./creds/deezer', main)
|
||||
creds_path = os.path.abspath(os.path.join(creds_dir, 'credentials.json'))
|
||||
print(f"DEBUG: Using Deezer credentials from: {creds_path}")
|
||||
print(f"DEBUG: Credentials exist: {os.path.exists(creds_path)}")
|
||||
|
||||
with open(creds_path, 'r') as f:
|
||||
creds = json.load(f)
|
||||
dl = DeeLogin(
|
||||
@@ -168,6 +198,7 @@ def download_playlist(
|
||||
spotify_client_secret=spotify_client_secret,
|
||||
progress_callback=progress_callback
|
||||
)
|
||||
print(f"DEBUG: Starting playlist download using Deezer direct")
|
||||
dl.download_playlistdee(
|
||||
link_playlist=url,
|
||||
output_dir="./downloads",
|
||||
@@ -183,8 +214,10 @@ def download_playlist(
|
||||
retry_delay_increase=retry_delay_increase,
|
||||
max_retries=max_retries
|
||||
)
|
||||
print(f"DEBUG: Playlist download completed successfully using Deezer direct")
|
||||
else:
|
||||
raise ValueError(f"Unsupported service: {service}")
|
||||
except Exception as e:
|
||||
print(f"ERROR: Playlist download failed with exception: {e}")
|
||||
traceback.print_exc()
|
||||
raise # Re-raise the exception after logging
|
||||
|
||||
Reference in New Issue
Block a user