This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user