Fix: Register SpotifyTrackMatchingService as singleton for DI

- Register as singleton first, then as hosted service
- Allows AdminController to inject and trigger matching manually
- Added better logging for Jellyfin playlist fetch failures
- Logs when JellyfinId is missing or API calls fail
- Helps debug '0 local / 0 missing' issue
This commit is contained in:
2026-02-03 17:51:55 -05:00
parent e51d569d79
commit b16d16c9c9
2 changed files with 19 additions and 1 deletions

View File

@@ -205,6 +205,8 @@ public class AdminController : ControllerBase
var request = new HttpRequestMessage(HttpMethod.Get, url);
request.Headers.Add("X-Emby-Authorization", GetJellyfinAuthHeader());
_logger.LogDebug("Fetching Jellyfin playlist items for {Name} from {Url}", config.Name, url);
var response = await _jellyfinHttpClient.SendAsync(request);
if (response.IsSuccessStatusCode)
{
@@ -216,7 +218,18 @@ public class AdminController : ControllerBase
var localCount = items.GetArrayLength();
playlistInfo["localTracks"] = localCount;
playlistInfo["externalTracks"] = Math.Max(0, spotifyTrackCount - localCount);
_logger.LogDebug("Playlist {Name}: {Local} local tracks, {Missing} missing",
config.Name, localCount, spotifyTrackCount - localCount);
}
else
{
_logger.LogWarning("No Items property in Jellyfin response for {Name}", config.Name);
}
}
else
{
_logger.LogWarning("Failed to get Jellyfin playlist {Name}: {StatusCode}",
config.Name, response.StatusCode);
}
}
catch (Exception ex)
@@ -224,6 +237,10 @@ public class AdminController : ControllerBase
_logger.LogWarning(ex, "Failed to get Jellyfin playlist tracks for {Name}", config.Name);
}
}
else
{
_logger.LogWarning("Playlist {Name} has no JellyfinId configured", config.Name);
}
playlists.Add(playlistInfo);
}