From f03aa0be35ed8f49f6a2c45f61c19e909bc89a65 Mon Sep 17 00:00:00 2001 From: Josh Patra Date: Sat, 7 Feb 2026 01:16:03 -0500 Subject: [PATCH] refactor: remove lyrics prefetching UI and optimize admin endpoints --- allstarr/Controllers/AdminController.cs | 60 +++---------------------- allstarr/wwwroot/index.html | 36 ++++----------- 2 files changed, 14 insertions(+), 82 deletions(-) diff --git a/allstarr/Controllers/AdminController.cs b/allstarr/Controllers/AdminController.cs index c54ca0c..c039470 100644 --- a/allstarr/Controllers/AdminController.cs +++ b/allstarr/Controllers/AdminController.cs @@ -547,54 +547,6 @@ public class AdminController : ControllerBase _logger.LogWarning("Playlist {Name} has no JellyfinId configured", config.Name); } - // Get lyrics completion status - try - { - var tracks = await _playlistFetcher.GetPlaylistTracksAsync(config.Name); - if (tracks.Count > 0) - { - var lyricsWithCount = 0; - var lyricsWithoutCount = 0; - - foreach (var track in tracks) - { - var cacheKey = $"lyrics:{track.PrimaryArtist}:{track.Title}:{track.Album}:{track.DurationMs / 1000}"; - var existingLyrics = await _cache.GetStringAsync(cacheKey); - - if (!string.IsNullOrEmpty(existingLyrics)) - { - lyricsWithCount++; - } - else - { - lyricsWithoutCount++; - } - } - - playlistInfo["lyricsTotal"] = tracks.Count; - playlistInfo["lyricsCached"] = lyricsWithCount; - playlistInfo["lyricsMissing"] = lyricsWithoutCount; - playlistInfo["lyricsPercentage"] = tracks.Count > 0 - ? (int)Math.Round((double)lyricsWithCount / tracks.Count * 100) - : 0; - } - else - { - playlistInfo["lyricsTotal"] = 0; - playlistInfo["lyricsCached"] = 0; - playlistInfo["lyricsMissing"] = 0; - playlistInfo["lyricsPercentage"] = 0; - } - } - catch (Exception ex) - { - _logger.LogWarning(ex, "Failed to get lyrics completion for playlist {Name}", config.Name); - playlistInfo["lyricsTotal"] = 0; - playlistInfo["lyricsCached"] = 0; - playlistInfo["lyricsMissing"] = 0; - playlistInfo["lyricsPercentage"] = 0; - } - playlists.Add(playlistInfo); } @@ -3471,7 +3423,7 @@ public class LinkPlaylistRequest /// /// GET /api/admin/downloads/file - /// Downloads a specific file + /// Downloads a specific file from the kept folder /// [HttpGet("downloads/file")] public IActionResult DownloadFile([FromQuery] string path) @@ -3483,14 +3435,14 @@ public class LinkPlaylistRequest return BadRequest(new { error = "Path is required" }); } - var downloadPath = _configuration["Library:DownloadPath"] ?? "./downloads"; - var fullPath = Path.Combine(downloadPath, path); + var keptPath = _configuration["Library:KeptPath"] ?? "/app/kept"; + var fullPath = Path.Combine(keptPath, path); - // Security: Ensure the path is within the download directory + // Security: Ensure the path is within the kept directory var normalizedFullPath = Path.GetFullPath(fullPath); - var normalizedDownloadPath = Path.GetFullPath(downloadPath); + var normalizedKeptPath = Path.GetFullPath(keptPath); - if (!normalizedFullPath.StartsWith(normalizedDownloadPath)) + if (!normalizedFullPath.StartsWith(normalizedKeptPath)) { return BadRequest(new { error = "Invalid path" }); } diff --git a/allstarr/wwwroot/index.html b/allstarr/wwwroot/index.html index 7cc913c..f9f5cd5 100644 --- a/allstarr/wwwroot/index.html +++ b/allstarr/wwwroot/index.html @@ -1414,20 +1414,12 @@ - ${p.lyricsTotal > 0 ? ` -
-
-
-
- ${p.lyricsPercentage}% -
- ` : '-'} + - ${p.cacheAge || '-'} - @@ -1562,16 +1554,20 @@ } tbody.innerHTML = missingTracks.map(t => { + const artist = (t.artists && t.artists.length > 0) ? t.artists.join(', ') : ''; + const searchQuery = `${t.title} ${artist}`; return ` ${escapeHtml(t.playlist)} ${escapeHtml(t.title)} - ${escapeHtml(t.artist)} + ${escapeHtml(artist)} ${t.album ? escapeHtml(t.album) : '-'} - + - @@ -1968,22 +1964,6 @@ } } - 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'); - } - } async function searchProvider(query, provider) { // Use SquidWTF HiFi API with round-robin base URLs for all searches