diff --git a/allstarr/Services/Spotify/SpotifyTrackMatchingService.cs b/allstarr/Services/Spotify/SpotifyTrackMatchingService.cs index 1c4115c..7e7dacb 100644 --- a/allstarr/Services/Spotify/SpotifyTrackMatchingService.cs +++ b/allstarr/Services/Spotify/SpotifyTrackMatchingService.cs @@ -855,6 +855,22 @@ public class SpotifyTrackMatchingService : BackgroundService var itemDict = JsonSerializer.Deserialize>(matchedJellyfinItem.Value.GetRawText()); if (itemDict != null) { + // Add Spotify ID to ProviderIds so lyrics can work for local tracks too + if (!string.IsNullOrEmpty(spotifyTrack.SpotifyId)) + { + if (!itemDict.ContainsKey("ProviderIds")) + { + itemDict["ProviderIds"] = new Dictionary(); + } + + var providerIds = itemDict["ProviderIds"] as Dictionary; + if (providerIds != null && !providerIds.ContainsKey("Spotify")) + { + providerIds["Spotify"] = spotifyTrack.SpotifyId; + _logger.LogDebug("Added Spotify ID {SpotifyId} to local track for lyrics support", spotifyTrack.SpotifyId); + } + } + finalItems.Add(itemDict); if (matchedKey != null) { @@ -1010,6 +1026,22 @@ public class SpotifyTrackMatchingService : BackgroundService var itemDict = JsonSerializer.Deserialize>(matchedJellyfinItem.Value.GetRawText()); if (itemDict != null) { + // Add Spotify ID to ProviderIds so lyrics can work for fuzzy-matched local tracks too + if (!string.IsNullOrEmpty(spotifyTrack.SpotifyId)) + { + if (!itemDict.ContainsKey("ProviderIds")) + { + itemDict["ProviderIds"] = new Dictionary(); + } + + var providerIds = itemDict["ProviderIds"] as Dictionary; + if (providerIds != null && !providerIds.ContainsKey("Spotify")) + { + providerIds["Spotify"] = spotifyTrack.SpotifyId; + _logger.LogDebug("Added Spotify ID {SpotifyId} to fuzzy-matched local track for lyrics support", spotifyTrack.SpotifyId); + } + } + finalItems.Add(itemDict); if (matchedKey != null) {