mirror of
https://lavaforge.org/spotizerr/spotizerr.git
synced 2025-12-24 02:39:14 -05:00
i dont have time for this
This commit is contained in:
@@ -6,7 +6,6 @@ from deezspot.deezloader import DeeLogin
|
||||
from pathlib import Path
|
||||
|
||||
def download_album(
|
||||
service,
|
||||
url,
|
||||
main,
|
||||
fallback=None,
|
||||
@@ -22,8 +21,24 @@ def download_album(
|
||||
progress_callback=None
|
||||
):
|
||||
try:
|
||||
# DEBUG: Print parameters
|
||||
print(f"DEBUG: album.py received - service={service}, main={main}, fallback={fallback}")
|
||||
# Detect URL source (Spotify or Deezer) from URL
|
||||
is_spotify_url = 'open.spotify.com' in url.lower()
|
||||
is_deezer_url = 'deezer.com' in url.lower()
|
||||
|
||||
# Determine service exclusively from URL
|
||||
if is_spotify_url:
|
||||
service = 'spotify'
|
||||
elif is_deezer_url:
|
||||
service = 'deezer'
|
||||
else:
|
||||
# If URL can't be detected, raise an error
|
||||
error_msg = "Invalid URL: Must be from open.spotify.com or deezer.com"
|
||||
print(f"ERROR: {error_msg}")
|
||||
raise ValueError(error_msg)
|
||||
|
||||
print(f"DEBUG: album.py - URL detection: is_spotify_url={is_spotify_url}, is_deezer_url={is_deezer_url}")
|
||||
print(f"DEBUG: album.py - Service determined from URL: {service}")
|
||||
print(f"DEBUG: album.py - Credentials: main={main}, fallback={fallback}")
|
||||
|
||||
# Load Spotify client credentials if available
|
||||
spotify_client_id = None
|
||||
@@ -49,6 +64,8 @@ def download_album(
|
||||
except Exception as e:
|
||||
print(f"Error loading Spotify search credentials: {e}")
|
||||
|
||||
# For Spotify URLs: check if fallback is enabled, if so use the fallback logic,
|
||||
# otherwise download directly from Spotify
|
||||
if service == 'spotify':
|
||||
if fallback:
|
||||
if quality is None:
|
||||
@@ -186,6 +203,7 @@ def download_album(
|
||||
max_retries=max_retries
|
||||
)
|
||||
print(f"DEBUG: Album download completed successfully using Spotify main")
|
||||
# For Deezer URLs: download directly from Deezer
|
||||
elif service == 'deezer':
|
||||
if quality is None:
|
||||
quality = 'FLAC'
|
||||
|
||||
@@ -87,6 +87,16 @@ def download_artist_albums(url, album_type="album,single,compilation", request_a
|
||||
|
||||
logger.info(f"Fetching artist info for ID: {artist_id}")
|
||||
|
||||
# Detect URL source (only Spotify is supported for artists)
|
||||
is_spotify_url = 'open.spotify.com' in url.lower()
|
||||
is_deezer_url = 'deezer.com' in url.lower()
|
||||
|
||||
# Artist functionality only works with Spotify URLs currently
|
||||
if not is_spotify_url:
|
||||
error_msg = "Invalid URL: Artist functionality only supports open.spotify.com URLs"
|
||||
logger.error(error_msg)
|
||||
raise ValueError(error_msg)
|
||||
|
||||
# Get artist info with albums
|
||||
artist_data = get_spotify_info(artist_id, "artist")
|
||||
|
||||
@@ -152,8 +162,7 @@ def download_artist_albums(url, album_type="album,single,compilation", request_a
|
||||
"name": album_name,
|
||||
"artist": album_artist,
|
||||
"type": "album",
|
||||
"service": "spotify",
|
||||
# Add reference to parent artist request if needed
|
||||
# URL source will be automatically detected in the download functions
|
||||
"parent_artist_url": url,
|
||||
"parent_request_type": "artist"
|
||||
}
|
||||
@@ -162,7 +171,6 @@ def download_artist_albums(url, album_type="album,single,compilation", request_a
|
||||
task_data = {
|
||||
"download_type": "album",
|
||||
"type": "album", # Type for the download task
|
||||
"service": "spotify", # Default to Spotify since we're using Spotify API
|
||||
"url": album_url, # Important: use the album URL, not artist URL
|
||||
"retry_url": album_url, # Use album URL for retry logic, not artist URL
|
||||
"name": album_name,
|
||||
|
||||
@@ -120,9 +120,6 @@ class CeleryDownloadQueueManager:
|
||||
# Extract original request or use empty dict
|
||||
original_request = task.get("orig_request", task.get("original_request", {}))
|
||||
|
||||
# Determine service (spotify or deezer) from config or request
|
||||
service = original_request.get("service", config_params.get("service", "spotify"))
|
||||
|
||||
# Debug retry_url if present
|
||||
if "retry_url" in task:
|
||||
logger.debug(f"Task has retry_url: {task['retry_url']}")
|
||||
@@ -133,21 +130,20 @@ class CeleryDownloadQueueManager:
|
||||
"type": task.get("type", download_type),
|
||||
"name": task.get("name", ""),
|
||||
"artist": task.get("artist", ""),
|
||||
"service": service,
|
||||
"url": task.get("url", ""),
|
||||
|
||||
# Preserve retry_url if present
|
||||
"retry_url": task.get("retry_url", ""),
|
||||
|
||||
# Use config values but allow override from request
|
||||
"main": original_request.get("main",
|
||||
config_params['spotify'] if service == 'spotify' else config_params['deezer']),
|
||||
# Use main account from config
|
||||
"main": original_request.get("main", config_params['deezer']),
|
||||
|
||||
# Set fallback if enabled in config
|
||||
"fallback": original_request.get("fallback",
|
||||
config_params['spotify'] if config_params['fallback'] and service == 'spotify' else None),
|
||||
config_params['spotify'] if config_params['fallback'] else None),
|
||||
|
||||
"quality": original_request.get("quality",
|
||||
config_params['spotifyQuality'] if service == 'spotify' else config_params['deezerQuality']),
|
||||
# Use default quality settings
|
||||
"quality": original_request.get("quality", config_params['deezerQuality']),
|
||||
|
||||
"fall_quality": original_request.get("fall_quality", config_params['spotifyQuality']),
|
||||
|
||||
|
||||
@@ -893,12 +893,11 @@ def download_track(self, **task_data):
|
||||
custom_track_format = task_data.get("custom_track_format", config_params.get("customTrackFormat", "%tracknum%. %music%"))
|
||||
pad_tracks = task_data.get("pad_tracks", config_params.get("tracknum_padding", True))
|
||||
|
||||
# Execute the download
|
||||
# Execute the download - service is now determined from URL
|
||||
download_track_func(
|
||||
service=service,
|
||||
url=url,
|
||||
main=main,
|
||||
fallback=fallback,
|
||||
fallback=fallback if fallback_enabled else None,
|
||||
quality=quality,
|
||||
fall_quality=fall_quality,
|
||||
real_time=real_time,
|
||||
@@ -961,12 +960,11 @@ def download_album(self, **task_data):
|
||||
custom_track_format = task_data.get("custom_track_format", config_params.get("customTrackFormat", "%tracknum%. %music%"))
|
||||
pad_tracks = task_data.get("pad_tracks", config_params.get("tracknum_padding", True))
|
||||
|
||||
# Execute the download
|
||||
# Execute the download - service is now determined from URL
|
||||
download_album_func(
|
||||
service=service,
|
||||
url=url,
|
||||
main=main,
|
||||
fallback=fallback,
|
||||
fallback=fallback if fallback_enabled else None,
|
||||
quality=quality,
|
||||
fall_quality=fall_quality,
|
||||
real_time=real_time,
|
||||
@@ -1034,12 +1032,11 @@ def download_playlist(self, **task_data):
|
||||
retry_delay_increase = task_data.get("retry_delay_increase", config_params.get("retry_delay_increase", 5))
|
||||
max_retries = task_data.get("max_retries", config_params.get("maxRetries", 3))
|
||||
|
||||
# Execute the download
|
||||
# Execute the download - service is now determined from URL
|
||||
download_playlist_func(
|
||||
service=service,
|
||||
url=url,
|
||||
main=main,
|
||||
fallback=fallback,
|
||||
fallback=fallback if fallback_enabled else None,
|
||||
quality=quality,
|
||||
fall_quality=fall_quality,
|
||||
real_time=real_time,
|
||||
|
||||
@@ -6,7 +6,6 @@ from deezspot.deezloader import DeeLogin
|
||||
from pathlib import Path
|
||||
|
||||
def download_playlist(
|
||||
service,
|
||||
url,
|
||||
main,
|
||||
fallback=None,
|
||||
@@ -22,8 +21,24 @@ def download_playlist(
|
||||
progress_callback=None,
|
||||
):
|
||||
try:
|
||||
# DEBUG: Print parameters
|
||||
print(f"DEBUG: playlist.py received - service={service}, main={main}, fallback={fallback}")
|
||||
# Detect URL source (Spotify or Deezer) from URL
|
||||
is_spotify_url = 'open.spotify.com' in url.lower()
|
||||
is_deezer_url = 'deezer.com' in url.lower()
|
||||
|
||||
# Determine service exclusively from URL
|
||||
if is_spotify_url:
|
||||
service = 'spotify'
|
||||
elif is_deezer_url:
|
||||
service = 'deezer'
|
||||
else:
|
||||
# If URL can't be detected, raise an error
|
||||
error_msg = "Invalid URL: Must be from open.spotify.com or deezer.com"
|
||||
print(f"ERROR: {error_msg}")
|
||||
raise ValueError(error_msg)
|
||||
|
||||
print(f"DEBUG: playlist.py - URL detection: is_spotify_url={is_spotify_url}, is_deezer_url={is_deezer_url}")
|
||||
print(f"DEBUG: playlist.py - Service determined from URL: {service}")
|
||||
print(f"DEBUG: playlist.py - Credentials: main={main}, fallback={fallback}")
|
||||
|
||||
# Load Spotify client credentials if available
|
||||
spotify_client_id = None
|
||||
@@ -49,6 +64,8 @@ def download_playlist(
|
||||
except Exception as e:
|
||||
print(f"Error loading Spotify search credentials: {e}")
|
||||
|
||||
# For Spotify URLs: check if fallback is enabled, if so use the fallback logic,
|
||||
# otherwise download directly from Spotify
|
||||
if service == 'spotify':
|
||||
if fallback:
|
||||
if quality is None:
|
||||
@@ -181,6 +198,7 @@ def download_playlist(
|
||||
max_retries=max_retries
|
||||
)
|
||||
print(f"DEBUG: Playlist download completed successfully using Spotify main")
|
||||
# For Deezer URLs: download directly from Deezer
|
||||
elif service == 'deezer':
|
||||
if quality is None:
|
||||
quality = 'FLAC'
|
||||
|
||||
@@ -6,7 +6,6 @@ from deezspot.deezloader import DeeLogin
|
||||
from pathlib import Path
|
||||
|
||||
def download_track(
|
||||
service,
|
||||
url,
|
||||
main,
|
||||
fallback=None,
|
||||
@@ -22,8 +21,24 @@ def download_track(
|
||||
progress_callback=None
|
||||
):
|
||||
try:
|
||||
# DEBUG: Print parameters
|
||||
print(f"DEBUG: track.py received - service={service}, main={main}, fallback={fallback}")
|
||||
# Detect URL source (Spotify or Deezer) from URL
|
||||
is_spotify_url = 'open.spotify.com' in url.lower()
|
||||
is_deezer_url = 'deezer.com' in url.lower()
|
||||
|
||||
# Determine service exclusively from URL
|
||||
if is_spotify_url:
|
||||
service = 'spotify'
|
||||
elif is_deezer_url:
|
||||
service = 'deezer'
|
||||
else:
|
||||
# If URL can't be detected, raise an error
|
||||
error_msg = "Invalid URL: Must be from open.spotify.com or deezer.com"
|
||||
print(f"ERROR: {error_msg}")
|
||||
raise ValueError(error_msg)
|
||||
|
||||
print(f"DEBUG: track.py - URL detection: is_spotify_url={is_spotify_url}, is_deezer_url={is_deezer_url}")
|
||||
print(f"DEBUG: track.py - Service determined from URL: {service}")
|
||||
print(f"DEBUG: track.py - Credentials: main={main}, fallback={fallback}")
|
||||
|
||||
# Load Spotify client credentials if available
|
||||
spotify_client_id = None
|
||||
@@ -49,6 +64,8 @@ def download_track(
|
||||
except Exception as e:
|
||||
print(f"Error loading Spotify search credentials: {e}")
|
||||
|
||||
# For Spotify URLs: check if fallback is enabled, if so use the fallback logic,
|
||||
# otherwise download directly from Spotify
|
||||
if service == 'spotify':
|
||||
if fallback:
|
||||
if quality is None:
|
||||
@@ -166,6 +183,7 @@ def download_track(
|
||||
retry_delay_increase=retry_delay_increase,
|
||||
max_retries=max_retries
|
||||
)
|
||||
# For Deezer URLs: download directly from Deezer
|
||||
elif service == 'deezer':
|
||||
if quality is None:
|
||||
quality = 'FLAC'
|
||||
|
||||
Reference in New Issue
Block a user