refactor: remove lyrics prefetching UI and optimize admin endpoints

This commit is contained in:
2026-02-07 01:16:03 -05:00
parent 440ef9850f
commit f03aa0be35
2 changed files with 14 additions and 82 deletions

View File

@@ -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
/// <summary>
/// GET /api/admin/downloads/file
/// Downloads a specific file
/// Downloads a specific file from the kept folder
/// </summary>
[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" });
}