mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-10 07:58:39 -05:00
.env format
This commit is contained in:
@@ -178,15 +178,37 @@ builder.Services.Configure<SpotifyImportSettings>(options =>
|
||||
.ToList();
|
||||
}
|
||||
|
||||
var playlistPositionsEnv = builder.Configuration.GetValue<string>("SpotifyImport:PlaylistLocalTracksPositions");
|
||||
if (!string.IsNullOrWhiteSpace(playlistPositionsEnv) && options.PlaylistLocalTracksPositions.Count == 0)
|
||||
{
|
||||
options.PlaylistLocalTracksPositions = playlistPositionsEnv
|
||||
.Split(',', StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(pos => pos.Trim())
|
||||
.Where(pos => !string.IsNullOrEmpty(pos))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
// Convert legacy format to new Playlists array
|
||||
for (int i = 0; i < options.PlaylistIds.Count; i++)
|
||||
{
|
||||
var name = i < options.PlaylistNames.Count ? options.PlaylistNames[i] : options.PlaylistIds[i];
|
||||
var position = LocalTracksPosition.First; // Default
|
||||
|
||||
// Parse position if provided
|
||||
if (i < options.PlaylistLocalTracksPositions.Count)
|
||||
{
|
||||
var posStr = options.PlaylistLocalTracksPositions[i];
|
||||
if (posStr.Equals("last", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
position = LocalTracksPosition.Last;
|
||||
}
|
||||
}
|
||||
|
||||
options.Playlists.Add(new SpotifyPlaylistConfig
|
||||
{
|
||||
Name = name,
|
||||
Id = options.PlaylistIds[i],
|
||||
LocalTracksPosition = LocalTracksPosition.First // Default for legacy
|
||||
LocalTracksPosition = position
|
||||
});
|
||||
}
|
||||
#pragma warning restore CS0618
|
||||
|
||||
Reference in New Issue
Block a user