();
+
+ if (lyricsPrefetchService == null)
+ {
+ return StatusCode(500, new { error = "Lyrics prefetch service not available" });
+ }
+
+ _logger.LogInformation("Starting lyrics prefetch for playlist: {Playlist}", decodedName);
+
+ var (fetched, cached, missing) = await lyricsPrefetchService.PrefetchPlaylistLyricsAsync(
+ decodedName,
+ HttpContext.RequestAborted);
+
+ return Ok(new
+ {
+ message = "Lyrics prefetch complete",
+ playlist = decodedName,
+ fetched,
+ cached,
+ missing,
+ total = fetched + cached + missing
+ });
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Failed to prefetch lyrics for playlist {Playlist}", decodedName);
+ return StatusCode(500, new { error = $"Failed to prefetch lyrics: {ex.Message}" });
+ }
+ }
+
#endregion
}
diff --git a/allstarr/Services/Lyrics/LyricsPrefetchService.cs b/allstarr/Services/Lyrics/LyricsPrefetchService.cs
index e219ada..295a8ab 100644
--- a/allstarr/Services/Lyrics/LyricsPrefetchService.cs
+++ b/allstarr/Services/Lyrics/LyricsPrefetchService.cs
@@ -107,7 +107,7 @@ public class LyricsPrefetchService : BackgroundService
totalFetched, totalCached, totalMissing);
}
- private async Task<(int Fetched, int Cached, int Missing)> PrefetchPlaylistLyricsAsync(
+ public async Task<(int Fetched, int Cached, int Missing)> PrefetchPlaylistLyricsAsync(
string playlistName,
CancellationToken cancellationToken)
{
diff --git a/allstarr/wwwroot/index.html b/allstarr/wwwroot/index.html
index 2c2cd4f..0baa412 100644
--- a/allstarr/wwwroot/index.html
+++ b/allstarr/wwwroot/index.html
@@ -1274,6 +1274,7 @@
| ${p.cacheAge || '-'} |
+
|
@@ -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 = {