From 2b8ab92ef7727a56a21740e12c9333fca1c101aa Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 21 Sep 2017 18:28:44 -0700 Subject: [PATCH] Fixed: Parse and reject season extras Fixes #2176 --- .../ParserTests/SeasonParserFixture.cs | 20 ++++++++++++------- .../EpisodeImport/ImportDecisionMaker.cs | 6 +++++- .../Parser/Model/ParsedEpisodeInfo.cs | 3 ++- src/NzbDrone.Core/Parser/Parser.cs | 11 ++++++---- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/NzbDrone.Core.Test/ParserTests/SeasonParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/SeasonParserFixture.cs index 8d7ba558e..43fc8cc37 100644 --- a/src/NzbDrone.Core.Test/ParserTests/SeasonParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/SeasonParserFixture.cs @@ -1,4 +1,4 @@ -using FluentAssertions; +using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.Test.Framework; @@ -34,14 +34,20 @@ namespace NzbDrone.Core.Test.ParserTests result.FullSeason.Should().BeTrue(); } - [TestCase("Acropolis Now S05 EXTRAS DVDRip XviD RUNNER")] - [TestCase("Punky Brewster S01 EXTRAS DVDRip XviD RUNNER")] - [TestCase("Instant Star S03 EXTRAS DVDRip XviD OSiTV")] - public void should_parse_season_extras(string postTitle) + [TestCase("Acropolis Now S05 EXTRAS DVDRip XviD RUNNER", "Acropolis Now", 5)] + [TestCase("Punky Brewster S01 EXTRAS DVDRip XviD RUNNER", "Punky Brewster", 1)] + [TestCase("Instant Star S03 EXTRAS DVDRip XviD OSiTV", "Instant Star", 3)] + [TestCase("The.Flash.S03.Extras.01.Deleted.Scenes.720p", "The Flash", 3)] + [TestCase("The.Flash.S03.Extras.02.720p", "The Flash", 3)] + public void should_parse_season_extras(string postTitle, string title, int season) { var result = Parser.Parser.ParseTitle(postTitle); - - result.Should().BeNull(); + result.SeasonNumber.Should().Be(season); + result.SeriesTitle.Should().Be(title); + result.EpisodeNumbers.Should().BeEmpty(); + result.AbsoluteEpisodeNumbers.Should().BeEmpty(); + result.FullSeason.Should().BeTrue(); + result.IsSeasonExtra.Should().BeTrue(); } [TestCase("Lie.to.Me.S03.SUBPACK.DVDRip.XviD-REWARD")] diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs index 8a131841a..642384275 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -98,6 +98,10 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport { decision = new ImportDecision(localEpisode, new Rejection("Partial season packs are not supported")); } + else if (localEpisode.ParsedEpisodeInfo.IsSeasonExtra) + { + decision = new ImportDecision(localEpisode, new Rejection("Extras are not supported")); + } else { decision = new ImportDecision(localEpisode, new Rejection("Invalid season or episode")); diff --git a/src/NzbDrone.Core/Parser/Model/ParsedEpisodeInfo.cs b/src/NzbDrone.Core/Parser/Model/ParsedEpisodeInfo.cs index 35bc49d7d..73a9dfbaf 100644 --- a/src/NzbDrone.Core/Parser/Model/ParsedEpisodeInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/ParsedEpisodeInfo.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using NzbDrone.Common.Extensions; using NzbDrone.Core.Qualities; @@ -17,6 +17,7 @@ namespace NzbDrone.Core.Parser.Model public Language Language { get; set; } public bool FullSeason { get; set; } public bool IsPartialSeason { get; set; } + public bool IsSeasonExtra { get; set; } public bool Special { get; set; } public string ReleaseGroup { get; set; } public string ReleaseHash { get; set; } diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index 0cd5fb6d1..8c21c5e90 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -602,9 +602,12 @@ namespace NzbDrone.Core.Parser if (!episodeCaptures.Any() && !absoluteEpisodeCaptures.Any()) { - //Check to see if this is an "Extras" or "SUBPACK" release, if it is, return NULL - //Todo: Set a "Extras" flag in EpisodeParseResult if we want to download them ever - if (!matchCollection[0].Groups["extras"].Value.IsNullOrWhiteSpace()) return null; + //Check to see if this is an "Extras" or "SUBPACK" release, if it is, set + // IsSeasonExtra so they can be filtered out + if (!matchCollection[0].Groups["extras"].Value.IsNullOrWhiteSpace()) + { + result.IsSeasonExtra = true; + } // Partial season packs will have a seasonpart group so they can be differentiated // from a full season/single episode release