Fix playlist injection: Store Jellyfin playlist ID in config

- Added JellyfinId field to SpotifyPlaylistConfig model
- Updated config format: [[Name,SpotifyId,JellyfinId,position],...]
- LinkPlaylist now stores both Jellyfin and Spotify playlist IDs
- IsSpotifyPlaylist() now checks by Jellyfin playlist ID (not Spotify ID)
- GetJellyfinPlaylists shows linked status by checking JellyfinId
- Updated Program.cs to parse new 4-field format
- Backward compatible: JellyfinId defaults to empty string for old configs

This fixes the issue where playlists weren't being recognized as configured
because the code was checking Jellyfin playlist IDs against Spotify IDs.
This commit is contained in:
2026-02-03 17:18:08 -05:00
parent 7cdf7e3806
commit 5646aa07ea
3 changed files with 44 additions and 19 deletions

View File

@@ -34,6 +34,13 @@ public class SpotifyPlaylistConfig
/// </summary>
public string Id { get; set; } = string.Empty;
/// <summary>
/// Jellyfin playlist ID (internal Jellyfin GUID)
/// Example: "4383a46d8bcac3be2ef9385053ea18df"
/// This is the ID Jellyfin uses when requesting playlist tracks
/// </summary>
public string JellyfinId { get; set; } = string.Empty;
/// <summary>
/// Where to position local tracks: "first" or "last"
/// </summary>
@@ -108,6 +115,12 @@ public class SpotifyImportSettings
public SpotifyPlaylistConfig? GetPlaylistById(string playlistId) =>
Playlists.FirstOrDefault(p => p.Id.Equals(playlistId, StringComparison.OrdinalIgnoreCase));
/// <summary>
/// Gets the playlist configuration by Jellyfin playlist ID.
/// </summary>
public SpotifyPlaylistConfig? GetPlaylistByJellyfinId(string jellyfinPlaylistId) =>
Playlists.FirstOrDefault(p => p.JellyfinId.Equals(jellyfinPlaylistId, StringComparison.OrdinalIgnoreCase));
/// <summary>
/// Gets the playlist configuration by name.
/// </summary>
@@ -115,8 +128,8 @@ public class SpotifyImportSettings
Playlists.FirstOrDefault(p => p.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
/// <summary>
/// Checks if a playlist ID is configured for Spotify import.
/// Checks if a Jellyfin playlist ID is configured for Spotify import.
/// </summary>
public bool IsSpotifyPlaylist(string playlistId) =>
Playlists.Any(p => p.Id.Equals(playlistId, StringComparison.OrdinalIgnoreCase));
public bool IsSpotifyPlaylist(string jellyfinPlaylistId) =>
Playlists.Any(p => p.JellyfinId.Equals(jellyfinPlaylistId, StringComparison.OrdinalIgnoreCase));
}