New: Parse some additional Chinese anime releases

Closes #5024
This commit is contained in:
Mark McDowall 2022-05-15 15:13:56 -07:00
parent a81a80a00f
commit 6a7d84f134
2 changed files with 5 additions and 2 deletions

View File

@ -26,6 +26,7 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("[星空字幕组] / Anime Series Title [05][1080p][]", "Anime Series Title", "", 5)]
[TestCase("【DHR动研字幕组】[多田君不恋爱_Anime Series Title][13][][720P][MP4]", "Anime Series Title", "DHR动研字幕组", 13)]
[TestCase("【动漫国字幕组】★01月新番[Anime Series Title][01][1080P][][MP4]", "Anime Series Title", "", 1)]
[TestCase("[OPFans楓雪動漫][ONE PIECE ][1008][][1080P][MKV][]", "ONE PIECE", "OPFans", 1008)]
public void should_parse_chinese_anime_releases(string postTitle, string title, string subgroup, int absoluteEpisodeNumber)
{
postTitle = XmlCleaner.ReplaceUnicode(postTitle);

View File

@ -9,7 +9,6 @@ using NzbDrone.Common.Extensions;
using NzbDrone.Common.Instrumentation;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Languages;
using System.Text;
namespace NzbDrone.Core.Parser
@ -30,7 +29,10 @@ namespace NzbDrone.Core.Parser
new RegexReplace(@"^\[(?<subgroup>[^\]]+)\](?:\s?★[^\[ -]+\s?)?\[?(?:(?<chinesetitle>[^\]]*?[\u4E00-\u9FCC][^\]]*?)(?:\]\[|\s*[_/·]\s*))?(?<title>[^\]]+?)\]?(?:\[\d{4}\])?\[第?(?<episode>[0-9]+(?:-[0-9]+)?)话?(?:END|完)?\]", "[${subgroup}] ${title} - ${episode} ", RegexOptions.Compiled),
// Some Chinese anime releases contain both Chinese and English titles, remove the Chinese title and replace with normal anime pattern
new RegexReplace(@"^\[(?<subgroup>[^\]]+)\](?:\s)(?:(?<chinesetitle>[^\]]*?[\u4E00-\u9FCC][^\]]*?)(?:\s/\s))(?<title>[^\]]+?)(?:[- ]+)(?<episode>[0-9]+(?:-[0-9]+)?)话?(?:END|完)?", "[${subgroup}] ${title} - ${episode} ", RegexOptions.Compiled)
new RegexReplace(@"^\[(?<subgroup>[^\]]+)\](?:\s)(?:(?<chinesetitle>[^\]]*?[\u4E00-\u9FCC][^\]]*?)(?:\s/\s))(?<title>[^\]]+?)(?:[- ]+)(?<episode>[0-9]+(?:-[0-9]+)?)话?(?:END|完)?", "[${subgroup}] ${title} - ${episode} ", RegexOptions.Compiled),
// 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)
};
private static readonly Regex[] ReportTitleRegex = new[]