mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-29 20:08:27 +01:00
Merge pull request #1929 from Narfinger/parser-fix4
[Draft][Help wanted] Fix parsing of certain names and adds a default season if no season was found
(cherry picked from commit 61b9b4046a)
Signed-off-by: Joshua Boniface <joshua@boniface.me>
This commit is contained in:
54
tests/Jellyfin.Naming.Tests/EpisodePathParserTest.cs
Normal file
54
tests/Jellyfin.Naming.Tests/EpisodePathParserTest.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
namespace Emby.Naming.TV
|
||||
{
|
||||
using Emby.Naming.Common;
|
||||
using Xunit;
|
||||
|
||||
public class EpisodePathParserTest
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("/media/Foo/Foo-S01E01", "Foo", 1, 1)]
|
||||
[InlineData("/media/Foo - S04E011", "Foo", 4, 11)]
|
||||
[InlineData("/media/Foo/Foo s01x01", "Foo", 1, 1)]
|
||||
[InlineData("/media/Foo (2019)/Season 4/Foo (2019).S04E03", "Foo (2019)", 4, 3)]
|
||||
public void ParseEpisodesCorrectly(string path, string name, int season, int episode)
|
||||
{
|
||||
NamingOptions o = new NamingOptions();
|
||||
EpisodePathParser p = new EpisodePathParser(o);
|
||||
var res = p.Parse(path, false);
|
||||
|
||||
Assert.True(res.Success);
|
||||
Assert.Equal(name, res.SeriesName);
|
||||
Assert.Equal(season, res.SeasonNumber);
|
||||
Assert.Equal(episode, res.EpisodeNumber);
|
||||
|
||||
//testing other paths delimeter
|
||||
var res2 = p.Parse(path.Replace("/", "\\"), false);
|
||||
Assert.True(res2.Success);
|
||||
Assert.Equal(name, res2.SeriesName);
|
||||
Assert.Equal(season, res2.SeasonNumber);
|
||||
Assert.Equal(episode, res2.EpisodeNumber);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/media/Foo/Foo 889", "Foo", 889)]
|
||||
[InlineData("/media/Foo/[Bar] Foo Baz - 11 [1080p]", "Foo Baz", 11)]
|
||||
public void ParseEpisodeWithoutSeason(string path, string name, int episode)
|
||||
{
|
||||
NamingOptions o = new NamingOptions();
|
||||
EpisodePathParser p = new EpisodePathParser(o);
|
||||
var res = p.Parse(path, true, null, null, true);
|
||||
|
||||
Assert.True(res.Success);
|
||||
Assert.Equal(name, res.SeriesName);
|
||||
Assert.True(res.SeasonNumber == null);
|
||||
Assert.Equal(episode, res.EpisodeNumber);
|
||||
|
||||
//testing other paths delimeter
|
||||
var res2 = p.Parse(path.Replace("/", "\\"), false, null, null, true);
|
||||
Assert.True(res2.Success);
|
||||
Assert.Equal(name, res2.SeriesName);
|
||||
Assert.True(res2.SeasonNumber == null);
|
||||
Assert.Equal(episode, res2.EpisodeNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
20
tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj
Normal file
20
tests/Jellyfin.Naming.Tests/Jellyfin.Naming.Tests.csproj
Normal file
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.0" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
|
||||
<PackageReference Include="coverlet.collector" Version="1.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Emby.Naming\Emby.Naming.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user