.env format

This commit is contained in:
2026-02-03 01:24:08 -05:00
parent 0980547848
commit 64be6eddf4
4 changed files with 55 additions and 9 deletions

View File

@@ -126,13 +126,26 @@ SPOTIFY_IMPORT_SYNC_START_MINUTE=15
# Example: If plugin runs at 4:15 PM and window is 2 hours, checks from 4:00 PM to 6:00 PM # Example: If plugin runs at 4:15 PM and window is 2 hours, checks from 4:00 PM to 6:00 PM
SPOTIFY_IMPORT_SYNC_WINDOW_HOURS=2 SPOTIFY_IMPORT_SYNC_WINDOW_HOURS=2
# Playlists configuration (JSON array format - combines name, ID, and local track position) # Playlists configuration (SIMPLE FORMAT - recommended for .env files)
# Format: [["PlaylistName","JellyfinPlaylistId","first|last"],...] # Comma-separated lists - all three must have the same number of items
# - PlaylistName: Name as it appears in Jellyfin (e.g., "Discover Weekly", "Release Radar") #
# - JellyfinPlaylistId: Get from playlist URL: https://jellyfin.example.com/web/#/details?id=PLAYLIST_ID # 1. Playlist IDs (get from Jellyfin playlist URL: https://jellyfin.example.com/web/#/details?id=PLAYLIST_ID)
# - first|last: Where to position local tracks relative to external tracks SPOTIFY_IMPORT_PLAYLIST_IDS=
# - "first": Local tracks appear first, external tracks at the end (default) #
# 2. Playlist names (as they appear in Jellyfin)
SPOTIFY_IMPORT_PLAYLIST_NAMES=
#
# 3. Local track positions (optional - defaults to "first" if not specified)
# - "first": Local tracks appear first, external tracks at the end
# - "last": External tracks appear first, local tracks at the end # - "last": External tracks appear first, local tracks at the end
# Example with 2 playlists: SPOTIFY_IMPORT_PLAYLIST_LOCAL_TRACKS_POSITIONS=
#
# Example with 4 playlists:
# SPOTIFY_IMPORT_PLAYLIST_IDS=4383a46d8bcac3be2ef9385053ea18df,ba50e26c867ec9d57ab2f7bf24cfd6b0,8203ce3be9b0053b122190eb23bac7ea,7c2b218bd69b00e24c986363ba71852f
# SPOTIFY_IMPORT_PLAYLIST_NAMES=Discover Weekly,Release Radar,Today's Top Hits,On Repeat
# SPOTIFY_IMPORT_PLAYLIST_LOCAL_TRACKS_POSITIONS=first,first,last,first
#
# Advanced: JSON array format (use only if you can't use the simple format above)
# Format: [["PlaylistName","JellyfinPlaylistId","first|last"],...]
# Note: This format may not work in .env files due to Docker Compose limitations
# SPOTIFY_IMPORT_PLAYLISTS=[["Discover Weekly","4383a46d8bcac3be2ef9385053ea18df","first"],["Release Radar","ba50e26c867ec9d57ab2f7bf24cfd6b0","last"]] # SPOTIFY_IMPORT_PLAYLISTS=[["Discover Weekly","4383a46d8bcac3be2ef9385053ea18df","first"],["Release Radar","ba50e26c867ec9d57ab2f7bf24cfd6b0","last"]]
SPOTIFY_IMPORT_PLAYLISTS=

View File

@@ -93,6 +93,14 @@ public class SpotifyImportSettings
[Obsolete("Use Playlists instead")] [Obsolete("Use Playlists instead")]
public List<string> PlaylistNames { get; set; } = new(); 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> /// <summary>
/// Gets the playlist configuration by Jellyfin playlist ID. /// Gets the playlist configuration by Jellyfin playlist ID.
/// </summary> /// </summary>

View File

@@ -178,15 +178,37 @@ builder.Services.Configure<SpotifyImportSettings>(options =>
.ToList(); .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 // Convert legacy format to new Playlists array
for (int i = 0; i < options.PlaylistIds.Count; i++) for (int i = 0; i < options.PlaylistIds.Count; i++)
{ {
var name = i < options.PlaylistNames.Count ? options.PlaylistNames[i] : options.PlaylistIds[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 options.Playlists.Add(new SpotifyPlaylistConfig
{ {
Name = name, Name = name,
Id = options.PlaylistIds[i], Id = options.PlaylistIds[i],
LocalTracksPosition = LocalTracksPosition.First // Default for legacy LocalTracksPosition = position
}); });
} }
#pragma warning restore CS0618 #pragma warning restore CS0618

View File

@@ -82,6 +82,9 @@ services:
- SpotifyImport__SyncStartMinute=${SPOTIFY_IMPORT_SYNC_START_MINUTE:-15} - SpotifyImport__SyncStartMinute=${SPOTIFY_IMPORT_SYNC_START_MINUTE:-15}
- SpotifyImport__SyncWindowHours=${SPOTIFY_IMPORT_SYNC_WINDOW_HOURS:-2} - SpotifyImport__SyncWindowHours=${SPOTIFY_IMPORT_SYNC_WINDOW_HOURS:-2}
- SpotifyImport__Playlists=${SPOTIFY_IMPORT_PLAYLISTS:-} - SpotifyImport__Playlists=${SPOTIFY_IMPORT_PLAYLISTS:-}
- SpotifyImport__PlaylistIds=${SPOTIFY_IMPORT_PLAYLIST_IDS:-}
- SpotifyImport__PlaylistNames=${SPOTIFY_IMPORT_PLAYLIST_NAMES:-}
- SpotifyImport__PlaylistLocalTracksPositions=${SPOTIFY_IMPORT_PLAYLIST_LOCAL_TRACKS_POSITIONS:-}
# ===== SHARED ===== # ===== SHARED =====
- Library__DownloadPath=/app/downloads - Library__DownloadPath=/app/downloads