Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/routes/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def index():
color_method=status.get('color_extraction_method', 'vibrant'),
spotify_client_id=config.get('SPOTIFY_CLIENT_ID', ''),
spotify_client_secret=config.get('SPOTIFY_CLIENT_SECRET', ''),
spotify_redirect_uri=config.get('SPOTIFY_REDIRECT_URI', 'http://localhost:5000/callback'),
refresh_interval=config.get('REFRESH_INTERVAL', 30),
wled_ips=config.get('WLED_IPS', []),
spotify_authenticated=status.get('spotify_authenticated', False)
Expand Down Expand Up @@ -72,6 +73,7 @@ def api_config_update():
try:
client_id = request.form.get('client_id', '').strip()
client_secret = request.form.get('client_secret', '').strip()
redirect_uri = request.form.get('redirect_uri', '').strip()

# Validate and convert refresh interval with proper error handling
try:
Expand All @@ -85,6 +87,7 @@ def api_config_update():

config.set('SPOTIFY_CLIENT_ID', client_id)
config.set('SPOTIFY_CLIENT_SECRET', client_secret)
config.set('SPOTIFY_REDIRECT_URI', redirect_uri)
config.set('REFRESH_INTERVAL', refresh_interval)

config.save()
Expand Down
9 changes: 9 additions & 0 deletions app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ <h4 id="trackName" class="mb-2">{{ current_track.name }}</h4>
<input type="password" name="client_secret" class="form-control"
value="{{ spotify_client_secret }}" required>
</div>
<div class="mb-3">
<label class="form-label">Redirect URI</label>
<input type="text" name="redirect_uri" class="form-control"
value="{{ spotify_redirect_uri }}" required>
<small class="form-text text-muted">
Must match the redirect URI in your <a href="https://developer.spotify.com/dashboard" target="_blank">Spotify Dashboard</a>.
Example: <code>http://your-server-ip:5000/callback</code>
</small>
</div>
<div class="mb-3">
<label class="form-label">Refresh Interval (seconds)</label>
<input type="number" name="refresh_interval" class="form-control"
Expand Down
11 changes: 11 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ def test_validation_success(self):
self.assertTrue(is_valid)
self.assertEqual(len(errors), 0)

def test_custom_redirect_uri(self):
"""Test custom redirect URI configuration"""
custom_uri = 'http://192.168.1.50:5000/callback'
self.config.set('SPOTIFY_REDIRECT_URI', custom_uri)
self.assertEqual(self.config.get('SPOTIFY_REDIRECT_URI'), custom_uri)

# Save and reload to verify persistence
self.config.save()
new_config = Config(config_path=self.temp_file.name)
self.assertEqual(new_config.get('SPOTIFY_REDIRECT_URI'), custom_uri)

def test_validation_missing_credentials(self):
"""Test validation with missing Spotify credentials"""
self.config.set('SPOTIFY_CLIENT_ID', '')
Expand Down