From 0638ac8a5e440f92d6851a24e9de26dd64674bd3 Mon Sep 17 00:00:00 2001 From: Jason Dove Date: Thu, 9 Sep 2021 06:38:46 -0500 Subject: [PATCH] more missing metadata fixes (#354) * more missing metadata fixes * update mudblazor --- .../Scheduling/MultiPartEpisodeGrouper.cs | 47 ++++++++++--------- ErsatzTV/ErsatzTV.csproj | 2 +- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/ErsatzTV.Core/Scheduling/MultiPartEpisodeGrouper.cs b/ErsatzTV.Core/Scheduling/MultiPartEpisodeGrouper.cs index b75a29de1..e5fa29841 100644 --- a/ErsatzTV.Core/Scheduling/MultiPartEpisodeGrouper.cs +++ b/ErsatzTV.Core/Scheduling/MultiPartEpisodeGrouper.cs @@ -121,32 +121,35 @@ namespace ErsatzTV.Core.Scheduling private static Option FindPartNumber(Episode e) { - const string PATTERN = @"^.*\((\d+)\)( - .*)?$"; - Match match = Regex.Match(e.EpisodeMetadata.Head().Title, PATTERN); - if (match.Success && int.TryParse(match.Groups[1].Value, out int value1)) + foreach (EpisodeMetadata metadata in e.EpisodeMetadata.HeadOrNone()) { - return value1; - } + const string PATTERN = @"^.*\((\d+)\)( - .*)?$"; + Match match = Regex.Match(metadata.Title ?? string.Empty, PATTERN); + if (match.Success && int.TryParse(match.Groups[1].Value, out int value1)) + { + return value1; + } - const string PATTERN_2 = @"^.*\(?Part (\d+)\)?$"; - Match match2 = Regex.Match(e.EpisodeMetadata.Head().Title, PATTERN_2); - if (match2.Success && int.TryParse(match2.Groups[1].Value, out int value2)) - { - return value2; - } + const string PATTERN_2 = @"^.*\(?Part (\d+)\)?$"; + Match match2 = Regex.Match(metadata.Title ?? string.Empty, PATTERN_2); + if (match2.Success && int.TryParse(match2.Groups[1].Value, out int value2)) + { + return value2; + } - const string PATTERN_3 = @"^.*\(([MDCLXVI]+)\)( - .*)?$"; - Match match3 = Regex.Match(e.EpisodeMetadata.Head().Title, PATTERN_3); - if (match3.Success && TryParseRoman(match3.Groups[1].Value, out int value3)) - { - return value3; - } + const string PATTERN_3 = @"^.*\(([MDCLXVI]+)\)( - .*)?$"; + Match match3 = Regex.Match(metadata.Title ?? string.Empty, PATTERN_3); + if (match3.Success && TryParseRoman(match3.Groups[1].Value, out int value3)) + { + return value3; + } - const string PATTERN_4 = @"^.*Part (\w+)$"; - Match match4 = Regex.Match(e.EpisodeMetadata.Head().Title, PATTERN_4); - if (match4.Success && TryParseEnglish(match4.Groups[1].Value, out int value4)) - { - return value4; + const string PATTERN_4 = @"^.*Part (\w+)$"; + Match match4 = Regex.Match(metadata.Title ?? string.Empty, PATTERN_4); + if (match4.Success && TryParseEnglish(match4.Groups[1].Value, out int value4)) + { + return value4; + } } return None; diff --git a/ErsatzTV/ErsatzTV.csproj b/ErsatzTV/ErsatzTV.csproj index 0ec44b4ff..6818c2c72 100644 --- a/ErsatzTV/ErsatzTV.csproj +++ b/ErsatzTV/ErsatzTV.csproj @@ -34,7 +34,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - +