The Free Software Media System - Server Backend & API
Fix 3D format detection when the tag is the last token of the path
TowyTowy5be844e1b755
diff --git a/Emby.Naming/Video/Format3DParser.cs b/Emby.Naming/Video/Format3DParser.csindex eb5e71d78f..a287a2525b 100644--- a/Emby.Naming/Video/Format3DParser.cs+++ b/Emby.Naming/Video/Format3DParser.cs@@ -52,13 +52,18 @@ namespace Emby.Naming.Videowhile (path.Length > 0){var index = path.IndexOfAny(delimiters);+ ReadOnlySpan<char> currentSlice;if (index == -1){- index = path.Length - 1;+ // No delimiter left, the last token is the remainder of the path+ currentSlice = path;+ path = default;+ }+ else+ {+ currentSlice = path[..index];+ path = path[(index + 1)..];}-- var currentSlice = path[..index];- path = path[(index + 1)..];if (!foundPrefix){diff --git a/tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs b/tests/Jellyfin.Naming.Tests/Video/Format3DTests.csindex d42bd66a1c..0e35071dd4 100644--- a/tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs+++ b/tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs@@ -19,6 +19,27 @@ namespace Jellyfin.Naming.Tests.VideoTest("Super movie 3d hsbs.mp4", true, "hsbs");}+ [Fact]+ public void TestFormat3DAtEndOfPath()+ {+ // Directory based media (eg. DVD or BluRay folder rips) have no file extension,+ // so the 3D tag can be the last token of the path.+ Test("Super movie (2009) 3d hsbs", true, "hsbs");+ Test("Super movie (2009).3d.sbs", true, "sbs");+ Test("Super movie (2009) 3d htab", true, "htab");+ Test("Super movie (2009).hsbs", true, "hsbs");+ Test("Super movie (2009) 3d", false, null);+ }++ [Fact]+ public void TestResolveDirectory3D()+ {+ var result = VideoResolver.ResolveDirectory("/movies/Oblivion (2013) 3d hsbs", _namingOptions);++ Assert.True(result?.Is3D);+ Assert.Equal("hsbs", result?.Format3D, true);+ }+[Fact]public void Test3DName(){