Skip to content

Commit baf8f6c

Browse files
committed
Fixed: Parsing multi-episode in square bracket
Fixes Sonarr#2669
1 parent c67c7e1 commit baf8f6c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/NzbDrone.Core.Test/ParserTests/MultiEpisodeParserFixture.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public class MultiEpisodeParserFixture : CoreTest
6161
[TestCase("1x01-x03 - Episode Title.HDTV-720p", "", 1, new [] { 1, 2, 3 })]
6262
[TestCase("Are.You.Human.Too.E07-E08.180612.1080p-NEXT", "Are You Human Too", 1, new[] { 7, 8 })]
6363
[TestCase("Are You Human Too? E11-E12 1080p HDTV AAC H.264-NEXT", "Are You Human Too", 1, new[] { 11, 12 })]
64+
[TestCase("The Series Title (2010) - [S01E01-02-03] - Episode Title", "The Series Title (2010)", 1, new [] { 1, 2, 3 })]
6465
//[TestCase("", "", , new [] { })]
6566
public void should_parse_multiple_episodes(string postTitle, string title, int season, int[] episodes)
6667
{

src/NzbDrone.Core/Parser/Parser.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,12 @@ public static class Parser
134134
new Regex(@"(?:.*(?:\""|^))(?<title>.*?)(?:[-_\W](?<![()\[]))+(?:\W?Season\W?)(?<season>(?<!\d+)\d{1,2}(?!\d+))(?:\W|_)+(?:Episode\W)(?:[-_. ]?(?<episode>(?<!\d+)\d{1,2}(?!\d+)))+",
135135
RegexOptions.IgnoreCase | RegexOptions.Compiled),
136136

137+
// Multi-episode with episodes in square brackets (Series Title [S01E11E12] or Series Title [S01E11-12])
138+
new Regex(@"(?:.*(?:^))(?<title>.*?)[-._ ]+\[S(?<season>(?<!\d+)\d{2}(?!\d+))(?:[E-]{1,2}(?<episode>(?<!\d+)\d{2}(?!\d+)))+\]",
139+
RegexOptions.IgnoreCase | RegexOptions.Compiled),
140+
137141
//Multi-episode release with no space between series title and season (S01E11E12)
138-
new Regex(@"(?:.*(?:^))(?<title>.*?)(?:\W?|_)S(?<season>(?<!\d+)\d{2}(?!\d+))(?:E(?<episode>(?<!\d+)\d{2}(?!\d+)))+",
142+
new Regex(@"(?:.*(?:^))(?<title>.*?)S(?<season>(?<!\d+)\d{2}(?!\d+))(?:E(?<episode>(?<!\d+)\d{2}(?!\d+)))+",
139143
RegexOptions.IgnoreCase | RegexOptions.Compiled),
140144

141145
//Multi-episode with single episode numbers (S6.E1-E2, S6.E1E2, S6E1E2, etc)

0 commit comments

Comments
 (0)