Minor improvements
This commit is contained in:
parent
3b006cd674
commit
228b33a23b
|
@ -1,6 +1,6 @@
|
|||
#nullable enable
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
@ -19,12 +19,7 @@ namespace Emby.Naming.AudioBook
|
|||
|
||||
public AudioBookFilePathParserResult Parse(string path)
|
||||
{
|
||||
if (path == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(path));
|
||||
}
|
||||
|
||||
var result = new AudioBookFilePathParserResult();
|
||||
AudioBookFilePathParserResult result = default;
|
||||
var fileName = Path.GetFileNameWithoutExtension(path);
|
||||
foreach (var expression in _options.AudioBookPartsExpressions)
|
||||
{
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#nullable enable
|
||||
#pragma warning disable CS1591
|
||||
|
||||
namespace Emby.Naming.AudioBook
|
||||
{
|
||||
public class AudioBookFilePathParserResult
|
||||
public struct AudioBookFilePathParserResult
|
||||
{
|
||||
public int? PartNumber { get; set; }
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#nullable enable
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
|
@ -15,11 +16,6 @@ namespace MediaBrowser.Controller.Extensions
|
|||
{
|
||||
public static string RemoveDiacritics(this string text)
|
||||
{
|
||||
if (text == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(text));
|
||||
}
|
||||
|
||||
var chars = Normalize(text, NormalizationForm.FormD)
|
||||
.Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch) != UnicodeCategory.NonSpacingMark);
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#nullable enable
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
|
@ -9,7 +10,7 @@ namespace MediaBrowser.Controller.Library
|
|||
{
|
||||
public static class NameExtensions
|
||||
{
|
||||
private static string RemoveDiacritics(string name)
|
||||
private static string RemoveDiacritics(string? name)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
using Emby.Naming.AudioBook;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Naming.Tests.AudioBook
|
||||
{
|
||||
public class AudioBookFileInfoTests
|
||||
{
|
||||
[Fact]
|
||||
public void CompareTo_Same_Success()
|
||||
{
|
||||
var info = new AudioBookFileInfo();
|
||||
Assert.Equal(0, info.CompareTo(info));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CompareTo_Null_Success()
|
||||
{
|
||||
var info = new AudioBookFileInfo();
|
||||
Assert.Equal(1, info.CompareTo(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CompareTo_Empty_Success()
|
||||
{
|
||||
var info1 = new AudioBookFileInfo();
|
||||
var info2 = new AudioBookFileInfo();
|
||||
Assert.Equal(0, info1.CompareTo(info2));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -44,14 +44,14 @@ namespace Jellyfin.Naming.Tests.Video
|
|||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(ExtraType.BehindTheScenes, "behind the scenes" )]
|
||||
[InlineData(ExtraType.DeletedScene, "deleted scenes" )]
|
||||
[InlineData(ExtraType.Interview, "interviews" )]
|
||||
[InlineData(ExtraType.Scene, "scenes" )]
|
||||
[InlineData(ExtraType.Sample, "samples" )]
|
||||
[InlineData(ExtraType.Clip, "shorts" )]
|
||||
[InlineData(ExtraType.Clip, "featurettes" )]
|
||||
[InlineData(ExtraType.Unknown, "extras" )]
|
||||
[InlineData(ExtraType.BehindTheScenes, "behind the scenes")]
|
||||
[InlineData(ExtraType.DeletedScene, "deleted scenes")]
|
||||
[InlineData(ExtraType.Interview, "interviews")]
|
||||
[InlineData(ExtraType.Scene, "scenes")]
|
||||
[InlineData(ExtraType.Sample, "samples")]
|
||||
[InlineData(ExtraType.Clip, "shorts")]
|
||||
[InlineData(ExtraType.Clip, "featurettes")]
|
||||
[InlineData(ExtraType.Unknown, "extras")]
|
||||
public void TestDirectories(ExtraType type, string dirName)
|
||||
{
|
||||
Test(dirName + "/300.mp4", type, _videoOptions);
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace Jellyfin.Server.Implementations.Tests.Library
|
|||
[InlineData("Superman: Red Son [imdbid=tt10985510]", "imdbid", "tt10985510")]
|
||||
[InlineData("Superman: Red Son - tt10985510", "imdbid", "tt10985510")]
|
||||
[InlineData("Superman: Red Son", "imdbid", null)]
|
||||
[InlineData("Superman: Red Son", "something", null)]
|
||||
public void GetAttributeValue_ValidArgs_Correct(string input, string attribute, string? expectedResult)
|
||||
{
|
||||
Assert.Equal(expectedResult, PathExtensions.GetAttributeValue(input, attribute));
|
||||
|
|
Loading…
Reference in New Issue
Block a user