5be844e1b7
Format3DParser drops the last character of the final path token: when
IndexOfAny finds no more delimiters, the slice is taken with
'index = path.Length - 1', so e.g. "hsbs" is compared as "hsb" and
never matches any rule.
File paths are unaffected because the extension is always the final
token, but directory based media have no extension. For DVD/BluRay
folder rips (BaseVideoResolver parses the folder path via
Set3DFormat), a trailing 3D tag such as
"Gravity (2013) 3d hsbs/BDMV" is silently ignored and Video3DFormat
is never set.
This is a regression from 42a2cc174 which replaced the string.Split
based FlagParser with span slicing; the Split implementation kept the
final token intact.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
96 lines
3.3 KiB
C#
96 lines
3.3 KiB
C#
using Emby.Naming.Common;
|
|
using Emby.Naming.Video;
|
|
using Xunit;
|
|
|
|
namespace Jellyfin.Naming.Tests.Video
|
|
{
|
|
public class Format3DTests
|
|
{
|
|
private readonly NamingOptions _namingOptions = new NamingOptions();
|
|
|
|
[Fact]
|
|
public void TestKodiFormat3D()
|
|
{
|
|
Test("Super movie.3d.mp4", false, null);
|
|
Test("Super movie.3d.hsbs.mp4", true, "hsbs");
|
|
Test("Super movie.3d.sbs.mp4", true, "sbs");
|
|
Test("Super movie.3d.htab.mp4", true, "htab");
|
|
Test("Super movie.3d.tab.mp4", true, "tab");
|
|
Test("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()
|
|
{
|
|
var result = VideoResolver.ResolveFile("C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.3d.hsbs.mkv", _namingOptions);
|
|
|
|
Assert.Equal("hsbs", result?.Format3D);
|
|
Assert.Equal("Oblivion", result?.Name);
|
|
}
|
|
|
|
[Fact]
|
|
public void TestExpandedFormat3D()
|
|
{
|
|
// These were introduced for Media Browser 3
|
|
// Kodi conventions are preferred but these still need to be supported
|
|
|
|
Test("Super movie.3d.mp4", false, null);
|
|
Test("Super movie.3d.hsbs.mp4", true, "hsbs");
|
|
Test("Super movie.3d.sbs.mp4", true, "sbs");
|
|
Test("Super movie.3d.htab.mp4", true, "htab");
|
|
Test("Super movie.3d.tab.mp4", true, "tab");
|
|
|
|
Test("Super movie.hsbs.mp4", true, "hsbs");
|
|
Test("Super movie.sbs.mp4", true, "sbs");
|
|
Test("Super movie.htab.mp4", true, "htab");
|
|
Test("Super movie.tab.mp4", true, "tab");
|
|
Test("Super movie.sbs3d.mp4", true, "sbs3d");
|
|
Test("Super movie.3d.mvc.mp4", true, "mvc");
|
|
|
|
Test("Super movie [3d].mp4", false, null);
|
|
Test("Super movie [hsbs].mp4", true, "hsbs");
|
|
Test("Super movie [fsbs].mp4", true, "fsbs");
|
|
Test("Super movie [ftab].mp4", true, "ftab");
|
|
Test("Super movie [htab].mp4", true, "htab");
|
|
Test("Super movie [sbs3d].mp4", true, "sbs3d");
|
|
}
|
|
|
|
private void Test(string input, bool is3D, string? format3D)
|
|
{
|
|
var result = Format3DParser.Parse(input, _namingOptions);
|
|
|
|
Assert.Equal(is3D, result.Is3D);
|
|
|
|
if (format3D is null)
|
|
{
|
|
Assert.Null(result?.Format3D);
|
|
}
|
|
else
|
|
{
|
|
Assert.Equal(format3D, result.Format3D, true);
|
|
}
|
|
}
|
|
}
|
|
}
|