mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
Add playlist parsing from env var and debug logging for Spotify feature
This commit is contained in:
@@ -108,8 +108,28 @@ builder.Services.Configure<SquidWTFSettings>(
|
||||
builder.Configuration.GetSection("SquidWTF"));
|
||||
builder.Services.Configure<RedisSettings>(
|
||||
builder.Configuration.GetSection("Redis"));
|
||||
builder.Services.Configure<SpotifyImportSettings>(
|
||||
builder.Configuration.GetSection("SpotifyImport"));
|
||||
// Configure Spotify Import settings with custom playlist parsing from env var
|
||||
builder.Services.Configure<SpotifyImportSettings>(options =>
|
||||
{
|
||||
builder.Configuration.GetSection("SpotifyImport").Bind(options);
|
||||
|
||||
// Parse SPOTIFY_IMPORT_PLAYLISTS env var (comma-separated) into Playlists array
|
||||
var playlistsEnv = builder.Configuration.GetValue<string>("SpotifyImport:Playlists");
|
||||
if (!string.IsNullOrWhiteSpace(playlistsEnv) && options.Playlists.Count == 0)
|
||||
{
|
||||
options.Playlists = playlistsEnv
|
||||
.Split(',', StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(name => name.Trim())
|
||||
.Where(name => !string.IsNullOrEmpty(name))
|
||||
.Select(name => new SpotifyPlaylistConfig
|
||||
{
|
||||
Name = name,
|
||||
SpotifyName = name,
|
||||
Enabled = true
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
});
|
||||
|
||||
// Get shared settings from the active backend config
|
||||
MusicService musicService;
|
||||
|
||||
@@ -31,6 +31,8 @@ public class SpotifyMissingTracksFetcher : BackgroundService
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
_logger.LogInformation("SpotifyMissingTracksFetcher: Starting up...");
|
||||
|
||||
if (!_spotifySettings.Value.Enabled)
|
||||
{
|
||||
_logger.LogInformation("Spotify playlist injection is disabled");
|
||||
@@ -46,7 +48,14 @@ public class SpotifyMissingTracksFetcher : BackgroundService
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Spotify missing tracks fetcher started");
|
||||
_logger.LogInformation("Spotify missing tracks fetcher started - monitoring {Count} playlists",
|
||||
_spotifySettings.Value.Playlists.Count);
|
||||
|
||||
foreach (var playlist in _spotifySettings.Value.Playlists)
|
||||
{
|
||||
_logger.LogInformation(" - {Name} (SpotifyName: {SpotifyName}, Enabled: {Enabled})",
|
||||
playlist.Name, playlist.SpotifyName, playlist.Enabled);
|
||||
}
|
||||
|
||||
// Run once on startup if we haven't run in the last 24 hours
|
||||
if (!_hasRunOnce)
|
||||
|
||||
Reference in New Issue
Block a user