fix: remove Spotify credential requirement — no API keys needed

spotdl (SpotAPI) works without developer credentials. Remove the
health-check warning, credential error UI, and Client Credentials
fallback that were blocking the importer.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
HoneyandClaude Sonnet 4.6 committed 2026-05-11 15:01:35 +02:00
1 parent 9b197e119a
commit eacd68aea7
2 files changed
+3 -64

No files matched your search

+2 -26
View File
@@ -224,29 +224,7 @@ async function fetchSpotifyToken() {
_spSecretCache = null; // force secret re-extraction next time
}
// Approach 2: Client Credentials fallback (requires SPOTIFY_CLIENT_ID/SECRET in env)
if (!CONFIG.spotifyClientId || !CONFIG.spotifyClientSecret) {
throw new Error(
'Spotify-Token nicht abrufbar (TOTP gescheitert). ' +
'SPOTIFY_CLIENT_ID und SPOTIFY_CLIENT_SECRET setzen als Fallback.'
);
}
const basic = Buffer.from(`${CONFIG.spotifyClientId}:${CONFIG.spotifyClientSecret}`).toString('base64');
const r = await _fetchTimeout('https://accounts.spotify.com/api/token', {
method: 'POST',
headers: { 'Authorization': `Basic ${basic}`, 'Content-Type': 'application/x-www-form-urlencoded' },
body: 'grant_type=client_credentials',
});
if (!r.ok) {
const errBody = await r.text().catch(() => '');
throw new Error(`Spotify-Token-Fehler (${r.status}): ${errBody.slice(0, 200)}`);
}
const d = await r.json();
if (!d.access_token) throw new Error('Kein access_token von Spotify erhalten');
_spTokenCache = d.access_token;
_spTokenExpiry = Date.now() + (d.expires_in * 1000) - 30000;
console.log('[spotify] token ok (Client Credentials)');
return _spTokenCache;
throw new Error('Spotify-Token nicht abrufbar (TOTP gescheitert)');
}
async function _spApi(path, token) {
@@ -370,9 +348,7 @@ app.get('/api/health', (req, res) => {
squidQuality: CONFIG.squidQuality,
activeJobs: activeDownloads,
queueLength: downloadQueue.length,
spotify: {
configured: !!(CONFIG.spotifyClientId && CONFIG.spotifyClientSecret),
},
spotify: { configured: true },
});
});
+1 -38
View File
@@ -6,32 +6,13 @@ import { makeGlobalTrackItem } from './components.js';
import { openDlModal } from './ui.js';
// ─── SPOTIFY IMPORTER PAGE ───
export async function loadSpotifyImporter() {
export function loadSpotifyImporter() {
if (!document.getElementById('spotify-link-input')?.value) {
const hint = document.getElementById('spotify-importer-hint');
const preview = document.getElementById('spotify-preview');
if (hint) hint.style.display = '';
if (preview) preview.style.display = 'none';
}
if (S.cfg.backendUrl) {
try {
const h = await fetch(`${S.cfg.backendUrl}/api/health`, { signal: AbortSignal.timeout(5000) }).then(r => r.json());
if (!h.spotify?.configured) {
const input = document.getElementById('spotify-link-input');
if (input) {
input.disabled = true;
input.placeholder = 'Spotify-Importer nicht konfiguriert (Server-Setup erforderlich)';
}
const hint = document.getElementById('spotify-importer-hint');
if (hint) hint.innerHTML += `
<div style="margin-top:16px;padding:12px;background:var(--surface);border-radius:10px;border-left:3px solid #1DB954;font-size:13px;color:var(--text2)">
⚠ Server-Admin muss <code>SPOTIFY_CLIENT_ID</code> und <code>SPOTIFY_CLIENT_SECRET</code> setzen.
Kostenlos unter <a href="https://developer.spotify.com/dashboard" target="_blank" style="color:#1DB954">developer.spotify.com/dashboard</a>.
</div>`;
}
} catch { /* health check failed — leave UI as-is */ }
}
}
export function clearSpotifyPreview() {
@@ -108,24 +89,6 @@ export async function resolveSpotifyLink() {
</div>`;
return;
}
if (e.message.includes('SPOTIFY_CLIENT_ID') ||
e.message.includes('Credentials fehlen') ||
e.message.includes('Spotify-Token-Fehler')) {
inner.innerHTML = `<div style="color:var(--text);padding:16px;background:var(--surface);border-radius:10px;border-left:3px solid #1DB954">
<div style="font-weight:600;margin-bottom:8px">Spotify-Importer nicht konfiguriert</div>
<div style="font-size:13px;line-height:1.5">
Der Server-Admin muss einmalig Spotify-Credentials hinterlegen.<br><br>
Schritte:<br>
1. <a href="https://developer.spotify.com/dashboard" target="_blank" style="color:#1DB954">developer.spotify.com/dashboard</a> öffnen<br>
2. "Create app" — Name beliebig, Redirect URI: <code>http://localhost</code><br>
3. Client ID + Secret als Environment-Variablen setzen:<br>
&nbsp;&nbsp;<code>SPOTIFY_CLIENT_ID=...</code><br>
&nbsp;&nbsp;<code>SPOTIFY_CLIENT_SECRET=...</code><br>
4. Backend neu starten
</div>
</div>`;
return;
}
inner.innerHTML = `<div style="color:var(--danger);padding:16px;background:var(--surface);border-radius:10px">${esc(e.message)}</div>`;
}
}