2020-11-05 15:59:15 +00:00
|
|
|
using Emby.Naming.Common;
|
2019-12-06 19:40:06 +00:00
|
|
|
using Emby.Naming.Video;
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
using Xunit;
|
2020-11-05 15:59:15 +00:00
|
|
|
using MediaType = Emby.Naming.Common.MediaType;
|
2019-12-06 19:40:06 +00:00
|
|
|
|
|
|
|
namespace Jellyfin.Naming.Tests.Video
|
|
|
|
{
|
2020-04-21 10:11:55 +00:00
|
|
|
public class ExtraTests
|
2019-12-06 19:40:06 +00:00
|
|
|
{
|
2020-04-10 23:00:30 +00:00
|
|
|
private readonly NamingOptions _videoOptions = new NamingOptions();
|
|
|
|
|
2019-12-06 19:40:06 +00:00
|
|
|
// Requirements
|
|
|
|
// movie-deleted = ExtraType deletedscene
|
|
|
|
|
|
|
|
// All of the above rules should be configurable through the options objects (ideally, even the ExtraTypes)
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void TestKodiExtras()
|
|
|
|
{
|
2021-10-05 19:47:59 +00:00
|
|
|
Test("trailer.mp4", ExtraType.Trailer);
|
|
|
|
Test("300-trailer.mp4", ExtraType.Trailer);
|
2019-12-06 19:40:06 +00:00
|
|
|
|
2021-10-05 19:47:59 +00:00
|
|
|
Test("theme.mp3", ExtraType.ThemeSong);
|
2019-12-06 19:40:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void TestExpandedExtras()
|
|
|
|
{
|
2021-10-05 19:47:59 +00:00
|
|
|
Test("trailer.mp4", ExtraType.Trailer);
|
|
|
|
Test("trailer.mp3", null);
|
|
|
|
Test("300-trailer.mp4", ExtraType.Trailer);
|
|
|
|
Test("stuff trailerthings.mkv", null);
|
|
|
|
|
|
|
|
Test("theme.mp3", ExtraType.ThemeSong);
|
|
|
|
Test("theme.mkv", null);
|
|
|
|
|
|
|
|
Test("300-scene.mp4", ExtraType.Scene);
|
|
|
|
Test("300-scene2.mp4", ExtraType.Scene);
|
|
|
|
Test("300-clip.mp4", ExtraType.Clip);
|
|
|
|
|
|
|
|
Test("300-deleted.mp4", ExtraType.DeletedScene);
|
|
|
|
Test("300-deletedscene.mp4", ExtraType.DeletedScene);
|
|
|
|
Test("300-interview.mp4", ExtraType.Interview);
|
|
|
|
Test("300-behindthescenes.mp4", ExtraType.BehindTheScenes);
|
2019-12-06 19:40:06 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 21:21:22 +00:00
|
|
|
[Theory]
|
2020-09-20 12:02:41 +00:00
|
|
|
[InlineData(ExtraType.BehindTheScenes, "behind the scenes")]
|
|
|
|
[InlineData(ExtraType.DeletedScene, "deleted scenes")]
|
|
|
|
[InlineData(ExtraType.Interview, "interviews")]
|
|
|
|
[InlineData(ExtraType.Scene, "scenes")]
|
|
|
|
[InlineData(ExtraType.Sample, "samples")]
|
2022-10-28 01:01:04 +00:00
|
|
|
[InlineData(ExtraType.Short, "shorts")]
|
|
|
|
[InlineData(ExtraType.Featurette, "featurettes")]
|
|
|
|
[InlineData(ExtraType.Clip, "clips")]
|
2021-12-24 13:09:10 +00:00
|
|
|
[InlineData(ExtraType.ThemeVideo, "backdrops")]
|
2020-09-20 12:02:41 +00:00
|
|
|
[InlineData(ExtraType.Unknown, "extras")]
|
2020-04-10 21:18:41 +00:00
|
|
|
public void TestDirectories(ExtraType type, string dirName)
|
2020-04-08 05:17:20 +00:00
|
|
|
{
|
2021-10-05 19:47:59 +00:00
|
|
|
Test(dirName + "/300.mp4", type);
|
|
|
|
Test("300/" + dirName + "/something.mkv", type);
|
|
|
|
Test("/data/something/Movies/300/" + dirName + "/whoknows.mp4", type);
|
2020-04-10 21:18:41 +00:00
|
|
|
}
|
2020-04-08 05:17:20 +00:00
|
|
|
|
2020-04-10 21:18:41 +00:00
|
|
|
[Theory]
|
|
|
|
[InlineData("gibberish")]
|
|
|
|
[InlineData("not a scene")]
|
|
|
|
[InlineData("The Big Short")]
|
|
|
|
public void TestNonExtraDirectories(string dirName)
|
|
|
|
{
|
2021-10-05 19:47:59 +00:00
|
|
|
Test(dirName + "/300.mp4", null);
|
|
|
|
Test("300/" + dirName + "/something.mkv", null);
|
|
|
|
Test("/data/something/Movies/300/" + dirName + "/whoknows.mp4", null);
|
|
|
|
Test("/data/something/Movies/" + dirName + "/" + dirName + ".mp4", null);
|
2020-04-08 05:17:20 +00:00
|
|
|
}
|
|
|
|
|
2019-12-06 19:40:06 +00:00
|
|
|
[Fact]
|
|
|
|
public void TestSample()
|
|
|
|
{
|
2021-10-05 19:47:59 +00:00
|
|
|
Test("300-sample.mp4", ExtraType.Sample);
|
2019-12-06 19:40:06 +00:00
|
|
|
}
|
|
|
|
|
2021-10-05 19:47:59 +00:00
|
|
|
private void Test(string input, ExtraType? expectedType)
|
2019-12-06 19:40:06 +00:00
|
|
|
{
|
2021-12-27 23:37:40 +00:00
|
|
|
var extraType = ExtraRuleResolver.GetExtraInfo(input, _videoOptions).ExtraType;
|
2019-12-06 19:40:06 +00:00
|
|
|
|
2021-10-05 19:47:59 +00:00
|
|
|
Assert.Equal(expectedType, extraType);
|
2019-12-06 19:40:06 +00:00
|
|
|
}
|
|
|
|
|
2020-11-05 15:59:15 +00:00
|
|
|
[Fact]
|
|
|
|
public void TestExtraInfo_InvalidRuleType()
|
|
|
|
{
|
2020-11-12 12:16:33 +00:00
|
|
|
var rule = new ExtraRule(ExtraType.Unknown, ExtraRuleType.Regex, @"([eE]x(tra)?\.\w+)", MediaType.Video);
|
|
|
|
var options = new NamingOptions { VideoExtraRules = new[] { rule } };
|
2021-12-27 23:37:40 +00:00
|
|
|
var res = ExtraRuleResolver.GetExtraInfo("extra.mp4", options);
|
2020-11-12 12:16:33 +00:00
|
|
|
|
|
|
|
Assert.Equal(rule, res.Rule);
|
2020-11-05 15:59:15 +00:00
|
|
|
}
|
2019-12-06 19:40:06 +00:00
|
|
|
}
|
|
|
|
}
|