mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-10 16:08:39 -05:00
fix: make GenreEnrichmentService optional in metadata services
- Add null checks before calling genre enrichment - Make constructor parameter optional with default null - Fixes test failures where GenreEnrichmentService couldn't be mocked - All 225 tests now passing
This commit is contained in:
@@ -16,13 +16,13 @@ public class DeezerMetadataService : IMusicMetadataService
|
|||||||
{
|
{
|
||||||
private readonly HttpClient _httpClient;
|
private readonly HttpClient _httpClient;
|
||||||
private readonly SubsonicSettings _settings;
|
private readonly SubsonicSettings _settings;
|
||||||
private readonly GenreEnrichmentService _genreEnrichment;
|
private readonly GenreEnrichmentService? _genreEnrichment;
|
||||||
private const string BaseUrl = "https://api.deezer.com";
|
private const string BaseUrl = "https://api.deezer.com";
|
||||||
|
|
||||||
public DeezerMetadataService(
|
public DeezerMetadataService(
|
||||||
IHttpClientFactory httpClientFactory,
|
IHttpClientFactory httpClientFactory,
|
||||||
IOptions<SubsonicSettings> settings,
|
IOptions<SubsonicSettings> settings,
|
||||||
GenreEnrichmentService genreEnrichment)
|
GenreEnrichmentService? genreEnrichment = null)
|
||||||
{
|
{
|
||||||
_httpClient = httpClientFactory.CreateClient();
|
_httpClient = httpClientFactory.CreateClient();
|
||||||
_settings = settings.Value;
|
_settings = settings.Value;
|
||||||
@@ -210,7 +210,7 @@ public class DeezerMetadataService : IMusicMetadataService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Enrich with MusicBrainz genres if missing
|
// Enrich with MusicBrainz genres if missing
|
||||||
if (string.IsNullOrEmpty(song.Genre))
|
if (_genreEnrichment != null && string.IsNullOrEmpty(song.Genre))
|
||||||
{
|
{
|
||||||
await _genreEnrichment.EnrichSongGenreAsync(song);
|
await _genreEnrichment.EnrichSongGenreAsync(song);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class QobuzMetadataService : IMusicMetadataService
|
|||||||
private readonly SubsonicSettings _settings;
|
private readonly SubsonicSettings _settings;
|
||||||
private readonly QobuzBundleService _bundleService;
|
private readonly QobuzBundleService _bundleService;
|
||||||
private readonly ILogger<QobuzMetadataService> _logger;
|
private readonly ILogger<QobuzMetadataService> _logger;
|
||||||
private readonly GenreEnrichmentService _genreEnrichment;
|
private readonly GenreEnrichmentService? _genreEnrichment;
|
||||||
private readonly string? _userAuthToken;
|
private readonly string? _userAuthToken;
|
||||||
private readonly string? _userId;
|
private readonly string? _userId;
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ public class QobuzMetadataService : IMusicMetadataService
|
|||||||
IOptions<QobuzSettings> qobuzSettings,
|
IOptions<QobuzSettings> qobuzSettings,
|
||||||
QobuzBundleService bundleService,
|
QobuzBundleService bundleService,
|
||||||
ILogger<QobuzMetadataService> logger,
|
ILogger<QobuzMetadataService> logger,
|
||||||
GenreEnrichmentService genreEnrichment)
|
GenreEnrichmentService? genreEnrichment = null)
|
||||||
{
|
{
|
||||||
_httpClient = httpClientFactory.CreateClient();
|
_httpClient = httpClientFactory.CreateClient();
|
||||||
_settings = settings.Value;
|
_settings = settings.Value;
|
||||||
@@ -184,7 +184,7 @@ public class QobuzMetadataService : IMusicMetadataService
|
|||||||
var song = ParseQobuzTrackFull(track);
|
var song = ParseQobuzTrackFull(track);
|
||||||
|
|
||||||
// Enrich with MusicBrainz genres if missing
|
// Enrich with MusicBrainz genres if missing
|
||||||
if (song != null && string.IsNullOrEmpty(song.Genre))
|
if (_genreEnrichment != null && song != null && string.IsNullOrEmpty(song.Genre))
|
||||||
{
|
{
|
||||||
await _genreEnrichment.EnrichSongGenreAsync(song);
|
await _genreEnrichment.EnrichSongGenreAsync(song);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class SquidWTFMetadataService : IMusicMetadataService
|
|||||||
private readonly ILogger<SquidWTFMetadataService> _logger;
|
private readonly ILogger<SquidWTFMetadataService> _logger;
|
||||||
private readonly RedisCacheService _cache;
|
private readonly RedisCacheService _cache;
|
||||||
private readonly RoundRobinFallbackHelper _fallbackHelper;
|
private readonly RoundRobinFallbackHelper _fallbackHelper;
|
||||||
private readonly GenreEnrichmentService _genreEnrichment;
|
private readonly GenreEnrichmentService? _genreEnrichment;
|
||||||
|
|
||||||
public SquidWTFMetadataService(
|
public SquidWTFMetadataService(
|
||||||
IHttpClientFactory httpClientFactory,
|
IHttpClientFactory httpClientFactory,
|
||||||
@@ -65,7 +65,7 @@ public class SquidWTFMetadataService : IMusicMetadataService
|
|||||||
ILogger<SquidWTFMetadataService> logger,
|
ILogger<SquidWTFMetadataService> logger,
|
||||||
RedisCacheService cache,
|
RedisCacheService cache,
|
||||||
List<string> apiUrls,
|
List<string> apiUrls,
|
||||||
GenreEnrichmentService genreEnrichment)
|
GenreEnrichmentService? genreEnrichment = null)
|
||||||
{
|
{
|
||||||
_httpClient = httpClientFactory.CreateClient();
|
_httpClient = httpClientFactory.CreateClient();
|
||||||
_settings = settings.Value;
|
_settings = settings.Value;
|
||||||
@@ -290,7 +290,7 @@ public class SquidWTFMetadataService : IMusicMetadataService
|
|||||||
var song = ParseTidalTrackFull(track);
|
var song = ParseTidalTrackFull(track);
|
||||||
|
|
||||||
// Enrich with MusicBrainz genres if missing (SquidWTF/Tidal doesn't provide genres)
|
// Enrich with MusicBrainz genres if missing (SquidWTF/Tidal doesn't provide genres)
|
||||||
if (string.IsNullOrEmpty(song.Genre))
|
if (_genreEnrichment != null && string.IsNullOrEmpty(song.Genre))
|
||||||
{
|
{
|
||||||
await _genreEnrichment.EnrichSongGenreAsync(song);
|
await _genreEnrichment.EnrichSongGenreAsync(song);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user