Fixed: Chinese releases with season and absolute episode numbers

This commit is contained in:
Xavier Xiong 2023-01-09 07:57:21 +01:00 committed by GitHub
parent facf775a43
commit f742e1f174
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -41,6 +41,25 @@ namespace NzbDrone.Core.Test.ParserTests
result.FullSeason.Should().BeFalse();
}
[TestCase("[Lilith-Raws] / Anime-Series Title S04 - 12 [Baha][WEB-DL][1080p][AVC AAC][CHT][MP4]", "Anime-Series Title", "Lilith-Raws", 4, 12)]
[TestCase("[Lilith-Raws] / Anime-Series Title S02 - 01 [Baha][WEB-DL][1080p][AVC AAC][CHT][MP4]", "Anime-Series Title", "Lilith-Raws", 2, 1)]
[TestCase("[Lilith-Raws] / Anime-Series Title S02 - 01 [Baha][WEB-DL][1080p][AVC AAC][CHT][MP4]", "Anime-Series Title", "Lilith-Raws", 2, 1)]
[TestCase("[SweetSub&LoliHouse] / Anime-Series Title S2 - 07 [WebRip 1080p HEVC-10bit AAC][]", "Anime-Series Title", "SweetSub&LoliHouse", 2, 7)]
[TestCase("[LoliHouse] Love Live! / Anime-Series Title S2 - 10 [WebRip 1080p HEVC-10bit AAC][]", "Anime-Series Title", "LoliHouse", 2, 10)]
[TestCase("[澄空学园&雪飘工作室&LoliHouse] / Anime-Series Title S3 - 06 [WebRip 1080p HEVC-10bit AAC][]", "Anime-Series Title", "&&LoliHouse", 3, 6)]
public void should_parse_chinese_anime_season_episode_releases(string postTitle, string title, string subgroup, int seasonNumber, int episodeNumber)
{
postTitle = XmlCleaner.ReplaceUnicode(postTitle);
var result = Parser.Parser.ParseTitle(postTitle);
result.Should().NotBeNull();
result.ReleaseGroup.Should().Be(subgroup);
result.SeasonNumber.Should().Be(seasonNumber);
result.EpisodeNumbers.Single().Should().Be(episodeNumber);
result.SeriesTitle.Should().Be(title);
result.FullSeason.Should().BeFalse();
}
[TestCase("[喵萌奶茶屋&LoliHouse]/Anime Series Title - 03 [WebRip 1080p HEVC-10bit AAC][]", "Anime Series Title", "&LoliHouse", 3)]
[TestCase("[悠哈璃羽字幕社&拉斯观测组&LoliHouse] : Alicization / Anime Series: Title - 17 [WebRip 1080p HEVC-10bit AAC][]", "Anime Series: Title", "&&LoliHouse", 17)]
[TestCase("[ZERO字幕組]·Anime-Series Title[11][BIG5][1080p]", "Anime-Series Title", "ZERO字幕組", 11)]

View File

@ -25,6 +25,9 @@ namespace NzbDrone.Core.Parser
// Some Chinese anime releases contain both English and Chinese titles, remove the Chinese title and replace with normal anime pattern
new RegexReplace(@"^\[(?:(?<subgroup>[^\]]+?)(?:[\u4E00-\u9FCC]+)?)\]\[(?<title>[^\]]+?)(?:\s(?<chinesetitle>[\u4E00-\u9FCC][^\]]*?))\]\[(?:(?:[\u4E00-\u9FCC]+?)?(?<episode>\d{1,4})(?:[\u4E00-\u9FCC]+?)?)\]", "[${subgroup}] ${title} - ${episode} - ", RegexOptions.Compiled),
// Chinese LoliHouse/Lilith-Raws releases use Season + Absolute Episode Number, normalize using SxxExx format
new RegexReplace(@"^\[(?<subgroup>[^\]]*?(?:LoliHouse|ZERO|Lilith-Raws)[^\]]*?)\].*/(?<title>[^\[\]]+?)(?:S?(?<season>(?<!\d+)\d{1,2}(?!\d+)))(?: - (?<episode>[0-9-]+)\s*|\[第?(?<episode>[0-9]+(?:-[0-9]+)?)话?(?:END|完)?\])\[", "[${subgroup}] ${title} S${season}E${episode} [", RegexOptions.Compiled),
// Chinese LoliHouse/ZERO/Lilith-Raws releases don't use the expected brackets, normalize using brackets
new RegexReplace(@"^\[(?<subgroup>[^\]]*?(?:LoliHouse|ZERO|Lilith-Raws)[^\]]*?)\](?<title>[^\[\]]+?)(?: - (?<episode>[0-9-]+)\s*|\[第?(?<episode>[0-9]+(?:-[0-9]+)?)话?(?:END|完)?\])\[", "[${subgroup}][${title}][${episode}][", RegexOptions.Compiled),