mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-10 07:58:39 -05:00
feat: add pluggable music service architecture with Qobuz support
This commit is contained in:
@@ -13,12 +13,30 @@ builder.Services.AddSwaggerGen();
|
||||
// Configuration
|
||||
builder.Services.Configure<SubsonicSettings>(
|
||||
builder.Configuration.GetSection("Subsonic"));
|
||||
builder.Services.Configure<QobuzSettings>(
|
||||
builder.Configuration.GetSection("Qobuz"));
|
||||
|
||||
// Get the configured music service
|
||||
var musicService = builder.Configuration.GetValue<MusicService>("Subsonic:MusicService");
|
||||
|
||||
// Business services
|
||||
// Registered as Singleton to share state (mappings cache, scan debounce, download tracking, rate limiting)
|
||||
builder.Services.AddSingleton<ILocalLibraryService, LocalLibraryService>();
|
||||
builder.Services.AddSingleton<IMusicMetadataService, DeezerMetadataService>();
|
||||
builder.Services.AddSingleton<IDownloadService, DeezerDownloadService>();
|
||||
|
||||
// Register music service based on configuration
|
||||
if (musicService == MusicService.Qobuz)
|
||||
{
|
||||
// Qobuz services
|
||||
builder.Services.AddSingleton<QobuzBundleService>();
|
||||
builder.Services.AddSingleton<IMusicMetadataService, QobuzMetadataService>();
|
||||
builder.Services.AddSingleton<IDownloadService, QobuzDownloadService>();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Deezer services (default)
|
||||
builder.Services.AddSingleton<IMusicMetadataService, DeezerMetadataService>();
|
||||
builder.Services.AddSingleton<IDownloadService, DeezerDownloadService>();
|
||||
}
|
||||
|
||||
// Startup validation - runs at application startup to validate configuration
|
||||
builder.Services.AddHostedService<StartupValidationService>();
|
||||
@@ -33,22 +51,22 @@ builder.Services.AddCors(options =>
|
||||
.WithExposedHeaders("X-Content-Duration", "X-Total-Count", "X-Nd-Authorization");
|
||||
});
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseCors();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseCors();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
Reference in New Issue
Block a user