using System.Collections.Generic;
using MediaBrowser.Model.Plugins;
namespace Jellyfin.Plugin.JellyLMS.Configuration;
///
/// Represents a path mapping between Jellyfin and LMS file paths.
///
public class PathMapping
{
///
/// Gets or sets the path prefix as seen by Jellyfin.
///
public string JellyfinPath { get; set; } = string.Empty;
///
/// Gets or sets the same path prefix as seen by LMS.
///
public string LmsPath { get; set; } = string.Empty;
}
///
/// Plugin configuration for JellyLMS.
///
public class PluginConfiguration : BasePluginConfiguration
{
///
/// Initializes a new instance of the class.
///
public PluginConfiguration()
{
LmsServerUrl = "http://localhost:9000";
LmsUsername = string.Empty;
LmsPassword = string.Empty;
JellyfinServerUrl = "http://localhost:8096";
ConnectionTimeoutSeconds = 10;
EnableAutoSync = true;
DefaultPlayerMac = string.Empty;
}
///
/// Gets or sets the LMS server URL (e.g., http://192.168.1.100:9000).
///
public string LmsServerUrl { get; set; }
///
/// Gets or sets the LMS username (if authentication is enabled).
///
public string LmsUsername { get; set; }
///
/// Gets or sets the LMS password (if authentication is enabled).
///
public string LmsPassword { get; set; }
///
/// Gets or sets the Jellyfin server URL that LMS will use to stream audio.
/// This should be accessible from the LMS server.
///
public string JellyfinServerUrl { get; set; }
///
/// Gets or sets the connection timeout in seconds.
///
public int ConnectionTimeoutSeconds { get; set; }
///
/// Gets or sets a value indicating whether to automatically sync players
/// when playing to multiple devices.
///
public bool EnableAutoSync { get; set; }
///
/// Gets or sets the default player MAC address to use when none is specified.
///
public string DefaultPlayerMac { get; set; }
///
/// Gets or sets the Jellyfin API key for authenticating stream requests from LMS.
///
public string JellyfinApiKey { get; set; } = string.Empty;
///
/// 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.
///
public bool UseDirectFilePath { get; set; }
///
/// 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.
///
public string JellyfinMediaPath { get; set; } = string.Empty;
///
/// 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.
///
public string LmsMediaPath { get; set; } = string.Empty;
///
/// 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.
///
public List PathMappings { get; set; } = new();
///
/// Gets all effective path mappings, including legacy single mapping if configured.
///
/// Enumerable of all configured path mappings.
public IEnumerable 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
};
}
}
}