mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
.env format
This commit is contained in:
@@ -93,6 +93,14 @@ public class SpotifyImportSettings
|
||||
[Obsolete("Use Playlists instead")]
|
||||
public List<string> PlaylistNames { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Legacy: Comma-separated list of local track positions ("first" or "last")
|
||||
/// Deprecated: Use Playlists instead
|
||||
/// Example: "first,last,first,first" (one per playlist)
|
||||
/// </summary>
|
||||
[Obsolete("Use Playlists instead")]
|
||||
public List<string> PlaylistLocalTracksPositions { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the playlist configuration by Jellyfin playlist ID.
|
||||
/// </summary>
|
||||
|
||||
@@ -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