v1.2.1: MusicBrainz genre enrichment + cleanup

## Features
- Implement automatic MusicBrainz genre enrichment for all external sources
  - Deezer: Enriches when genre missing
  - Qobuz: Enriches when genre missing
  - SquidWTF/Tidal: Always enriches (Tidal doesn't provide genres)
- Use ISRC codes for exact matching, fallback to title/artist search
- Cache results in Redis (30 days) + file cache for performance
- Respect MusicBrainz rate limits (1 req/sec)

## Cleanup
- Remove unused Spotify API ClientId and ClientSecret settings
- Simplify Spotify API configuration

## Fixes
- Make GenreEnrichmentService optional to fix test failures
- All 225 tests passing

This ensures all external tracks have genre metadata for better
organization and filtering in music clients.
This commit is contained in:
2026-02-10 10:29:49 -05:00
parent 96889738df
commit 9c9a827a91
3 changed files with 9 additions and 9 deletions

View File

@@ -16,13 +16,13 @@ public class DeezerMetadataService : IMusicMetadataService
{
private readonly HttpClient _httpClient;
private readonly SubsonicSettings _settings;
private readonly GenreEnrichmentService _genreEnrichment;
private readonly GenreEnrichmentService? _genreEnrichment;
private const string BaseUrl = "https://api.deezer.com";
public DeezerMetadataService(
IHttpClientFactory httpClientFactory,
IOptions<SubsonicSettings> settings,
GenreEnrichmentService genreEnrichment)
GenreEnrichmentService? genreEnrichment = null)
{
_httpClient = httpClientFactory.CreateClient();
_settings = settings.Value;
@@ -210,7 +210,7 @@ public class DeezerMetadataService : IMusicMetadataService
}
// Enrich with MusicBrainz genres if missing
if (string.IsNullOrEmpty(song.Genre))
if (_genreEnrichment != null && string.IsNullOrEmpty(song.Genre))
{
await _genreEnrichment.EnrichSongGenreAsync(song);
}

View File

@@ -19,7 +19,7 @@ public class QobuzMetadataService : IMusicMetadataService
private readonly SubsonicSettings _settings;
private readonly QobuzBundleService _bundleService;
private readonly ILogger<QobuzMetadataService> _logger;
private readonly GenreEnrichmentService _genreEnrichment;
private readonly GenreEnrichmentService? _genreEnrichment;
private readonly string? _userAuthToken;
private readonly string? _userId;
@@ -31,7 +31,7 @@ public class QobuzMetadataService : IMusicMetadataService
IOptions<QobuzSettings> qobuzSettings,
QobuzBundleService bundleService,
ILogger<QobuzMetadataService> logger,
GenreEnrichmentService genreEnrichment)
GenreEnrichmentService? genreEnrichment = null)
{
_httpClient = httpClientFactory.CreateClient();
_settings = settings.Value;
@@ -184,7 +184,7 @@ public class QobuzMetadataService : IMusicMetadataService
var song = ParseQobuzTrackFull(track);
// 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);
}

View File

@@ -56,7 +56,7 @@ public class SquidWTFMetadataService : IMusicMetadataService
private readonly ILogger<SquidWTFMetadataService> _logger;
private readonly RedisCacheService _cache;
private readonly RoundRobinFallbackHelper _fallbackHelper;
private readonly GenreEnrichmentService _genreEnrichment;
private readonly GenreEnrichmentService? _genreEnrichment;
public SquidWTFMetadataService(
IHttpClientFactory httpClientFactory,
@@ -65,7 +65,7 @@ public class SquidWTFMetadataService : IMusicMetadataService
ILogger<SquidWTFMetadataService> logger,
RedisCacheService cache,
List<string> apiUrls,
GenreEnrichmentService genreEnrichment)
GenreEnrichmentService? genreEnrichment = null)
{
_httpClient = httpClientFactory.CreateClient();
_settings = settings.Value;
@@ -290,7 +290,7 @@ public class SquidWTFMetadataService : IMusicMetadataService
var song = ParseTidalTrackFull(track);
// 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);
}