diff --git a/.env.example b/.env.example index 6352368..408ded9 100644 --- a/.env.example +++ b/.env.example @@ -120,3 +120,9 @@ SPOTIFY_IMPORT_SYNC_WINDOW_HOURS=2 # Get IDs from Jellyfin playlist URLs: https://jellyfin.example.com/web/#/details?id=PLAYLIST_ID # Example: SPOTIFY_IMPORT_PLAYLIST_IDS=4383a46d8bcac3be2ef9385053ea18df,ba50e26c867ec9d57ab2f7bf24cfd6b0 SPOTIFY_IMPORT_PLAYLIST_IDS= + +# Playlist names (comma-separated, must match Spotify Import plugin format) +# IMPORTANT: Plugin replaces spaces with underscores in filenames +# Must be in same order as SPOTIFY_IMPORT_PLAYLIST_IDS +# Example: SPOTIFY_IMPORT_PLAYLIST_NAMES=Discover_Weekly,Release_Radar +SPOTIFY_IMPORT_PLAYLIST_NAMES= diff --git a/allstarr/Controllers/JellyfinController.cs b/allstarr/Controllers/JellyfinController.cs index 605b72b..bd467d7 100644 --- a/allstarr/Controllers/JellyfinController.cs +++ b/allstarr/Controllers/JellyfinController.cs @@ -1993,21 +1993,15 @@ public class JellyfinController : ControllerBase var results = new Dictionary(); - // Hardcoded playlist names that match the Spotify Import plugin format - // Note: Plugin replaces spaces with underscores in filenames - var playlistNames = new Dictionary - { - { "4383a46d8bcac3be2ef9385053ea18df", "Discover_Weekly" }, - { "ba50e26c867ec9d57ab2f7bf24cfd6b0", "Release_Radar" } - }; - - foreach (var playlistId in _spotifySettings.PlaylistIds) + for (int i = 0; i < _spotifySettings.PlaylistIds.Count; i++) { + var playlistId = _spotifySettings.PlaylistIds[i]; + try { - // Use hardcoded name or fall back to ID - var playlistName = playlistNames.ContainsKey(playlistId) - ? playlistNames[playlistId] + // Use configured name if available, otherwise use ID + var playlistName = i < _spotifySettings.PlaylistNames.Count + ? _spotifySettings.PlaylistNames[i] : playlistId; _logger.LogInformation("Fetching missing tracks for {Playlist} (ID: {Id})", playlistName, playlistId); diff --git a/allstarr/Models/Settings/SpotifyImportSettings.cs b/allstarr/Models/Settings/SpotifyImportSettings.cs index 22e4104..716f35f 100644 --- a/allstarr/Models/Settings/SpotifyImportSettings.cs +++ b/allstarr/Models/Settings/SpotifyImportSettings.cs @@ -36,4 +36,12 @@ public class SpotifyImportSettings /// Get IDs from Jellyfin playlist URLs /// public List PlaylistIds { get; set; } = new(); + + /// + /// Comma-separated list of playlist names (must match Spotify Import plugin format) + /// Example: "Discover_Weekly,Release_Radar" + /// Must be in same order as PlaylistIds + /// Plugin replaces spaces with underscores in filenames + /// + public List PlaylistNames { get; set; } = new(); }