diff options
| author | Bond-009 <bond.009@outlook.com> | 2026-07-28 20:05:51 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-28 20:05:51 +0200 |
| commit | 41b8bd4459706a1d9107bad9b40892ba37b8659c (patch) | |
| tree | 4314e894ed5786707ad1a8a7620f8836dc42378f | |
| parent | 7215950bd4ff42fa8b48f99cf3d09380586500da (diff) | |
| parent | 5be844e1b755bca6b8dd23509f96b7040b16f2f3 (diff) | |
Merge pull request #17310 from TowyTowy/fix/format3d-trailing-token
Fix 3D format detection when the tag is the last token of the path
| -rw-r--r-- | Emby.Naming/Video/Format3DParser.cs | 13 | ||||
| -rw-r--r-- | tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs | 21 |
2 files changed, 30 insertions, 4 deletions
diff --git a/Emby.Naming/Video/Format3DParser.cs b/Emby.Naming/Video/Format3DParser.cs index eb5e71d78f..a287a2525b 100644 --- a/Emby.Naming/Video/Format3DParser.cs +++ b/Emby.Naming/Video/Format3DParser.cs @@ -52,13 +52,18 @@ namespace Emby.Naming.Video while (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.cs index d42bd66a1c..0e35071dd4 100644 --- a/tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs +++ b/tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs @@ -20,6 +20,27 @@ namespace Jellyfin.Naming.Tests.Video } [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() { var result = VideoResolver.ResolveFile("C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.3d.hsbs.mkv", _namingOptions); |
