From bb3140a247c98aa3a6265aae9f8290aad928cf4b Mon Sep 17 00:00:00 2001 From: Josh Patra Date: Fri, 6 Feb 2026 20:32:32 -0500 Subject: [PATCH] feat: add Spotify ID to local tracks for lyrics support - Inject Spotify ID into ProviderIds for manually mapped local tracks - Also add Spotify ID to fuzzy-matched local tracks - Enables Spotify Lyrics API to work for local Jellyfin tracks - Fallback to Spotify lyrics when local track has no embedded lyrics --- .../Spotify/SpotifyTrackMatchingService.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) 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) {