diff --git a/core/__pycache__/plex_client.cpython-312.pyc b/core/__pycache__/plex_client.cpython-312.pyc index 9a8a77e7..040ba5ad 100644 Binary files a/core/__pycache__/plex_client.cpython-312.pyc and b/core/__pycache__/plex_client.cpython-312.pyc differ diff --git a/core/__pycache__/soulseek_client.cpython-312.pyc b/core/__pycache__/soulseek_client.cpython-312.pyc index 93101410..60ff281e 100644 Binary files a/core/__pycache__/soulseek_client.cpython-312.pyc and b/core/__pycache__/soulseek_client.cpython-312.pyc differ diff --git a/core/__pycache__/spotify_client.cpython-312.pyc b/core/__pycache__/spotify_client.cpython-312.pyc index 0cd0f054..33d5bb08 100644 Binary files a/core/__pycache__/spotify_client.cpython-312.pyc and b/core/__pycache__/spotify_client.cpython-312.pyc differ diff --git a/core/spotify_client.py b/core/spotify_client.py index ce1ffe37..d9804030 100644 --- a/core/spotify_client.py +++ b/core/spotify_client.py @@ -168,7 +168,7 @@ class SpotifyClient: auth_manager = SpotifyOAuth( client_id=config['client_id'], client_secret=config['client_secret'], - redirect_uri="http://localhost:8888/callback", + redirect_uri="http://127.0.0.1:8888/callback", scope="user-library-read user-read-private playlist-read-private playlist-read-collaborative user-read-email", cache_path='.spotify_cache' ) diff --git a/main.py b/main.py index 4c3c17b0..aa512d29 100644 --- a/main.py +++ b/main.py @@ -36,8 +36,8 @@ class ServiceStatusThread(QThread): def run(self): while self.running: try: - # Check Spotify authentication - spotify_status = self.spotify_client.is_authenticated() + # Check Spotify authentication - but don't trigger OAuth + spotify_status = self.spotify_client.sp is not None self.status_updated.emit("spotify", spotify_status) # Check Plex connection @@ -48,11 +48,11 @@ class ServiceStatusThread(QThread): soulseek_status = self.soulseek_client.is_configured() self.status_updated.emit("soulseek", soulseek_status) - self.msleep(3000) # Check every 3 seconds + self.msleep(10000) # Check every 10 seconds (less aggressive) except Exception as e: logger.error(f"Error checking service status: {e}") - self.msleep(5000) + self.msleep(10000) def stop(self): self.running = False diff --git a/ui/pages/__pycache__/dashboard.cpython-312.pyc b/ui/pages/__pycache__/dashboard.cpython-312.pyc index 0e1eea3a..8a2ad8e7 100644 Binary files a/ui/pages/__pycache__/dashboard.cpython-312.pyc and b/ui/pages/__pycache__/dashboard.cpython-312.pyc differ diff --git a/ui/pages/__pycache__/settings.cpython-312.pyc b/ui/pages/__pycache__/settings.cpython-312.pyc index f03f2c0e..2873d6c8 100644 Binary files a/ui/pages/__pycache__/settings.cpython-312.pyc and b/ui/pages/__pycache__/settings.cpython-312.pyc differ diff --git a/ui/pages/settings.py b/ui/pages/settings.py index a9b6b56c..e8eb911b 100644 --- a/ui/pages/settings.py +++ b/ui/pages/settings.py @@ -282,6 +282,10 @@ class ServiceTestThread(QThread): try: from core.spotify_client import SpotifyClient + # Basic validation first + if not self.test_config.get('client_id') or not self.test_config.get('client_secret'): + return False, "✗ Please enter both Client ID and Client Secret" + # Save temporarily to test original_client_id = config_manager.get('spotify.client_id') original_client_secret = config_manager.get('spotify.client_secret') @@ -289,15 +293,32 @@ class ServiceTestThread(QThread): config_manager.set('spotify.client_id', self.test_config['client_id']) config_manager.set('spotify.client_secret', self.test_config['client_secret']) - # Test connection - client = SpotifyClient() - if client.is_authenticated(): - user_info = client.get_user_info() - username = user_info.get('display_name', 'Unknown') if user_info else 'Unknown' - message = f"✓ Spotify connection successful!\nConnected as: {username}" - success = True - else: - message = "✗ Spotify connection failed.\nCheck your credentials and try again." + # Test connection with timeout protection + try: + client = SpotifyClient() + + # Check if client was created successfully (has sp object) + if client.sp is None: + message = "✗ Failed to create Spotify client.\nCheck your credentials." + success = False + else: + # Try a simple auth check with timeout + try: + # This will trigger OAuth flow - user needs to complete it + if client.is_authenticated(): + user_info = client.get_user_info() + username = user_info.get('display_name', 'Unknown') if user_info else 'Unknown' + message = f"✓ Spotify connection successful!\nConnected as: {username}" + success = True + else: + message = "✗ Spotify authentication failed.\nPlease complete the OAuth flow in your browser." + success = False + except Exception as auth_e: + message = f"✗ Spotify authentication failed:\n{str(auth_e)}" + success = False + + except Exception as client_e: + message = f"✗ Failed to create Spotify client:\n{str(client_e)}" success = False # Restore original values @@ -307,6 +328,12 @@ class ServiceTestThread(QThread): return success, message except Exception as e: + # Restore original values even on exception + try: + config_manager.set('spotify.client_id', original_client_id) + config_manager.set('spotify.client_secret', original_client_secret) + except: + pass return False, f"✗ Spotify test failed:\n{str(e)}" def _test_plex(self): @@ -1024,7 +1051,7 @@ class SettingsPage(QWidget): callback_info_label.setStyleSheet("color: #b3b3b3; font-size: 11px; margin-top: 8px;") spotify_layout.addWidget(callback_info_label) - callback_url_label = QLabel("http://localhost:8888/callback") + callback_url_label = QLabel("http://127.0.0.1:8888/callback") callback_url_label.setStyleSheet(""" color: #1db954; font-size: 11px;