mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-10 16:08:39 -05:00
Combine Spotify playlist config into single JSON array with local track position option
This commit is contained in:
@@ -1,5 +1,44 @@
|
||||
namespace allstarr.Models.Settings;
|
||||
|
||||
/// <summary>
|
||||
/// Where to position local tracks relative to external matched tracks in Spotify playlists.
|
||||
/// </summary>
|
||||
public enum LocalTracksPosition
|
||||
{
|
||||
/// <summary>
|
||||
/// Local tracks appear first, external tracks appended at the end (default)
|
||||
/// </summary>
|
||||
First,
|
||||
|
||||
/// <summary>
|
||||
/// External tracks appear first, local tracks appended at the end
|
||||
/// </summary>
|
||||
Last
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configuration for a single Spotify Import playlist.
|
||||
/// </summary>
|
||||
public class SpotifyPlaylistConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Playlist name as it appears in Jellyfin/Spotify Import plugin
|
||||
/// Example: "Discover Weekly", "Release Radar"
|
||||
/// </summary>
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Jellyfin playlist ID (get from playlist URL)
|
||||
/// Example: "4383a46d8bcac3be2ef9385053ea18df"
|
||||
/// </summary>
|
||||
public string Id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Where to position local tracks: "first" or "last"
|
||||
/// </summary>
|
||||
public LocalTracksPosition LocalTracksPosition { get; set; } = LocalTracksPosition.First;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configuration for Spotify playlist injection feature.
|
||||
/// Requires Jellyfin Spotify Import Plugin: https://github.com/Viperinius/jellyfin-plugin-spotify-import
|
||||
@@ -34,17 +73,41 @@ public class SpotifyImportSettings
|
||||
public int SyncWindowHours { get; set; } = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Comma-separated list of Jellyfin playlist IDs to inject
|
||||
/// Example: "4383a46d8bcac3be2ef9385053ea18df,ba50e26c867ec9d57ab2f7bf24cfd6b0"
|
||||
/// Get IDs from Jellyfin playlist URLs
|
||||
/// Combined playlist configuration as JSON array.
|
||||
/// Format: [["Name","Id","first|last"],...]
|
||||
/// Example: [["Discover Weekly","abc123","first"],["Release Radar","def456","last"]]
|
||||
/// </summary>
|
||||
public List<SpotifyPlaylistConfig> Playlists { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Legacy: Comma-separated list of Jellyfin playlist IDs to inject
|
||||
/// Deprecated: Use Playlists instead
|
||||
/// </summary>
|
||||
[Obsolete("Use Playlists instead")]
|
||||
public List<string> PlaylistIds { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// Legacy: Comma-separated list of playlist names
|
||||
/// Deprecated: Use Playlists instead
|
||||
/// </summary>
|
||||
[Obsolete("Use Playlists instead")]
|
||||
public List<string> PlaylistNames { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the playlist configuration by Jellyfin playlist ID.
|
||||
/// </summary>
|
||||
public SpotifyPlaylistConfig? GetPlaylistById(string playlistId) =>
|
||||
Playlists.FirstOrDefault(p => p.Id.Equals(playlistId, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the playlist configuration by name.
|
||||
/// </summary>
|
||||
public SpotifyPlaylistConfig? GetPlaylistByName(string name) =>
|
||||
Playlists.FirstOrDefault(p => p.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a playlist ID is configured for Spotify import.
|
||||
/// </summary>
|
||||
public bool IsSpotifyPlaylist(string playlistId) =>
|
||||
Playlists.Any(p => p.Id.Equals(playlistId, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user