diff --git a/allstarr/Controllers/AdminController.cs b/allstarr/Controllers/AdminController.cs
index b96b547..6343cac 100644
--- a/allstarr/Controllers/AdminController.cs
+++ b/allstarr/Controllers/AdminController.cs
@@ -2891,6 +2891,74 @@ public class AdminController : ControllerBase
}
}
+ ///
+ /// Test Spotify lyrics API by fetching lyrics for a specific Spotify track ID
+ /// Example: GET /api/admin/lyrics/spotify/test?trackId=3yII7UwgLF6K5zW3xad3MP
+ ///
+ [HttpGet("lyrics/spotify/test")]
+ public async Task TestSpotifyLyrics([FromQuery] string trackId)
+ {
+ if (string.IsNullOrEmpty(trackId))
+ {
+ return BadRequest(new { error = "trackId parameter is required" });
+ }
+
+ try
+ {
+ var spotifyLyricsService = _serviceProvider.GetService();
+
+ if (spotifyLyricsService == null)
+ {
+ return StatusCode(500, new { error = "Spotify lyrics service not available" });
+ }
+
+ _logger.LogInformation("Testing Spotify lyrics for track ID: {TrackId}", trackId);
+
+ var result = await spotifyLyricsService.GetLyricsByTrackIdAsync(trackId);
+
+ if (result == null)
+ {
+ return NotFound(new
+ {
+ error = "No lyrics found",
+ trackId,
+ message = "Lyrics may not be available for this track, or the Spotify API is not configured correctly"
+ });
+ }
+
+ return Ok(new
+ {
+ success = true,
+ trackId = result.SpotifyTrackId,
+ syncType = result.SyncType,
+ lineCount = result.Lines.Count,
+ language = result.Language,
+ provider = result.Provider,
+ providerDisplayName = result.ProviderDisplayName,
+ lines = result.Lines.Select(l => new
+ {
+ startTimeMs = l.StartTimeMs,
+ endTimeMs = l.EndTimeMs,
+ words = l.Words
+ }).ToList(),
+ // Also show LRC format
+ lrcFormat = string.Join("\n", result.Lines.Select(l =>
+ {
+ var timestamp = TimeSpan.FromMilliseconds(l.StartTimeMs);
+ var mm = (int)timestamp.TotalMinutes;
+ var ss = timestamp.Seconds;
+ var ms = timestamp.Milliseconds / 10;
+ return $"[{mm:D2}:{ss:D2}.{ms:D2}]{l.Words}";
+ }))
+ });
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Failed to test Spotify lyrics for track {TrackId}", trackId);
+ return StatusCode(500, new { error = $"Failed to fetch lyrics: {ex.Message}" });
+ }
+ }
+
///
/// Prefetch lyrics for a specific playlist
///