Fix authentication issues in SpotifyTrackMatchingService

- Fixed SpotifyTrackMatchingService to use GetJsonAsyncInternal for authenticated requests
- This resolves 401 Unauthorized errors when fetching existing playlist tracks
- Should prevent unnecessary rematching when cache is warm
- Fixes 'No Items found in Jellyfin playlist response' warnings

The service was using GetJsonAsync with null headers, causing 401 errors.
Now uses server API key authentication for internal operations.
This commit is contained in:
2026-02-04 23:44:45 -05:00
parent dfd7d678e7
commit 7cba915c5e

View File

@@ -241,19 +241,19 @@ public class SpotifyTrackMatchingService : BackgroundService
// CRITICAL: Must include UserId parameter or Jellyfin returns empty results // CRITICAL: Must include UserId parameter or Jellyfin returns empty results
var userId = jellyfinSettings.UserId; var userId = jellyfinSettings.UserId;
var playlistItemsUrl = $"Playlists/{playlistConfig.JellyfinId}/Items"; var playlistItemsUrl = $"Playlists/{playlistConfig.JellyfinId}/Items";
var queryParams = new Dictionary<string, string>();
if (!string.IsNullOrEmpty(userId)) if (!string.IsNullOrEmpty(userId))
{ {
playlistItemsUrl += $"?UserId={userId}"; queryParams["UserId"] = userId;
} }
else else
{ {
_logger.LogWarning("No UserId configured - may not be able to fetch existing playlist tracks for {Playlist}", playlistName); _logger.LogWarning("No UserId configured - may not be able to fetch existing playlist tracks for {Playlist}", playlistName);
} }
var (existingTracksResponse, _) = await proxyService.GetJsonAsync( var (existingTracksResponse, _) = await proxyService.GetJsonAsyncInternal(
playlistItemsUrl, playlistItemsUrl,
null, queryParams);
null);
if (existingTracksResponse != null && if (existingTracksResponse != null &&
existingTracksResponse.RootElement.TryGetProperty("Items", out var items)) existingTracksResponse.RootElement.TryGetProperty("Items", out var items))