Skip to content

Commit

Permalink
optimize episode number detection
Browse files Browse the repository at this point in the history
  • Loading branch information
kookxiang committed Aug 26, 2024
1 parent 5147c02 commit 21cb52c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Jellyfin.Plugin.Bangumi.Test/Episode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,21 @@ public async Task FixEpisodeIndexWithNumberInName()
Assert.IsNotNull(episodeData, "episode data should not be null");
Assert.IsNotNull(episodeData.Item, "episode data should not be null");
Assert.AreEqual(22, episodeData.Item.IndexNumber, "should fix episode index automatically");

episodeData = await _provider.GetMetadata(new EpisodeInfo
{
IndexNumber = 0,
Path = FakePath.CreateFile("Detective Conan/[SBSUB][CONAN][5][WEBRIP][1080P][HEVC_AAC][CHS_CHT_JP](951D8C84).mkv"),
SeriesProviderIds = new Dictionary<string, string>
{
{
Constants.ProviderName, "899"
}
}
}, _token);
Assert.IsNotNull(episodeData, "episode data should not be null");
Assert.IsNotNull(episodeData.Item, "episode data should not be null");
Assert.AreEqual(5, episodeData.Item.IndexNumber, "should fix episode index automatically");
}

[TestMethod]
Expand Down
3 changes: 2 additions & 1 deletion Jellyfin.Plugin.Bangumi/Providers/EpisodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public class EpisodeProvider(BangumiApi api, ILogger<EpisodeProvider> log, ILibr
new(@"EP?([\d\.]{2,})", RegexOptions.IgnoreCase),
new(@"\[([\d\.]{2,})"),
new(@"#([\d\.]{2,})"),
new(@"(\d{2,})")
new(@"(\d{2,})"),
new(@"\[([\d\.]+)\]")
};

private static readonly Regex OpeningEpisodeFileNameRegex = new(@"(NC)?OP([^a-zA-Z]|$)");
Expand Down

0 comments on commit 21cb52c

Please sign in to comment.