ditched email and pass for deezer

This commit is contained in:
cool.gitter.choco
2025-01-27 09:38:54 -06:00
parent db80a8d06c
commit 584ffaadf8
12 changed files with 26 additions and 24 deletions

6
.gitignore vendored
View File

@@ -10,3 +10,9 @@ routes/__pycache__/
routes/utils/__pycache__/ routes/utils/__pycache__/
test.sh test.sh
__pycache__/ __pycache__/
routes/__pycache__/__init__.cpython-312.pyc
routes/__pycache__/credentials.cpython-312.pyc
routes/__pycache__/search.cpython-312.pyc
routes/utils/__pycache__/__init__.cpython-312.pyc
routes/utils/__pycache__/credentials.cpython-312.pyc
routes/utils/__pycache__/search.cpython-312.pyc

View File

@@ -18,8 +18,6 @@ def download_album(service, url, main, fallback=None):
# Initialize DeeLogin with Deezer credentials # Initialize DeeLogin with Deezer credentials
dl = DeeLogin( dl = DeeLogin(
arl=deezer_creds.get('arl', ''), arl=deezer_creds.get('arl', ''),
email=deezer_creds.get('email', ''),
password=deezer_creds.get('password', '')
) )
# Download using download_albumspo # Download using download_albumspo
dl.download_albumspo( dl.download_albumspo(
@@ -77,8 +75,6 @@ def download_album(service, url, main, fallback=None):
creds = json.load(f) creds = json.load(f)
dl = DeeLogin( dl = DeeLogin(
arl=creds.get('arl', ''), arl=creds.get('arl', ''),
email=creds.get('email', ''),
password=creds.get('password', '')
) )
dl.download_albumdee( dl.download_albumdee(
link_album=url, link_album=url,

View File

@@ -62,7 +62,7 @@ def create_credential(service, name, data):
data (dict): Dictionary containing the credential data data (dict): Dictionary containing the credential data
Raises: Raises:
ValueError: If service is invalid or data is missing required fields ValueError: If service is invalid, data has invalid fields, or missing required fields
FileExistsError: If the credential directory already exists FileExistsError: If the credential directory already exists
""" """
if service not in ['spotify', 'deezer']: if service not in ['spotify', 'deezer']:
@@ -70,11 +70,18 @@ def create_credential(service, name, data):
# Validate data structure # Validate data structure
required_fields = [] required_fields = []
allowed_fields = []
if service == 'spotify': if service == 'spotify':
required_fields = ['username', 'credentials'] required_fields = ['username', 'credentials']
allowed_fields = required_fields + ['type']
data['type'] = 'AUTHENTICATION_STORED_SPOTIFY_CREDENTIALS' data['type'] = 'AUTHENTICATION_STORED_SPOTIFY_CREDENTIALS'
else: else:
required_fields = ['arl', 'email', 'password'] required_fields = ['arl']
allowed_fields = required_fields.copy()
# Check for extra fields
extra_fields = set(data.keys()) - set(allowed_fields)
if extra_fields:
raise ValueError(f"Deezer credentials can only contain 'arl'. Extra fields found: {', '.join(extra_fields)}")
for field in required_fields: for field in required_fields:
if field not in data: if field not in data:
@@ -122,7 +129,6 @@ def edit_credential(service, name, new_data):
FileNotFoundError: If the credential does not exist FileNotFoundError: If the credential does not exist
ValueError: If new_data contains invalid fields or missing required fields after update ValueError: If new_data contains invalid fields or missing required fields after update
""" """
# Validate service
if service not in ['spotify', 'deezer']: if service not in ['spotify', 'deezer']:
raise ValueError("Service must be 'spotify' or 'deezer'") raise ValueError("Service must be 'spotify' or 'deezer'")
@@ -140,7 +146,7 @@ def edit_credential(service, name, new_data):
if service == 'spotify': if service == 'spotify':
allowed_fields = ['username', 'credentials'] allowed_fields = ['username', 'credentials']
else: else:
allowed_fields = ['arl', 'email', 'password'] allowed_fields = ['arl']
for key in new_data.keys(): for key in new_data.keys():
if key not in allowed_fields: if key not in allowed_fields:
@@ -149,13 +155,19 @@ def edit_credential(service, name, new_data):
# Update data # Update data
data.update(new_data) data.update(new_data)
# For Deezer: Strip all fields except 'arl'
if service == 'deezer':
if 'arl' not in data:
raise ValueError("Missing 'arl' field for Deezer credential")
data = {'arl': data['arl']}
# Ensure required fields are present # Ensure required fields are present
required_fields = [] required_fields = []
if service == 'spotify': if service == 'spotify':
required_fields = ['username', 'credentials', 'type'] required_fields = ['username', 'credentials', 'type']
data['type'] = 'AUTHENTICATION_STORED_SPOTIFY_CREDENTIALS' # Ensure type is correct data['type'] = 'AUTHENTICATION_STORED_SPOTIFY_CREDENTIALS'
else: else:
required_fields = ['arl', 'email', 'password'] required_fields = ['arl']
for field in required_fields: for field in required_fields:
if field not in data: if field not in data:

View File

@@ -18,8 +18,6 @@ def download_playlist(service, url, main, fallback=None):
# Initialize DeeLogin with Deezer credentials # Initialize DeeLogin with Deezer credentials
dl = DeeLogin( dl = DeeLogin(
arl=deezer_creds.get('arl', ''), arl=deezer_creds.get('arl', ''),
email=deezer_creds.get('email', ''),
password=deezer_creds.get('password', '')
) )
# Download using download_playlistspo # Download using download_playlistspo
dl.download_playlistspo( dl.download_playlistspo(
@@ -79,8 +77,6 @@ def download_playlist(service, url, main, fallback=None):
creds = json.load(f) creds = json.load(f)
dl = DeeLogin( dl = DeeLogin(
arl=creds.get('arl', ''), arl=creds.get('arl', ''),
email=creds.get('email', ''),
password=creds.get('password', '')
) )
dl.download_playlistdee( dl.download_playlistdee(
link_playlist=url, link_playlist=url,

View File

@@ -16,8 +16,6 @@ def download_track(service, url, main, fallback=None):
deezer_creds = json.load(f) deezer_creds = json.load(f)
dl = DeeLogin( dl = DeeLogin(
arl=deezer_creds.get('arl', ''), arl=deezer_creds.get('arl', ''),
email=deezer_creds.get('email', ''),
password=deezer_creds.get('password', '')
) )
dl.download_trackspo( dl.download_trackspo(
link_track=url, link_track=url,
@@ -65,8 +63,6 @@ def download_track(service, url, main, fallback=None):
creds = json.load(f) creds = json.load(f)
dl = DeeLogin( dl = DeeLogin(
arl=creds.get('arl', ''), arl=creds.get('arl', ''),
email=creds.get('email', ''),
password=creds.get('password', '')
) )
dl.download_trackdee( dl.download_trackdee(
link_track=url, link_track=url,

View File

@@ -11,14 +11,10 @@ const serviceConfig = {
}, },
deezer: { deezer: {
fields: [ fields: [
{ id: 'arl', label: 'ARL', type: 'text' }, { id: 'arl', label: 'ARL', type: 'text' }
{ id: 'email', label: 'Email', type: 'email' },
{ id: 'password', label: 'Password', type: 'password' }
], ],
validator: (data) => ({ validator: (data) => ({
arl: data.arl, arl: data.arl
email: data.email,
password: data.password
}) })
} }
}; };