diff --git a/.gitignore b/.gitignore index 7759a30..34dcf0e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,9 @@ routes/__pycache__/ routes/utils/__pycache__/ test.sh __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 diff --git a/routes/__pycache__/__init__.cpython-312.pyc b/routes/__pycache__/__init__.cpython-312.pyc index 96949c9..f34fe3a 100644 Binary files a/routes/__pycache__/__init__.cpython-312.pyc and b/routes/__pycache__/__init__.cpython-312.pyc differ diff --git a/routes/__pycache__/credentials.cpython-312.pyc b/routes/__pycache__/credentials.cpython-312.pyc index 865eabf..e02d8a1 100644 Binary files a/routes/__pycache__/credentials.cpython-312.pyc and b/routes/__pycache__/credentials.cpython-312.pyc differ diff --git a/routes/__pycache__/search.cpython-312.pyc b/routes/__pycache__/search.cpython-312.pyc index 98cd1dd..1b5ac15 100644 Binary files a/routes/__pycache__/search.cpython-312.pyc and b/routes/__pycache__/search.cpython-312.pyc differ diff --git a/routes/utils/__pycache__/__init__.cpython-312.pyc b/routes/utils/__pycache__/__init__.cpython-312.pyc index ac1ba28..920f24a 100644 Binary files a/routes/utils/__pycache__/__init__.cpython-312.pyc and b/routes/utils/__pycache__/__init__.cpython-312.pyc differ diff --git a/routes/utils/__pycache__/credentials.cpython-312.pyc b/routes/utils/__pycache__/credentials.cpython-312.pyc index 07431f4..fdcb97f 100644 Binary files a/routes/utils/__pycache__/credentials.cpython-312.pyc and b/routes/utils/__pycache__/credentials.cpython-312.pyc differ diff --git a/routes/utils/__pycache__/search.cpython-312.pyc b/routes/utils/__pycache__/search.cpython-312.pyc index 9872c54..b4835b9 100644 Binary files a/routes/utils/__pycache__/search.cpython-312.pyc and b/routes/utils/__pycache__/search.cpython-312.pyc differ diff --git a/routes/utils/album.py b/routes/utils/album.py index 2ae913a..0565ff4 100644 --- a/routes/utils/album.py +++ b/routes/utils/album.py @@ -18,8 +18,6 @@ def download_album(service, url, main, fallback=None): # Initialize DeeLogin with Deezer credentials dl = DeeLogin( arl=deezer_creds.get('arl', ''), - email=deezer_creds.get('email', ''), - password=deezer_creds.get('password', '') ) # Download using download_albumspo dl.download_albumspo( @@ -77,8 +75,6 @@ def download_album(service, url, main, fallback=None): creds = json.load(f) dl = DeeLogin( arl=creds.get('arl', ''), - email=creds.get('email', ''), - password=creds.get('password', '') ) dl.download_albumdee( link_album=url, diff --git a/routes/utils/credentials.py b/routes/utils/credentials.py index c2567ac..0b16281 100644 --- a/routes/utils/credentials.py +++ b/routes/utils/credentials.py @@ -62,7 +62,7 @@ def create_credential(service, name, data): data (dict): Dictionary containing the credential data 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 """ if service not in ['spotify', 'deezer']: @@ -70,11 +70,18 @@ def create_credential(service, name, data): # Validate data structure required_fields = [] + allowed_fields = [] if service == 'spotify': required_fields = ['username', 'credentials'] + allowed_fields = required_fields + ['type'] data['type'] = 'AUTHENTICATION_STORED_SPOTIFY_CREDENTIALS' 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: if field not in data: @@ -122,7 +129,6 @@ def edit_credential(service, name, new_data): FileNotFoundError: If the credential does not exist ValueError: If new_data contains invalid fields or missing required fields after update """ - # Validate service if service not in ['spotify', 'deezer']: raise ValueError("Service must be 'spotify' or 'deezer'") @@ -140,7 +146,7 @@ def edit_credential(service, name, new_data): if service == 'spotify': allowed_fields = ['username', 'credentials'] else: - allowed_fields = ['arl', 'email', 'password'] + allowed_fields = ['arl'] for key in new_data.keys(): if key not in allowed_fields: @@ -149,13 +155,19 @@ def edit_credential(service, name, new_data): # Update 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 required_fields = [] if service == 'spotify': required_fields = ['username', 'credentials', 'type'] - data['type'] = 'AUTHENTICATION_STORED_SPOTIFY_CREDENTIALS' # Ensure type is correct + data['type'] = 'AUTHENTICATION_STORED_SPOTIFY_CREDENTIALS' else: - required_fields = ['arl', 'email', 'password'] + required_fields = ['arl'] for field in required_fields: if field not in data: diff --git a/routes/utils/playlist.py b/routes/utils/playlist.py index 72321b1..9f208ef 100644 --- a/routes/utils/playlist.py +++ b/routes/utils/playlist.py @@ -18,8 +18,6 @@ def download_playlist(service, url, main, fallback=None): # Initialize DeeLogin with Deezer credentials dl = DeeLogin( arl=deezer_creds.get('arl', ''), - email=deezer_creds.get('email', ''), - password=deezer_creds.get('password', '') ) # Download using download_playlistspo dl.download_playlistspo( @@ -79,8 +77,6 @@ def download_playlist(service, url, main, fallback=None): creds = json.load(f) dl = DeeLogin( arl=creds.get('arl', ''), - email=creds.get('email', ''), - password=creds.get('password', '') ) dl.download_playlistdee( link_playlist=url, diff --git a/routes/utils/track.py b/routes/utils/track.py index f5398fb..1426d5d 100644 --- a/routes/utils/track.py +++ b/routes/utils/track.py @@ -16,8 +16,6 @@ def download_track(service, url, main, fallback=None): deezer_creds = json.load(f) dl = DeeLogin( arl=deezer_creds.get('arl', ''), - email=deezer_creds.get('email', ''), - password=deezer_creds.get('password', '') ) dl.download_trackspo( link_track=url, @@ -65,8 +63,6 @@ def download_track(service, url, main, fallback=None): creds = json.load(f) dl = DeeLogin( arl=creds.get('arl', ''), - email=creds.get('email', ''), - password=creds.get('password', '') ) dl.download_trackdee( link_track=url, diff --git a/static/js/app.js b/static/js/app.js index a2306ab..12c3543 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -11,14 +11,10 @@ const serviceConfig = { }, deezer: { fields: [ - { id: 'arl', label: 'ARL', type: 'text' }, - { id: 'email', label: 'Email', type: 'email' }, - { id: 'password', label: 'Password', type: 'password' } + { id: 'arl', label: 'ARL', type: 'text' } ], validator: (data) => ({ - arl: data.arl, - email: data.email, - password: data.password + arl: data.arl }) } };