Add lyrics prefetch endpoint and UI button: prefetch lyrics for individual playlists with progress feedback

This commit is contained in:
2026-02-05 11:45:36 -05:00
parent 8555b67a38
commit 3b8d83b43e
3 changed files with 62 additions and 1 deletions

View File

@@ -1274,6 +1274,7 @@
<td class="cache-age">${p.cacheAge || '-'}</td>
<td>
<button onclick="matchPlaylistTracks('${escapeJs(p.name)}')">Match Tracks</button>
<button onclick="prefetchLyrics('${escapeJs(p.name)}')">Prefetch Lyrics</button>
<button onclick="viewTracks('${escapeJs(p.name)}')">View</button>
<button class="danger" onclick="removePlaylist('${escapeJs(p.name)}')">Remove</button>
</td>
@@ -1568,6 +1569,23 @@
}
}
async function prefetchLyrics(name) {
try {
showToast(`Prefetching lyrics for ${name}...`, 'info', 5000);
const res = await fetch(`/api/admin/playlists/${encodeURIComponent(name)}/prefetch-lyrics`, { method: 'POST' });
const data = await res.json();
if (res.ok) {
const summary = `Fetched: ${data.fetched}, Cached: ${data.cached}, Missing: ${data.missing}`;
showToast(`✓ Lyrics prefetch complete for ${name}. ${summary}`, 'success', 8000);
} else {
showToast(data.error || 'Failed to prefetch lyrics', 'error');
}
} catch (error) {
showToast('Failed to prefetch lyrics', 'error');
}
}
function searchProvider(query, provider) {
// Provider-specific search URLs
const searchUrls = {