mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -550,7 +550,8 @@ builder.Services.AddHostedService(sp => sp.GetRequiredService<allstarr.Services.
|
||||
builder.Services.AddHostedService<allstarr.Services.Spotify.SpotifyMissingTracksFetcher>();
|
||||
|
||||
// Register Spotify track matching service (pre-matches tracks with rate limiting)
|
||||
builder.Services.AddHostedService<allstarr.Services.Spotify.SpotifyTrackMatchingService>();
|
||||
builder.Services.AddSingleton<allstarr.Services.Spotify.SpotifyTrackMatchingService>();
|
||||
builder.Services.AddHostedService(sp => sp.GetRequiredService<allstarr.Services.Spotify.SpotifyTrackMatchingService>());
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user