Address comments

This commit is contained in:
Bond_009 2020-04-25 15:29:59 +02:00
parent 851dda097e
commit a273ed9a57
2 changed files with 151 additions and 156 deletions

View File

@ -93,7 +93,7 @@ namespace Emby.Naming.Video
year = cleanDateTimeResult.Year;
if (extraResult.ExtraType == null
&& TryCleanString(cleanDateTimeResult.Name, out ReadOnlySpan<char> newName))
&& TryCleanString(name, out ReadOnlySpan<char> newName))
{
name = newName.ToString();
}

View File

@ -1,5 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using System.Collections.Generic;
using Emby.Naming.Common;
using Emby.Naming.Video;
using MediaBrowser.Model.Entities;
@ -11,179 +10,175 @@ namespace Jellyfin.Naming.Tests.Video
{
private readonly NamingOptions _namingOptions = new NamingOptions();
private class ResolveFileTestData : IEnumerable<object[]>
public static IEnumerable<object[]> GetResolveFileTestData()
{
public IEnumerator<object[]> GetEnumerator()
yield return new object[]
{
yield return new object[]
new VideoFileInfo()
{
new VideoFileInfo()
{
Path = @"/server/Movies/7 Psychos.mkv/7 Psychos.mkv",
Container = "mkv",
Name = "7 Psychos"
}
};
yield return new object[]
Path = @"/server/Movies/7 Psychos.mkv/7 Psychos.mkv",
Container = "mkv",
Name = "7 Psychos"
}
};
yield return new object[]
{
new VideoFileInfo()
{
new VideoFileInfo()
{
Path = @"/server/Movies/3 days to kill (2005)/3 days to kill (2005).mkv",
Container = "mkv",
Name = "3 days to kill",
Year = 2005
}
};
yield return new object[]
Path = @"/server/Movies/3 days to kill (2005)/3 days to kill (2005).mkv",
Container = "mkv",
Name = "3 days to kill",
Year = 2005
}
};
yield return new object[]
{
new VideoFileInfo()
{
new VideoFileInfo()
{
Path = @"/server/Movies/American Psycho/American.Psycho.mkv",
Container = "mkv",
Name = "American.Psycho",
}
};
yield return new object[]
Path = @"/server/Movies/American Psycho/American.Psycho.mkv",
Container = "mkv",
Name = "American.Psycho",
}
};
yield return new object[]
{
new VideoFileInfo()
{
new VideoFileInfo()
{
Path = @"/server/Movies/brave (2007)/brave (2006).3d.sbs.mkv",
Container = "mkv",
Name = "brave",
Year = 2006,
Is3D = true,
Format3D = "sbs",
}
};
yield return new object[]
Path = @"/server/Movies/brave (2007)/brave (2006).3d.sbs.mkv",
Container = "mkv",
Name = "brave",
Year = 2006,
Is3D = true,
Format3D = "sbs",
}
};
yield return new object[]
{
new VideoFileInfo()
{
new VideoFileInfo()
{
Path = @"/server/Movies/300 (2007)/300 (2006).3d1.sbas.mkv",
Container = "mkv",
Name = "300",
Year = 2006
}
};
yield return new object[]
Path = @"/server/Movies/300 (2007)/300 (2006).3d1.sbas.mkv",
Container = "mkv",
Name = "300",
Year = 2006
}
};
yield return new object[]
{
new VideoFileInfo()
{
new VideoFileInfo()
{
Path = @"/server/Movies/300 (2007)/300 (2006).3d.sbs.mkv",
Container = "mkv",
Name = "300",
Year = 2006,
Is3D = true,
Format3D = "sbs",
}
};
yield return new object[]
Path = @"/server/Movies/300 (2007)/300 (2006).3d.sbs.mkv",
Container = "mkv",
Name = "300",
Year = 2006,
Is3D = true,
Format3D = "sbs",
}
};
yield return new object[]
{
new VideoFileInfo()
{
new VideoFileInfo()
{
Path = @"/server/Movies/brave (2007)/brave (2006)-trailer.bluray.disc",
Container = "disc",
Name = "brave",
Year = 2006,
IsStub = true,
StubType = "bluray",
}
};
yield return new object[]
Path = @"/server/Movies/brave (2007)/brave (2006)-trailer.bluray.disc",
Container = "disc",
Name = "brave",
Year = 2006,
IsStub = true,
StubType = "bluray",
}
};
yield return new object[]
{
new VideoFileInfo()
{
new VideoFileInfo()
{
Path = @"/server/Movies/300 (2007)/300 (2006)-trailer.bluray.disc",
Container = "disc",
Name = "300",
Year = 2006,
IsStub = true,
StubType = "bluray",
}
};
yield return new object[]
Path = @"/server/Movies/300 (2007)/300 (2006)-trailer.bluray.disc",
Container = "disc",
Name = "300",
Year = 2006,
IsStub = true,
StubType = "bluray",
}
};
yield return new object[]
{
new VideoFileInfo()
{
new VideoFileInfo()
{
Path = @"/server/Movies/Brave (2007)/Brave (2006).bluray.disc",
Container = "disc",
Name = "Brave",
Year = 2006,
IsStub = true,
StubType = "bluray",
}
};
yield return new object[]
Path = @"/server/Movies/Brave (2007)/Brave (2006).bluray.disc",
Container = "disc",
Name = "Brave",
Year = 2006,
IsStub = true,
StubType = "bluray",
}
};
yield return new object[]
{
new VideoFileInfo()
{
new VideoFileInfo()
{
Path = @"/server/Movies/300 (2007)/300 (2006).bluray.disc",
Container = "disc",
Name = "300",
Year = 2006,
IsStub = true,
StubType = "bluray",
}
};
yield return new object[]
Path = @"/server/Movies/300 (2007)/300 (2006).bluray.disc",
Container = "disc",
Name = "300",
Year = 2006,
IsStub = true,
StubType = "bluray",
}
};
yield return new object[]
{
new VideoFileInfo()
{
new VideoFileInfo()
{
Path = @"/server/Movies/300 (2007)/300 (2006)-trailer.mkv",
Container = "mkv",
Name = "300",
Year = 2006,
ExtraType = ExtraType.Trailer,
}
};
yield return new object[]
Path = @"/server/Movies/300 (2007)/300 (2006)-trailer.mkv",
Container = "mkv",
Name = "300",
Year = 2006,
ExtraType = ExtraType.Trailer,
}
};
yield return new object[]
{
new VideoFileInfo()
{
new VideoFileInfo()
{
Path = @"/server/Movies/Brave (2007)/Brave (2006)-trailer.mkv",
Container = "mkv",
Name = "Brave",
Year = 2006,
ExtraType = ExtraType.Trailer,
}
};
yield return new object[]
Path = @"/server/Movies/Brave (2007)/Brave (2006)-trailer.mkv",
Container = "mkv",
Name = "Brave",
Year = 2006,
ExtraType = ExtraType.Trailer,
}
};
yield return new object[]
{
new VideoFileInfo()
{
new VideoFileInfo()
{
Path = @"/server/Movies/300 (2007)/300 (2006).mkv",
Container = "mkv",
Name = "300",
Year = 2006
}
};
yield return new object[]
Path = @"/server/Movies/300 (2007)/300 (2006).mkv",
Container = "mkv",
Name = "300",
Year = 2006
}
};
yield return new object[]
{
new VideoFileInfo()
{
new VideoFileInfo()
{
Path = @"/server/Movies/Bad Boys (1995)/Bad Boys (1995).mkv",
Container = "mkv",
Name = "Bad Boys",
Year = 1995,
}
};
yield return new object[]
Path = @"/server/Movies/Bad Boys (1995)/Bad Boys (1995).mkv",
Container = "mkv",
Name = "Bad Boys",
Year = 1995,
}
};
yield return new object[]
{
new VideoFileInfo()
{
new VideoFileInfo()
{
Path = @"/server/Movies/Brave (2007)/Brave (2006).mkv",
Container = "mkv",
Name = "Brave",
Year = 2006,
}
};
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
Path = @"/server/Movies/Brave (2007)/Brave (2006).mkv",
Container = "mkv",
Name = "Brave",
Year = 2006,
}
};
}
[Theory]
[ClassData(typeof(ResolveFileTestData))]
[MemberData(nameof(GetResolveFileTestData))]
public void ResolveFile_ValidFileName_Success(VideoFileInfo expectedResult)
{
var result = new VideoResolver(_namingOptions).ResolveFile(expectedResult.Path);