fixed
This commit is contained in:
parent
7ef7521c1b
commit
886b9140a1
8 changed files with 42 additions and 15 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -168,7 +168,7 @@ class SpotifyClient:
|
||||||
auth_manager = SpotifyOAuth(
|
auth_manager = SpotifyOAuth(
|
||||||
client_id=config['client_id'],
|
client_id=config['client_id'],
|
||||||
client_secret=config['client_secret'],
|
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",
|
scope="user-library-read user-read-private playlist-read-private playlist-read-collaborative user-read-email",
|
||||||
cache_path='.spotify_cache'
|
cache_path='.spotify_cache'
|
||||||
)
|
)
|
||||||
|
|
|
||||||
8
main.py
8
main.py
|
|
@ -36,8 +36,8 @@ class ServiceStatusThread(QThread):
|
||||||
def run(self):
|
def run(self):
|
||||||
while self.running:
|
while self.running:
|
||||||
try:
|
try:
|
||||||
# Check Spotify authentication
|
# Check Spotify authentication - but don't trigger OAuth
|
||||||
spotify_status = self.spotify_client.is_authenticated()
|
spotify_status = self.spotify_client.sp is not None
|
||||||
self.status_updated.emit("spotify", spotify_status)
|
self.status_updated.emit("spotify", spotify_status)
|
||||||
|
|
||||||
# Check Plex connection
|
# Check Plex connection
|
||||||
|
|
@ -48,11 +48,11 @@ class ServiceStatusThread(QThread):
|
||||||
soulseek_status = self.soulseek_client.is_configured()
|
soulseek_status = self.soulseek_client.is_configured()
|
||||||
self.status_updated.emit("soulseek", soulseek_status)
|
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:
|
except Exception as e:
|
||||||
logger.error(f"Error checking service status: {e}")
|
logger.error(f"Error checking service status: {e}")
|
||||||
self.msleep(5000)
|
self.msleep(10000)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.running = False
|
self.running = False
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -282,6 +282,10 @@ class ServiceTestThread(QThread):
|
||||||
try:
|
try:
|
||||||
from core.spotify_client import SpotifyClient
|
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
|
# Save temporarily to test
|
||||||
original_client_id = config_manager.get('spotify.client_id')
|
original_client_id = config_manager.get('spotify.client_id')
|
||||||
original_client_secret = config_manager.get('spotify.client_secret')
|
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_id', self.test_config['client_id'])
|
||||||
config_manager.set('spotify.client_secret', self.test_config['client_secret'])
|
config_manager.set('spotify.client_secret', self.test_config['client_secret'])
|
||||||
|
|
||||||
# Test connection
|
# Test connection with timeout protection
|
||||||
client = SpotifyClient()
|
try:
|
||||||
if client.is_authenticated():
|
client = SpotifyClient()
|
||||||
user_info = client.get_user_info()
|
|
||||||
username = user_info.get('display_name', 'Unknown') if user_info else 'Unknown'
|
# Check if client was created successfully (has sp object)
|
||||||
message = f"✓ Spotify connection successful!\nConnected as: {username}"
|
if client.sp is None:
|
||||||
success = True
|
message = "✗ Failed to create Spotify client.\nCheck your credentials."
|
||||||
else:
|
success = False
|
||||||
message = "✗ Spotify connection failed.\nCheck your credentials and try again."
|
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
|
success = False
|
||||||
|
|
||||||
# Restore original values
|
# Restore original values
|
||||||
|
|
@ -307,6 +328,12 @@ class ServiceTestThread(QThread):
|
||||||
return success, message
|
return success, message
|
||||||
|
|
||||||
except Exception as e:
|
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)}"
|
return False, f"✗ Spotify test failed:\n{str(e)}"
|
||||||
|
|
||||||
def _test_plex(self):
|
def _test_plex(self):
|
||||||
|
|
@ -1024,7 +1051,7 @@ class SettingsPage(QWidget):
|
||||||
callback_info_label.setStyleSheet("color: #b3b3b3; font-size: 11px; margin-top: 8px;")
|
callback_info_label.setStyleSheet("color: #b3b3b3; font-size: 11px; margin-top: 8px;")
|
||||||
spotify_layout.addWidget(callback_info_label)
|
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("""
|
callback_url_label.setStyleSheet("""
|
||||||
color: #1db954;
|
color: #1db954;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue