Finish coverage for Emby.Naming.Video
This commit is contained in:
parent
5741150367
commit
3466dc5581
|
@ -120,9 +120,9 @@ namespace Emby.Naming.Common
|
||||||
|
|
||||||
VideoFileStackingExpressions = new[]
|
VideoFileStackingExpressions = new[]
|
||||||
{
|
{
|
||||||
"(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[0-9]+)(.*?)(\\.[^.]+)$",
|
"(?<title>.*?)(?<volume>[ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[0-9]+)(?<ignore>.*?)(?<extension>\\.[^.]+)$",
|
||||||
"(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[a-d])(.*?)(\\.[^.]+)$",
|
"(?<title>.*?)(?<volume>[ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[a-d])(?<ignore>.*?)(?<extension>\\.[^.]+)$",
|
||||||
"(.*?)([ ._-]*[a-d])(.*?)(\\.[^.]+)$"
|
"(?<title>.*?)(?<volume>[ ._-]*[a-d])(?<ignore>.*?)(?<extension>\\.[^.]+)$"
|
||||||
};
|
};
|
||||||
|
|
||||||
CleanDateTimes = new[]
|
CleanDateTimes = new[]
|
||||||
|
|
|
@ -45,7 +45,8 @@ namespace Emby.Naming.Video
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return result;
|
// Currently unreachable code if new rule.MediaType is desired add if clause with proper tests
|
||||||
|
throw new InvalidOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rule.RuleType == ExtraRuleType.Filename)
|
if (rule.RuleType == ExtraRuleType.Filename)
|
||||||
|
@ -70,6 +71,9 @@ namespace Emby.Naming.Video
|
||||||
}
|
}
|
||||||
else if (rule.RuleType == ExtraRuleType.Regex)
|
else if (rule.RuleType == ExtraRuleType.Regex)
|
||||||
{
|
{
|
||||||
|
// Currently unreachable code if new rule.MediaType is desired add if clause with proper tests
|
||||||
|
throw new InvalidOperationException();
|
||||||
|
/*
|
||||||
var filename = Path.GetFileName(path);
|
var filename = Path.GetFileName(path);
|
||||||
|
|
||||||
var regex = new Regex(rule.Token, RegexOptions.IgnoreCase);
|
var regex = new Regex(rule.Token, RegexOptions.IgnoreCase);
|
||||||
|
@ -79,6 +83,7 @@ namespace Emby.Naming.Video
|
||||||
result.ExtraType = rule.ExtraType;
|
result.ExtraType = rule.ExtraType;
|
||||||
result.Rule = rule;
|
result.Rule = rule;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
else if (rule.RuleType == ExtraRuleType.DirectoryName)
|
else if (rule.RuleType == ExtraRuleType.DirectoryName)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace Emby.Naming.Video
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(path))
|
if (string.IsNullOrEmpty(path))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(path));
|
return Array.Empty<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: the tags need be be surrounded be either a space ( ), hyphen -, dot . or underscore _.
|
// Note: the tags need be be surrounded be either a space ( ), hyphen -, dot . or underscore _.
|
||||||
|
|
|
@ -86,10 +86,10 @@ namespace Emby.Naming.Video
|
||||||
|
|
||||||
if (match1.Success)
|
if (match1.Success)
|
||||||
{
|
{
|
||||||
var title1 = match1.Groups[1].Value;
|
var title1 = match1.Groups["title"].Value;
|
||||||
var volume1 = match1.Groups[2].Value;
|
var volume1 = match1.Groups["volume"].Value;
|
||||||
var ignore1 = match1.Groups[3].Value;
|
var ignore1 = match1.Groups["ignore"].Value;
|
||||||
var extension1 = match1.Groups[4].Value;
|
var extension1 = match1.Groups["extension"].Value;
|
||||||
|
|
||||||
var j = i + 1;
|
var j = i + 1;
|
||||||
while (j < list.Count)
|
while (j < list.Count)
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Emby.Naming.Video
|
||||||
{
|
{
|
||||||
stubType = default;
|
stubType = default;
|
||||||
|
|
||||||
if (path == null)
|
if (string.IsNullOrEmpty(path))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,35 @@ namespace Emby.Naming.Video
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class VideoFileInfo
|
public class VideoFileInfo
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="VideoFileInfo"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Name of file.</param>
|
||||||
|
/// <param name="path">Path to the file.</param>
|
||||||
|
/// <param name="container">Container type.</param>
|
||||||
|
/// <param name="year">Year of release.</param>
|
||||||
|
/// <param name="extraType">Extra type.</param>
|
||||||
|
/// <param name="extraRule">Extra rule.</param>
|
||||||
|
/// <param name="format3D">Format 3D.</param>
|
||||||
|
/// <param name="is3D">Is 3D.</param>
|
||||||
|
/// <param name="isStub">Is Stub.</param>
|
||||||
|
/// <param name="stubType">Stub type.</param>
|
||||||
|
/// <param name="isDirectory">Is directory.</param>
|
||||||
|
public VideoFileInfo(string name, string? path, string? container, int? year = default, ExtraType? extraType = default, ExtraRule? extraRule = default, string? format3D = default, bool is3D = default, bool isStub = default, string? stubType = default, bool isDirectory = default)
|
||||||
|
{
|
||||||
|
Path = path;
|
||||||
|
Container = container;
|
||||||
|
Name = name;
|
||||||
|
Year = year;
|
||||||
|
ExtraType = extraType;
|
||||||
|
ExtraRule = extraRule;
|
||||||
|
Format3D = format3D;
|
||||||
|
Is3D = is3D;
|
||||||
|
IsStub = isStub;
|
||||||
|
StubType = stubType;
|
||||||
|
IsDirectory = isDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the path.
|
/// Gets or sets the path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -23,7 +52,7 @@ namespace Emby.Naming.Video
|
||||||
/// Gets or sets the name.
|
/// Gets or sets the name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The name.</value>
|
/// <value>The name.</value>
|
||||||
public string? Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the year.
|
/// Gets or sets the year.
|
||||||
|
@ -84,8 +113,7 @@ namespace Emby.Naming.Video
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
// Makes debugging easier
|
return "VideoFileInfo(Name: '" + Name + "')";
|
||||||
return Name ?? base.ToString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace Emby.Naming.Video
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(path))
|
if (string.IsNullOrEmpty(path))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(path));
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isStub = false;
|
bool isStub = false;
|
||||||
|
@ -99,20 +99,18 @@ namespace Emby.Naming.Video
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new VideoFileInfo
|
return new VideoFileInfo(
|
||||||
{
|
path: path,
|
||||||
Path = path,
|
container: container,
|
||||||
Container = container,
|
isStub: isStub,
|
||||||
IsStub = isStub,
|
name: name,
|
||||||
Name = name,
|
year: year,
|
||||||
Year = year,
|
stubType: stubType,
|
||||||
StubType = stubType,
|
is3D: format3DResult.Is3D,
|
||||||
Is3D = format3DResult.Is3D,
|
format3D: format3DResult.Format3D,
|
||||||
Format3D = format3DResult.Format3D,
|
extraType: extraResult.ExtraType,
|
||||||
ExtraType = extraResult.ExtraType,
|
isDirectory: isDirectory,
|
||||||
IsDirectory = isDirectory,
|
extraRule: extraResult.Rule);
|
||||||
ExtraRule = extraResult.Rule
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsVideoFile(string path)
|
public bool IsVideoFile(string path)
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
using Emby.Naming.Common;
|
using System;
|
||||||
|
using Emby.Naming.Common;
|
||||||
using Emby.Naming.Video;
|
using Emby.Naming.Video;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
using MediaType = Emby.Naming.Common.MediaType;
|
||||||
|
|
||||||
namespace Jellyfin.Naming.Tests.Video
|
namespace Jellyfin.Naming.Tests.Video
|
||||||
{
|
{
|
||||||
|
@ -93,6 +95,27 @@ namespace Jellyfin.Naming.Tests.Video
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TestExtraInfo_InvalidRuleMediaType()
|
||||||
|
{
|
||||||
|
var options = new NamingOptions { VideoExtraRules = new[] { new ExtraRule(ExtraType.Unknown, ExtraRuleType.DirectoryName, " ", MediaType.Photo) } };
|
||||||
|
Assert.Throws<InvalidOperationException>(() => GetExtraTypeParser(options).GetExtraInfo("sample.jpg"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TestExtraInfo_InvalidRuleType()
|
||||||
|
{
|
||||||
|
var options = new NamingOptions { VideoExtraRules = new[] { new ExtraRule(ExtraType.Unknown, ExtraRuleType.Regex, " ", MediaType.Video) } };
|
||||||
|
Assert.Throws<InvalidOperationException>(() => GetExtraTypeParser(options).GetExtraInfo("sample.mp4"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TestFlagsParser()
|
||||||
|
{
|
||||||
|
var flags = new FlagParser(_videoOptions).GetFlags(string.Empty);
|
||||||
|
Assert.Empty(flags);
|
||||||
|
}
|
||||||
|
|
||||||
private ExtraResolver GetExtraTypeParser(NamingOptions videoOptions)
|
private ExtraResolver GetExtraTypeParser(NamingOptions videoOptions)
|
||||||
{
|
{
|
||||||
return new ExtraResolver(videoOptions);
|
return new ExtraResolver(videoOptions);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Emby.Naming.Common;
|
using Emby.Naming.Common;
|
||||||
using Emby.Naming.Video;
|
using Emby.Naming.Video;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ namespace Jellyfin.Naming.Tests.Video
|
||||||
Test("video.hdtv.disc", true, "tv");
|
Test("video.hdtv.disc", true, "tv");
|
||||||
Test("video.pdtv.disc", true, "tv");
|
Test("video.pdtv.disc", true, "tv");
|
||||||
Test("video.dsr.disc", true, "tv");
|
Test("video.dsr.disc", true, "tv");
|
||||||
|
Test(string.Empty, false, "tv");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Emby.Naming.Common;
|
using Emby.Naming.Common;
|
||||||
using Emby.Naming.Video;
|
using Emby.Naming.Video;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
|
@ -369,6 +369,26 @@ namespace Jellyfin.Naming.Tests.Video
|
||||||
Assert.Single(result);
|
Assert.Single(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TestFourRooms()
|
||||||
|
{
|
||||||
|
var files = new[]
|
||||||
|
{
|
||||||
|
@"Four Rooms - A.avi",
|
||||||
|
@"Four Rooms - A.mp4"
|
||||||
|
};
|
||||||
|
|
||||||
|
var resolver = GetResolver();
|
||||||
|
|
||||||
|
var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
|
||||||
|
{
|
||||||
|
IsDirectory = false,
|
||||||
|
FullName = i
|
||||||
|
}).ToList()).ToList();
|
||||||
|
|
||||||
|
Assert.Equal(2, result.Count);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TestMovieTrailer()
|
public void TestMovieTrailer()
|
||||||
{
|
{
|
||||||
|
@ -431,6 +451,13 @@ namespace Jellyfin.Naming.Tests.Video
|
||||||
Assert.Single(result);
|
Assert.Single(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TestDirectoryStack()
|
||||||
|
{
|
||||||
|
var stack = new FileStack();
|
||||||
|
Assert.False(stack.ContainsFile("XX", true));
|
||||||
|
}
|
||||||
|
|
||||||
private VideoListResolver GetResolver()
|
private VideoListResolver GetResolver()
|
||||||
{
|
{
|
||||||
return new VideoListResolver(_namingOptions);
|
return new VideoListResolver(_namingOptions);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Emby.Naming.Common;
|
using Emby.Naming.Common;
|
||||||
using Emby.Naming.Video;
|
using Emby.Naming.Video;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
@ -14,165 +15,135 @@ namespace Jellyfin.Naming.Tests.Video
|
||||||
{
|
{
|
||||||
yield return new object[]
|
yield return new object[]
|
||||||
{
|
{
|
||||||
new VideoFileInfo()
|
new VideoFileInfo(
|
||||||
{
|
path: @"/server/Movies/7 Psychos.mkv/7 Psychos.mkv",
|
||||||
Path = @"/server/Movies/7 Psychos.mkv/7 Psychos.mkv",
|
container: "mkv",
|
||||||
Container = "mkv",
|
name: "7 Psychos")
|
||||||
Name = "7 Psychos"
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
yield return new object[]
|
yield return new object[]
|
||||||
{
|
{
|
||||||
new VideoFileInfo()
|
new VideoFileInfo(
|
||||||
{
|
path: @"/server/Movies/3 days to kill (2005)/3 days to kill (2005).mkv",
|
||||||
Path = @"/server/Movies/3 days to kill (2005)/3 days to kill (2005).mkv",
|
container: "mkv",
|
||||||
Container = "mkv",
|
name: "3 days to kill",
|
||||||
Name = "3 days to kill",
|
year: 2005)
|
||||||
Year = 2005
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
yield return new object[]
|
yield return new object[]
|
||||||
{
|
{
|
||||||
new VideoFileInfo()
|
new VideoFileInfo(
|
||||||
{
|
path: @"/server/Movies/American Psycho/American.Psycho.mkv",
|
||||||
Path = @"/server/Movies/American Psycho/American.Psycho.mkv",
|
container: "mkv",
|
||||||
Container = "mkv",
|
name: "American.Psycho")
|
||||||
Name = "American.Psycho",
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
yield return new object[]
|
yield return new object[]
|
||||||
{
|
{
|
||||||
new VideoFileInfo()
|
new VideoFileInfo(
|
||||||
{
|
path: @"/server/Movies/brave (2007)/brave (2006).3d.sbs.mkv",
|
||||||
Path = @"/server/Movies/brave (2007)/brave (2006).3d.sbs.mkv",
|
container: "mkv",
|
||||||
Container = "mkv",
|
name: "brave",
|
||||||
Name = "brave",
|
year: 2006,
|
||||||
Year = 2006,
|
is3D: true,
|
||||||
Is3D = true,
|
format3D: "sbs")
|
||||||
Format3D = "sbs",
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
yield return new object[]
|
yield return new object[]
|
||||||
{
|
{
|
||||||
new VideoFileInfo()
|
new VideoFileInfo(
|
||||||
{
|
path: @"/server/Movies/300 (2007)/300 (2006).3d1.sbas.mkv",
|
||||||
Path = @"/server/Movies/300 (2007)/300 (2006).3d1.sbas.mkv",
|
container: "mkv",
|
||||||
Container = "mkv",
|
name: "300",
|
||||||
Name = "300",
|
year: 2006)
|
||||||
Year = 2006
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
yield return new object[]
|
yield return new object[]
|
||||||
{
|
{
|
||||||
new VideoFileInfo()
|
new VideoFileInfo(
|
||||||
{
|
path: @"/server/Movies/300 (2007)/300 (2006).3d.sbs.mkv",
|
||||||
Path = @"/server/Movies/300 (2007)/300 (2006).3d.sbs.mkv",
|
container: "mkv",
|
||||||
Container = "mkv",
|
name: "300",
|
||||||
Name = "300",
|
year: 2006,
|
||||||
Year = 2006,
|
is3D: true,
|
||||||
Is3D = true,
|
format3D: "sbs")
|
||||||
Format3D = "sbs",
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
yield return new object[]
|
yield return new object[]
|
||||||
{
|
{
|
||||||
new VideoFileInfo()
|
new VideoFileInfo(
|
||||||
{
|
path: @"/server/Movies/brave (2007)/brave (2006)-trailer.bluray.disc",
|
||||||
Path = @"/server/Movies/brave (2007)/brave (2006)-trailer.bluray.disc",
|
container: "disc",
|
||||||
Container = "disc",
|
name: "brave",
|
||||||
Name = "brave",
|
year: 2006,
|
||||||
Year = 2006,
|
isStub: true,
|
||||||
IsStub = true,
|
stubType: "bluray")
|
||||||
StubType = "bluray",
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
yield return new object[]
|
yield return new object[]
|
||||||
{
|
{
|
||||||
new VideoFileInfo()
|
new VideoFileInfo(
|
||||||
{
|
path: @"/server/Movies/300 (2007)/300 (2006)-trailer.bluray.disc",
|
||||||
Path = @"/server/Movies/300 (2007)/300 (2006)-trailer.bluray.disc",
|
container: "disc",
|
||||||
Container = "disc",
|
name: "300",
|
||||||
Name = "300",
|
year: 2006,
|
||||||
Year = 2006,
|
isStub: true,
|
||||||
IsStub = true,
|
stubType: "bluray")
|
||||||
StubType = "bluray",
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
yield return new object[]
|
yield return new object[]
|
||||||
{
|
{
|
||||||
new VideoFileInfo()
|
new VideoFileInfo(
|
||||||
{
|
path: @"/server/Movies/Brave (2007)/Brave (2006).bluray.disc",
|
||||||
Path = @"/server/Movies/Brave (2007)/Brave (2006).bluray.disc",
|
container: "disc",
|
||||||
Container = "disc",
|
name: "Brave",
|
||||||
Name = "Brave",
|
year: 2006,
|
||||||
Year = 2006,
|
isStub: true,
|
||||||
IsStub = true,
|
stubType: "bluray")
|
||||||
StubType = "bluray",
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
yield return new object[]
|
yield return new object[]
|
||||||
{
|
{
|
||||||
new VideoFileInfo()
|
new VideoFileInfo(
|
||||||
{
|
path: @"/server/Movies/300 (2007)/300 (2006).bluray.disc",
|
||||||
Path = @"/server/Movies/300 (2007)/300 (2006).bluray.disc",
|
container: "disc",
|
||||||
Container = "disc",
|
name: "300",
|
||||||
Name = "300",
|
year: 2006,
|
||||||
Year = 2006,
|
isStub: true,
|
||||||
IsStub = true,
|
stubType: "bluray")
|
||||||
StubType = "bluray",
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
yield return new object[]
|
yield return new object[]
|
||||||
{
|
{
|
||||||
new VideoFileInfo()
|
new VideoFileInfo(
|
||||||
{
|
path: @"/server/Movies/300 (2007)/300 (2006)-trailer.mkv",
|
||||||
Path = @"/server/Movies/300 (2007)/300 (2006)-trailer.mkv",
|
container: "mkv",
|
||||||
Container = "mkv",
|
name: "300",
|
||||||
Name = "300",
|
year: 2006,
|
||||||
Year = 2006,
|
extraType: ExtraType.Trailer)
|
||||||
ExtraType = ExtraType.Trailer,
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
yield return new object[]
|
yield return new object[]
|
||||||
{
|
{
|
||||||
new VideoFileInfo()
|
new VideoFileInfo(
|
||||||
{
|
path: @"/server/Movies/Brave (2007)/Brave (2006)-trailer.mkv",
|
||||||
Path = @"/server/Movies/Brave (2007)/Brave (2006)-trailer.mkv",
|
container: "mkv",
|
||||||
Container = "mkv",
|
name: "Brave",
|
||||||
Name = "Brave",
|
year: 2006,
|
||||||
Year = 2006,
|
extraType: ExtraType.Trailer)
|
||||||
ExtraType = ExtraType.Trailer,
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
yield return new object[]
|
yield return new object[]
|
||||||
{
|
{
|
||||||
new VideoFileInfo()
|
new VideoFileInfo(
|
||||||
{
|
path: @"/server/Movies/300 (2007)/300 (2006).mkv",
|
||||||
Path = @"/server/Movies/300 (2007)/300 (2006).mkv",
|
container: "mkv",
|
||||||
Container = "mkv",
|
name: "300",
|
||||||
Name = "300",
|
year: 2006)
|
||||||
Year = 2006
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
yield return new object[]
|
yield return new object[]
|
||||||
{
|
{
|
||||||
new VideoFileInfo()
|
new VideoFileInfo(
|
||||||
{
|
path: @"/server/Movies/Bad Boys (1995)/Bad Boys (1995).mkv",
|
||||||
Path = @"/server/Movies/Bad Boys (1995)/Bad Boys (1995).mkv",
|
container: "mkv",
|
||||||
Container = "mkv",
|
name: "Bad Boys",
|
||||||
Name = "Bad Boys",
|
year: 1995)
|
||||||
Year = 1995,
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
yield return new object[]
|
yield return new object[]
|
||||||
{
|
{
|
||||||
new VideoFileInfo()
|
new VideoFileInfo(
|
||||||
{
|
path: @"/server/Movies/Brave (2007)/Brave (2006).mkv",
|
||||||
Path = @"/server/Movies/Brave (2007)/Brave (2006).mkv",
|
container: "mkv",
|
||||||
Container = "mkv",
|
name: "Brave",
|
||||||
Name = "Brave",
|
year: 2006)
|
||||||
Year = 2006,
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,6 +165,34 @@ namespace Jellyfin.Naming.Tests.Video
|
||||||
Assert.Equal(result?.StubType, expectedResult.StubType);
|
Assert.Equal(result?.StubType, expectedResult.StubType);
|
||||||
Assert.Equal(result?.IsDirectory, expectedResult.IsDirectory);
|
Assert.Equal(result?.IsDirectory, expectedResult.IsDirectory);
|
||||||
Assert.Equal(result?.FileNameWithoutExtension, expectedResult.FileNameWithoutExtension);
|
Assert.Equal(result?.FileNameWithoutExtension, expectedResult.FileNameWithoutExtension);
|
||||||
|
Assert.Equal(result?.ToString(), expectedResult.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ResolveFile_EmptyPath()
|
||||||
|
{
|
||||||
|
var result = new VideoResolver(_namingOptions).ResolveFile(string.Empty);
|
||||||
|
|
||||||
|
Assert.Null(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ResolveDirectoryTest()
|
||||||
|
{
|
||||||
|
var paths = new[]
|
||||||
|
{
|
||||||
|
@"/Server/Iron Man",
|
||||||
|
@"Batman",
|
||||||
|
string.Empty
|
||||||
|
};
|
||||||
|
|
||||||
|
var resolver = new VideoResolver(_namingOptions);
|
||||||
|
var results = paths.Select(path => resolver.ResolveDirectory(path)).ToList();
|
||||||
|
|
||||||
|
Assert.Equal(3, results.Count);
|
||||||
|
Assert.NotNull(results[0]);
|
||||||
|
Assert.NotNull(results[1]);
|
||||||
|
Assert.Null(results[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user