From 2dd7020a61cab710755752dca88232aa7716b83f Mon Sep 17 00:00:00 2001 From: Josh Patra Date: Fri, 6 Feb 2026 00:59:23 -0500 Subject: [PATCH] Add logging to Spotify lyrics search for better debugging Show when Spotify search is skipped, fails, or finds no matches --- allstarr/Services/Lyrics/SpotifyLyricsService.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/allstarr/Services/Lyrics/SpotifyLyricsService.cs b/allstarr/Services/Lyrics/SpotifyLyricsService.cs index c356e0d..2abda1f 100644 --- a/allstarr/Services/Lyrics/SpotifyLyricsService.cs +++ b/allstarr/Services/Lyrics/SpotifyLyricsService.cs @@ -136,6 +136,7 @@ public class SpotifyLyricsService { if (!_settings.Enabled || string.IsNullOrEmpty(_settings.SessionCookie)) { + _logger.LogDebug("Spotify lyrics search skipped: API not enabled or no session cookie"); return null; } @@ -144,6 +145,7 @@ public class SpotifyLyricsService var token = await _spotifyClient.GetWebAccessTokenAsync(); if (string.IsNullOrEmpty(token)) { + _logger.LogWarning("Could not get Spotify access token for lyrics search"); return null; } @@ -154,6 +156,8 @@ public class SpotifyLyricsService query += $" album:{albumName}"; } + _logger.LogDebug("Searching Spotify for lyrics: {Query}", query); + var searchUrl = $"https://api.spotify.com/v1/search?q={Uri.EscapeDataString(query)}&type=track&limit=5"; var request = new HttpRequestMessage(HttpMethod.Get, searchUrl); @@ -162,6 +166,7 @@ public class SpotifyLyricsService var response = await _httpClient.SendAsync(request); if (!response.IsSuccessStatusCode) { + _logger.LogWarning("Spotify search failed with status {StatusCode}", response.StatusCode); return null; } @@ -173,6 +178,7 @@ public class SpotifyLyricsService !tracks.TryGetProperty("items", out var items) || items.GetArrayLength() == 0) { + _logger.LogInformation("No Spotify tracks found for: {Track} - {Artist}", trackName, artistName); return null; } @@ -205,9 +211,11 @@ public class SpotifyLyricsService if (!string.IsNullOrEmpty(bestMatchId)) { + _logger.LogDebug("Found Spotify track match: {TrackId} (score: {Score})", bestMatchId, bestScore); return await GetLyricsByTrackIdAsync(bestMatchId); } + _logger.LogInformation("No suitable Spotify track match found for: {Track} - {Artist}", trackName, artistName); return null; } catch (Exception ex)