Allow multiple library folders
Build Plugin / build (push) Successful in 2m21s

This commit is contained in:
2025-12-19 23:29:25 +01:00
parent c02469c6d0
commit d3fbaef417
4 changed files with 340 additions and 36 deletions
@@ -422,14 +422,7 @@ public class LmsSessionController : ISessionController, IDisposable
var positionSeconds = positionTicks / TimeSpan.TicksPerSecond;
// Check if we're using direct file path mode - if so, LMS can seek natively
var config = Plugin.Instance?.Configuration;
var canSeekNatively = config?.UseDirectFilePath == true
&& !string.IsNullOrEmpty(config.JellyfinMediaPath)
&& !string.IsNullOrEmpty(config.LmsMediaPath)
&& _currentItem?.Path != null
&& _currentItem.Path.StartsWith(config.JellyfinMediaPath, StringComparison.OrdinalIgnoreCase);
if (canSeekNatively)
if (CanSeekNatively())
{
// Use native LMS seeking - much smoother!
_logger.LogInformation("Seeking natively to {Seconds}s using LMS time command", positionSeconds);
@@ -565,24 +558,27 @@ public class LmsSessionController : ISessionController, IDisposable
{
var config = Plugin.Instance?.Configuration;
// Check if direct file path mode is enabled and configured
if (config?.UseDirectFilePath == true
&& !string.IsNullOrEmpty(config.JellyfinMediaPath)
&& !string.IsNullOrEmpty(config.LmsMediaPath)
&& _currentItem?.Path != null)
// Check if direct file path mode is enabled
if (config?.UseDirectFilePath == true && _currentItem?.Path != null)
{
var directPath = BuildDirectFilePath(_currentItem.Path, config.JellyfinMediaPath, config.LmsMediaPath);
if (directPath != null)
// Try each path mapping until one matches
foreach (var mapping in config.GetAllPathMappings())
{
_logger.LogDebug(
"Using direct file path: {OriginalPath} -> {MappedPath}",
_currentItem.Path,
directPath);
return (directPath, true);
var directPath = BuildDirectFilePath(_currentItem.Path, mapping.JellyfinPath, mapping.LmsPath);
if (directPath != null)
{
_logger.LogDebug(
"Using direct file path with mapping '{JellyfinPath}' -> '{LmsPath}': {OriginalPath} -> {MappedPath}",
mapping.JellyfinPath,
mapping.LmsPath,
_currentItem.Path,
directPath);
return (directPath, true);
}
}
_logger.LogWarning(
"Direct file path mode enabled but path mapping failed for: {Path}",
"Direct file path mode enabled but no path mapping matched for: {Path}",
_currentItem.Path);
}
@@ -590,6 +586,31 @@ public class LmsSessionController : ISessionController, IDisposable
return (BuildStreamUrlWithPosition(itemId, startPositionTicks), false);
}
/// <summary>
/// Checks if the current item can use native LMS seeking (direct file path mode).
/// </summary>
private bool CanSeekNatively()
{
var config = Plugin.Instance?.Configuration;
if (config?.UseDirectFilePath != true || _currentItem?.Path == null)
{
return false;
}
// Check if any mapping matches the current item's path
foreach (var mapping in config.GetAllPathMappings())
{
var normalizedPath = _currentItem.Path.Replace('\\', '/');
var normalizedPrefix = mapping.JellyfinPath.TrimEnd('/', '\\').Replace('\\', '/');
if (normalizedPath.StartsWith(normalizedPrefix, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
return false;
}
/// <summary>
/// Maps a Jellyfin file path to an LMS file path using the configured path prefixes.
/// </summary>