From 21cb52c196723b9a5ad64b5e96c6b13ed9569421 Mon Sep 17 00:00:00 2001 From: kookxiang Date: Tue, 27 Aug 2024 01:25:35 +0800 Subject: [PATCH] optimize episode number detection --- Jellyfin.Plugin.Bangumi.Test/Episode.cs | 15 +++++++++++++++ .../Providers/EpisodeProvider.cs | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Jellyfin.Plugin.Bangumi.Test/Episode.cs b/Jellyfin.Plugin.Bangumi.Test/Episode.cs index e698026..d5b9531 100644 --- a/Jellyfin.Plugin.Bangumi.Test/Episode.cs +++ b/Jellyfin.Plugin.Bangumi.Test/Episode.cs @@ -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 + { + { + 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] diff --git a/Jellyfin.Plugin.Bangumi/Providers/EpisodeProvider.cs b/Jellyfin.Plugin.Bangumi/Providers/EpisodeProvider.cs index 05239b5..d73ea27 100644 --- a/Jellyfin.Plugin.Bangumi/Providers/EpisodeProvider.cs +++ b/Jellyfin.Plugin.Bangumi/Providers/EpisodeProvider.cs @@ -39,7 +39,8 @@ public class EpisodeProvider(BangumiApi api, ILogger 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]|$)");