Duncan Tourolle d3fbaef417
All checks were successful
Build Plugin / build (push) Successful in 2m21s
Allow multiple library folders
2025-12-19 23:29:25 +01:00

135 lines
4.5 KiB
C#

using System.Collections.Generic;
using MediaBrowser.Model.Plugins;
namespace Jellyfin.Plugin.JellyLMS.Configuration;
/// <summary>
/// Represents a path mapping between Jellyfin and LMS file paths.
/// </summary>
public class PathMapping
{
/// <summary>
/// Gets or sets the path prefix as seen by Jellyfin.
/// </summary>
public string JellyfinPath { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the same path prefix as seen by LMS.
/// </summary>
public string LmsPath { get; set; } = string.Empty;
}
/// <summary>
/// Plugin configuration for JellyLMS.
/// </summary>
public class PluginConfiguration : BasePluginConfiguration
{
/// <summary>
/// Initializes a new instance of the <see cref="PluginConfiguration"/> class.
/// </summary>
public PluginConfiguration()
{
LmsServerUrl = "http://localhost:9000";
LmsUsername = string.Empty;
LmsPassword = string.Empty;
JellyfinServerUrl = "http://localhost:8096";
ConnectionTimeoutSeconds = 10;
EnableAutoSync = true;
DefaultPlayerMac = string.Empty;
}
/// <summary>
/// Gets or sets the LMS server URL (e.g., http://192.168.1.100:9000).
/// </summary>
public string LmsServerUrl { get; set; }
/// <summary>
/// Gets or sets the LMS username (if authentication is enabled).
/// </summary>
public string LmsUsername { get; set; }
/// <summary>
/// Gets or sets the LMS password (if authentication is enabled).
/// </summary>
public string LmsPassword { get; set; }
/// <summary>
/// Gets or sets the Jellyfin server URL that LMS will use to stream audio.
/// This should be accessible from the LMS server.
/// </summary>
public string JellyfinServerUrl { get; set; }
/// <summary>
/// Gets or sets the connection timeout in seconds.
/// </summary>
public int ConnectionTimeoutSeconds { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to automatically sync players
/// when playing to multiple devices.
/// </summary>
public bool EnableAutoSync { get; set; }
/// <summary>
/// Gets or sets the default player MAC address to use when none is specified.
/// </summary>
public string DefaultPlayerMac { get; set; }
/// <summary>
/// Gets or sets the Jellyfin API key for authenticating stream requests from LMS.
/// </summary>
public string JellyfinApiKey { get; set; } = string.Empty;
/// <summary>
/// Gets or sets a value indicating whether to use direct file paths instead of HTTP streaming.
/// When enabled, LMS accesses files directly from shared storage, enabling native seeking.
/// </summary>
public bool UseDirectFilePath { get; set; }
/// <summary>
/// Gets or sets the media path prefix as seen by Jellyfin.
/// Used for path mapping when UseDirectFilePath is enabled.
/// Deprecated: Use PathMappings instead. Kept for backwards compatibility.
/// </summary>
public string JellyfinMediaPath { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the media path prefix as seen by LMS.
/// Used for path mapping when UseDirectFilePath is enabled.
/// Deprecated: Use PathMappings instead. Kept for backwards compatibility.
/// </summary>
public string LmsMediaPath { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the list of path mappings between Jellyfin and LMS.
/// Each mapping allows files from different locations to be played via direct file access.
/// </summary>
public List<PathMapping> PathMappings { get; set; } = new();
/// <summary>
/// Gets all effective path mappings, including legacy single mapping if configured.
/// </summary>
/// <returns>Enumerable of all configured path mappings.</returns>
public IEnumerable<PathMapping> GetAllPathMappings()
{
// Return configured list mappings first
foreach (var mapping in PathMappings)
{
if (!string.IsNullOrEmpty(mapping.JellyfinPath) && !string.IsNullOrEmpty(mapping.LmsPath))
{
yield return mapping;
}
}
// Fall back to legacy single mapping for backwards compatibility
if (!string.IsNullOrEmpty(JellyfinMediaPath) && !string.IsNullOrEmpty(LmsMediaPath))
{
yield return new PathMapping
{
JellyfinPath = JellyfinMediaPath,
LmsPath = LmsMediaPath
};
}
}
}