mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 19:37:55 +02:00
Merge pull request #7107 from Bond-009/namingtests
This commit is contained in:
commit
072526d798
10 changed files with 42 additions and 85 deletions
|
@ -6,6 +6,8 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
{
|
||||
public class AbsoluteEpisodeNumberTests
|
||||
{
|
||||
private readonly EpisodeResolver _resolver = new EpisodeResolver(new NamingOptions());
|
||||
|
||||
[Theory]
|
||||
[InlineData("The Simpsons/12.avi", 12)]
|
||||
[InlineData("The Simpsons/The Simpsons 12.avi", 12)]
|
||||
|
@ -16,10 +18,7 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
[InlineData("The Simpsons/The Simpsons 101.avi", 101)]
|
||||
public void GetEpisodeNumberFromFileTest(string path, int episodeNumber)
|
||||
{
|
||||
var options = new NamingOptions();
|
||||
|
||||
var result = new EpisodeResolver(options)
|
||||
.Resolve(path, false, null, null, true);
|
||||
var result = _resolver.Resolve(path, false, null, null, true);
|
||||
|
||||
Assert.Equal(episodeNumber, result?.EpisodeNumber);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
{
|
||||
public class DailyEpisodeTests
|
||||
{
|
||||
private readonly EpisodeResolver _resolver = new EpisodeResolver(new NamingOptions());
|
||||
|
||||
[Theory]
|
||||
[InlineData(@"/server/anything_1996.11.14.mp4", "anything", 1996, 11, 14)]
|
||||
[InlineData(@"/server/anything_1996-11-14.mp4", "anything", 1996, 11, 14)]
|
||||
|
@ -16,10 +18,7 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
// TODO: [InlineData(@"/server/Last Man Standing_KTLADT_2018_05_25_01_28_00.wtv", "Last Man Standing", 2018, 05, 25)]
|
||||
public void Test(string path, string seriesName, int? year, int? month, int? day)
|
||||
{
|
||||
var options = new NamingOptions();
|
||||
|
||||
var result = new EpisodeResolver(options)
|
||||
.Resolve(path, false);
|
||||
var result = _resolver.Resolve(path, false);
|
||||
|
||||
Assert.Null(result?.SeasonNumber);
|
||||
Assert.Null(result?.EpisodeNumber);
|
||||
|
|
|
@ -6,6 +6,8 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
{
|
||||
public class EpisodeNumberWithoutSeasonTests
|
||||
{
|
||||
private readonly EpisodeResolver _resolver = new EpisodeResolver(new NamingOptions());
|
||||
|
||||
[Theory]
|
||||
[InlineData(8, @"The Simpsons/The Simpsons.S25E08.Steal this episode.mp4")]
|
||||
[InlineData(2, @"The Simpsons/The Simpsons - 02 - Ep Name.avi")]
|
||||
|
@ -24,10 +26,7 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
// TODO: [InlineData(13, @"Case Closed (1996-2007)/Case Closed - 13.mkv")]
|
||||
public void GetEpisodeNumberFromFileTest(int episodeNumber, string path)
|
||||
{
|
||||
var options = new NamingOptions();
|
||||
|
||||
var result = new EpisodeResolver(options)
|
||||
.Resolve(path, false);
|
||||
var result = _resolver.Resolve(path, false);
|
||||
|
||||
Assert.Equal(episodeNumber, result?.EpisodeNumber);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
{
|
||||
public class EpisodePathParserTest
|
||||
{
|
||||
private readonly NamingOptions _namingOptions = new NamingOptions();
|
||||
|
||||
[Theory]
|
||||
[InlineData("/media/Foo/Foo-S01E01", true, "Foo", 1, 1)]
|
||||
[InlineData("/media/Foo - S04E011", true, "Foo", 4, 11)]
|
||||
|
@ -36,8 +38,7 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
// TODO: [InlineData("/The.Legend.of.Condor.Heroes.2017.V2.web-dl.1080p.h264.aac-hdctv/The.Legend.of.Condor.Heroes.2017.E07.V2.web-dl.1080p.h264.aac-hdctv.mkv", "The Legend of Condor Heroes 2017", 1, 7)]
|
||||
public void ParseEpisodesCorrectly(string path, bool isDirectory, string name, int season, int episode)
|
||||
{
|
||||
NamingOptions o = new NamingOptions();
|
||||
EpisodePathParser p = new EpisodePathParser(o);
|
||||
EpisodePathParser p = new EpisodePathParser(_namingOptions);
|
||||
var res = p.Parse(path, isDirectory);
|
||||
|
||||
Assert.True(res.Success);
|
||||
|
@ -50,8 +51,7 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
[InlineData("/test/01-03.avi", true, true)]
|
||||
public void EpisodePathParserTest_DifferentExpressionsParameters(string path, bool? isNamed, bool? isOptimistic)
|
||||
{
|
||||
NamingOptions o = new NamingOptions();
|
||||
EpisodePathParser p = new EpisodePathParser(o);
|
||||
EpisodePathParser p = new EpisodePathParser(_namingOptions);
|
||||
var res = p.Parse(path, false, isNamed, isOptimistic);
|
||||
|
||||
Assert.True(res.Success);
|
||||
|
@ -60,8 +60,7 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
[Fact]
|
||||
public void EpisodePathParserTest_FalsePositivePixelRate()
|
||||
{
|
||||
NamingOptions o = new NamingOptions();
|
||||
EpisodePathParser p = new EpisodePathParser(o);
|
||||
EpisodePathParser p = new EpisodePathParser(_namingOptions);
|
||||
var res = p.Parse("Series Special (1920x1080).mkv", false);
|
||||
|
||||
Assert.False(res.Success);
|
||||
|
@ -70,14 +69,14 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
[Fact]
|
||||
public void EpisodeResolverTest_WrongExtension()
|
||||
{
|
||||
var res = new EpisodeResolver(new NamingOptions()).Resolve("test.mp3", false);
|
||||
var res = new EpisodeResolver(_namingOptions).Resolve("test.mp3", false);
|
||||
Assert.Null(res);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EpisodeResolverTest_WrongExtensionStub()
|
||||
{
|
||||
var res = new EpisodeResolver(new NamingOptions()).Resolve("dvd.disc", false);
|
||||
var res = new EpisodeResolver(_namingOptions).Resolve("dvd.disc", false);
|
||||
Assert.NotNull(res);
|
||||
Assert.True(res!.IsStub);
|
||||
}
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
using Emby.Naming.Common;
|
||||
using Emby.Naming.TV;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Naming.Tests.TV
|
||||
{
|
||||
public class EpisodeWithoutSeasonTests
|
||||
{
|
||||
// TODO: [Theory]
|
||||
// TODO: [InlineData(@"/server/anything_ep02.mp4", "anything", null, 2)]
|
||||
// TODO: [InlineData(@"/server/anything_ep_02.mp4", "anything", null, 2)]
|
||||
// TODO: [InlineData(@"/server/anything_part.II.mp4", "anything", null, null)]
|
||||
// TODO: [InlineData(@"/server/anything_pt.II.mp4", "anything", null, null)]
|
||||
// TODO: [InlineData(@"/server/anything_pt_II.mp4", "anything", null, null)]
|
||||
public void Test(string path, string seriesName, int? seasonNumber, int? episodeNumber)
|
||||
{
|
||||
var options = new NamingOptions();
|
||||
|
||||
var result = new EpisodeResolver(options)
|
||||
.Resolve(path, false);
|
||||
|
||||
Assert.Equal(seasonNumber, result?.SeasonNumber);
|
||||
Assert.Equal(episodeNumber, result?.EpisodeNumber);
|
||||
Assert.Equal(seriesName, result?.SeriesName, ignoreCase: true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,8 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
{
|
||||
public class MultiEpisodeTests
|
||||
{
|
||||
private readonly EpisodePathParser _episodePathParser = new EpisodePathParser(new NamingOptions());
|
||||
|
||||
[Theory]
|
||||
[InlineData(@"Season 1/4x01 – 20 Hours in America (1).mkv", null)]
|
||||
[InlineData(@"Season 1/01x02 blah.avi", null)]
|
||||
|
@ -69,10 +71,7 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
[InlineData(@"Season 1/MOONLIGHTING_s01e01-e04", 4)]
|
||||
public void TestGetEndingEpisodeNumberFromFile(string filename, int? endingEpisodeNumber)
|
||||
{
|
||||
var options = new NamingOptions();
|
||||
|
||||
var result = new EpisodePathParser(options)
|
||||
.Parse(filename, false);
|
||||
var result = _episodePathParser.Parse(filename, false);
|
||||
|
||||
Assert.Equal(result.EndingEpisodeNumber, endingEpisodeNumber);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
{
|
||||
public class SeasonNumberTests
|
||||
{
|
||||
private readonly NamingOptions _namingOptions = new NamingOptions();
|
||||
private readonly EpisodeResolver _resolver = new EpisodeResolver(new NamingOptions());
|
||||
|
||||
[Theory]
|
||||
[InlineData("The Daily Show/The Daily Show 25x22 - [WEBDL-720p][AAC 2.0][x264] Noah Baumbach-TBS.mkv", 25)]
|
||||
|
@ -56,8 +56,7 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
// TODO: [InlineData(@"Seinfeld/Seinfeld 0807 The Checks.avi", 8)]
|
||||
public void GetSeasonNumberFromEpisodeFileTest(string path, int? expected)
|
||||
{
|
||||
var result = new EpisodeResolver(_namingOptions)
|
||||
.Resolve(path, false);
|
||||
var result = _resolver.Resolve(path, false);
|
||||
|
||||
Assert.Equal(expected, result?.SeasonNumber);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
{
|
||||
public class SeriesPathParserTest
|
||||
{
|
||||
private readonly NamingOptions _namingOptions = new NamingOptions();
|
||||
|
||||
[Theory]
|
||||
[InlineData("The.Show.S01", "The.Show")]
|
||||
[InlineData("/The.Show.S01", "The.Show")]
|
||||
|
@ -18,8 +20,7 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
[InlineData("/something/The Show/S01", "The Show")]
|
||||
public void SeriesPathParserParseTest(string path, string name)
|
||||
{
|
||||
NamingOptions o = new NamingOptions();
|
||||
var res = SeriesPathParser.Parse(o, path);
|
||||
var res = SeriesPathParser.Parse(_namingOptions, path);
|
||||
|
||||
Assert.Equal(name, res.SeriesName);
|
||||
Assert.True(res.Success);
|
||||
|
|
|
@ -6,6 +6,8 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
{
|
||||
public class SeriesResolverTests
|
||||
{
|
||||
private readonly NamingOptions _namingOptions = new NamingOptions();
|
||||
|
||||
[Theory]
|
||||
[InlineData("The.Show.S01", "The Show")]
|
||||
[InlineData("The.Show.S01.COMPLETE", "The Show")]
|
||||
|
@ -19,8 +21,7 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
[InlineData("/some/path/The Show s02e10 the episode 720p hdtv", "The Show")]
|
||||
public void SeriesResolverResolveTest(string path, string name)
|
||||
{
|
||||
NamingOptions o = new NamingOptions();
|
||||
var res = SeriesResolver.Resolve(o, path);
|
||||
var res = SeriesResolver.Resolve(_namingOptions, path);
|
||||
|
||||
Assert.Equal(name, res.Name);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
{
|
||||
public class SimpleEpisodeTests
|
||||
{
|
||||
private readonly EpisodeResolver _resolver = new EpisodeResolver(new NamingOptions());
|
||||
|
||||
[Theory]
|
||||
[InlineData("/server/anything_s01e02.mp4", "anything", 1, 2)]
|
||||
[InlineData("/server/anything_s1e2.mp4", "anything", 1, 2)]
|
||||
|
@ -23,39 +25,25 @@ namespace Jellyfin.Naming.Tests.TV
|
|||
[InlineData(@"Love.Death.and.Robots.S01.1080p.NF.WEB-DL.DDP5.1.x264-NTG/Love.Death.and.Robots.S01E01.Sonnies.Edge.1080p.NF.WEB-DL.DDP5.1.x264-NTG.mkv", "Love.Death.and.Robots", 1, 1)]
|
||||
[InlineData("[YuiSubs] Tensura Nikki - Tensei Shitara Slime Datta Ken/[YuiSubs] Tensura Nikki - Tensei Shitara Slime Datta Ken - 12 (NVENC H.265 1080p).mkv", "Tensura Nikki - Tensei Shitara Slime Datta Ken", null, 12)]
|
||||
[InlineData("[Baz-Bar]Foo - 01 - 12[1080p][Multiple Subtitle]/[Baz-Bar] Foo - 05 [1080p][Multiple Subtitle].mkv", "Foo", null, 5)]
|
||||
[InlineData("Series/4-12 - The Woman.mp4", "", 4, 12, 12)]
|
||||
// TODO: [InlineData("E:\\Anime\\Yahari Ore no Seishun Love Comedy wa Machigatteiru\\Yahari Ore no Seishun Love Comedy wa Machigatteiru. Zoku\\Oregairu Zoku 11 - Hayama Hayato Always Renconds to Everyone's Expectations..mkv", "Yahari Ore no Seishun Love Comedy wa Machigatteiru", null, 11)]
|
||||
// TODO: [InlineData(@"/Library/Series/The Grand Tour (2016)/Season 1/S01E01 The Holy Trinity.mkv", "The Grand Tour", 1, 1)]
|
||||
public void TestSimple(string path, string seriesName, int? seasonNumber, int? episodeNumber)
|
||||
public void TestSimple(string path, string seriesName, int? seasonNumber, int? episodeNumber, int? episodeEndNumber = null)
|
||||
{
|
||||
Test(path, seriesName, seasonNumber, episodeNumber, null);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Series/4-12 - The Woman.mp4", "", 4, 12, 12)]
|
||||
public void TestWithPossibleEpisodeEnd(string path, string seriesName, int? seasonNumber, int? episodeNumber, int? episodeEndNumber)
|
||||
{
|
||||
Test(path, seriesName, seasonNumber, episodeNumber, episodeEndNumber);
|
||||
}
|
||||
|
||||
private void Test(string path, string seriesName, int? seasonNumber, int? episodeNumber, int? episodeEndNumber)
|
||||
{
|
||||
var options = new NamingOptions();
|
||||
|
||||
var result = new EpisodeResolver(options)
|
||||
.Resolve(path, false);
|
||||
var result = _resolver.Resolve(path, false);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(seasonNumber, result?.SeasonNumber);
|
||||
Assert.Equal(episodeNumber, result?.EpisodeNumber);
|
||||
Assert.Equal(seriesName, result?.SeriesName, true);
|
||||
Assert.Equal(path, result?.Path);
|
||||
Assert.Equal(seasonNumber, result!.SeasonNumber);
|
||||
Assert.Equal(episodeNumber, result!.EpisodeNumber);
|
||||
Assert.Equal(seriesName, result!.SeriesName, true);
|
||||
Assert.Equal(path, result!.Path);
|
||||
Assert.Equal(Path.GetExtension(path).Substring(1), result?.Container);
|
||||
Assert.Null(result?.Format3D);
|
||||
Assert.False(result?.Is3D);
|
||||
Assert.False(result?.IsStub);
|
||||
Assert.Null(result?.StubType);
|
||||
Assert.Equal(episodeEndNumber, result?.EndingEpisodeNumber);
|
||||
Assert.False(result?.IsByDate);
|
||||
Assert.Null(result!.Format3D);
|
||||
Assert.False(result!.Is3D);
|
||||
Assert.False(result!.IsStub);
|
||||
Assert.Null(result!.StubType);
|
||||
Assert.Equal(episodeEndNumber, result!.EndingEpisodeNumber);
|
||||
Assert.False(result!.IsByDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue