From 51de8f16fb404f5adece0f9447cfc44dd13cc7ae Mon Sep 17 00:00:00 2001 From: Gabriel Patzleiner Date: Wed, 8 Apr 2020 18:54:05 +0200 Subject: [PATCH] New: Removed the whole lenient parsing and lenient mapping functionality --- .../Config/IndexerConfigResource.cs | 2 - src/NzbDrone.Core.Test/Framework/CoreTest.cs | 2 +- .../ParserTests/ParserFixture.cs | 43 ++++----------- .../ParsingServiceTests/GetMovieFixture.cs | 2 +- .../Configuration/ConfigService.cs | 6 --- .../Configuration/IConfigService.cs | 1 - .../Migration/117_update_movie_file.cs | 2 +- .../DecisionEngine/DownloadDecisionMaker.cs | 9 +--- .../DownloadDecisionPriorizationService.cs | 4 +- .../Consumers/Roksbox/RoksboxMetadata.cs | 2 +- .../Metadata/Consumers/Wdtv/WdtvMetadata.cs | 2 +- .../Metadata/Consumers/Xbmc/XbmcMetadata.cs | 2 +- .../DownloadedMovieImportService.cs | 2 +- .../MovieImport/ImportApprovedMovie.cs | 2 +- .../MovieImport/ImportDecisionMaker.cs | 4 +- .../MovieImport/Manual/ManualImportService.cs | 8 +-- .../MetadataSource/SkyHook/SkyHookProxy.cs | 2 +- .../NetImport/RSSImport/RSSImportParser.cs | 2 +- .../Organizer/FileNameValidationService.cs | 2 +- src/NzbDrone.Core/Parser/Parser.cs | 30 +++-------- src/NzbDrone.Core/Parser/ParsingLeniency.cs | 9 ---- src/NzbDrone.Core/Parser/ParsingService.cs | 53 ++----------------- src/NzbDrone.Core/Parser/SceneChecker.cs | 2 +- .../Config/IndexerConfigResource.cs | 2 - 24 files changed, 44 insertions(+), 151 deletions(-) delete mode 100644 src/NzbDrone.Core/Parser/ParsingLeniency.cs diff --git a/src/NzbDrone.Api/Config/IndexerConfigResource.cs b/src/NzbDrone.Api/Config/IndexerConfigResource.cs index 80d9f4758..c0db97dcc 100644 --- a/src/NzbDrone.Api/Config/IndexerConfigResource.cs +++ b/src/NzbDrone.Api/Config/IndexerConfigResource.cs @@ -14,7 +14,6 @@ public class IndexerConfigResource : RestResource public int AvailabilityDelay { get; set; } public bool AllowHardcodedSubs { get; set; } public string WhitelistedHardcodedSubs { get; set; } - public ParsingLeniencyType ParsingLeniency { get; set; } } public static class IndexerConfigResourceMapper @@ -31,7 +30,6 @@ public static IndexerConfigResource ToResource(IConfigService model) AvailabilityDelay = model.AvailabilityDelay, AllowHardcodedSubs = model.AllowHardcodedSubs, WhitelistedHardcodedSubs = model.WhitelistedHardcodedSubs, - ParsingLeniency = model.ParsingLeniency, }; } } diff --git a/src/NzbDrone.Core.Test/Framework/CoreTest.cs b/src/NzbDrone.Core.Test/Framework/CoreTest.cs index ab3cb795f..1036090a4 100644 --- a/src/NzbDrone.Core.Test/Framework/CoreTest.cs +++ b/src/NzbDrone.Core.Test/Framework/CoreTest.cs @@ -42,7 +42,7 @@ protected void ParseMovieTitle() Mocker.GetMock().Setup(c => c.ParseMovieInfo(It.IsAny(), It.IsAny>())) .Returns>((title, helpers) => { - var result = Parser.Parser.ParseMovieTitle(title, false); + var result = Parser.Parser.ParseMovieTitle(title); if (result != null) { result.Quality = QualityParser.ParseQuality(title); diff --git a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs index 63412c938..48968d054 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ParserFixture.cs @@ -64,7 +64,7 @@ public void should_remove_accents_from_title() [TestCase("www.Torrenting.org - Revenge.2008.720p.X264-DIMENSION", "Revenge")] public void should_parse_movie_title(string postTitle, string title) { - Parser.Parser.ParseMovieTitle(postTitle, true).MovieTitle.Should().Be(title); + Parser.Parser.ParseMovieTitle(postTitle).MovieTitle.Should().Be(title); } [TestCase("Avatar.Aufbruch.nach.Pandora.Extended.2009.German.DTS.720p.BluRay.x264-SoW", "Avatar Aufbruch nach Pandora", "Extended", 2009)] @@ -80,43 +80,22 @@ public void should_parse_movie_title(string postTitle, string title) [TestCase("Life.Partners.2014.German.DL.PAL.DVDR-ETM", "Life Partners", "", 2014)] [TestCase("Joe.Dreck.2.EXTENDED.EDITION.2015.German.DL.PAL.DVDR-ETM", "Joe Dreck 2", "EXTENDED EDITION", 2015)] [TestCase("Rango.EXTENDED.2011.HDRip.AC3.German.XviD-POE", "Rango", "EXTENDED", 2011)] - [TestCase("Suicide.Squad.2016.EXTENDED.German.DL.AC3.BDRip.x264-hqc", "Suicide Squad", "EXTENDED", 2016)] //edition after year - public void should_parse_german_movie(string postTitle, string title, string edition, int year) - { - ParsedMovieInfo movie = Parser.Parser.ParseMovieTitle(postTitle, false); - using (new AssertionScope()) - { - movie.MovieTitle.Should().Be(title); - movie.Edition.Should().Be(edition); - movie.Year.Should().Be(year); - } - } - [TestCase("Avatar.Aufbruch.nach.Pandora.Extended.2009.German.DTS.720p.BluRay.x264-SoW", "Avatar Aufbruch nach Pandora", "Extended", 2009)] - [TestCase("Drop.Zone.1994.German.AC3D.DL.720p.BluRay.x264-KLASSiGERHD", "Drop Zone", "", 1994)] - [TestCase("Kick.Ass.2.2013.German.DTS.DL.720p.BluRay.x264-Pate", "Kick Ass 2", "", 2013)] - [TestCase("Paradise.Hills.2019.German.DL.AC3.Dubbed.1080p.BluRay.x264-muhHD", "Paradise Hills", "", 2019)] - [TestCase("96.Hours.Taken.3.EXTENDED.2014.German.DL.1080p.BluRay.x264-ENCOUNTERS", "96 Hours Taken 3", "EXTENDED", 2014)] - [TestCase("World.War.Z.EXTENDED.CUT.2013.German.DL.1080p.BluRay.x264-HQX", "World War Z", "EXTENDED CUT", 2013)] - [TestCase("Sin.City.2005.RECUT.EXTENDED.German.DL.1080p.BluRay.x264-DETAiLS", "Sin City", "RECUT EXTENDED", 2005)] - [TestCase("Die.Klasse.von.1999.1990.German.720p.HDTV.x264-NORETAiL", "Die Klasse von 1999", "", 1990)] //year in the title - [TestCase("2.Tage.in.L.A.1996.GERMAN.DL.720p.WEB.H264-SOV", "2 Tage in L.A.", "", 1996)] - [TestCase("8.2019.GERMAN.720p.BluRay.x264-UNiVERSUM", "8", "", 2019)] - [TestCase("Life.Partners.2014.German.DL.PAL.DVDR-ETM", "Life Partners", "", 2014)] - [TestCase("Joe.Dreck.2.EXTENDED.EDITION.2015.German.DL.PAL.DVDR-ETM", "Joe Dreck 2", "EXTENDED EDITION", 2015)] - [TestCase("Rango.EXTENDED.2011.HDRip.AC3.German.XviD-POE", "Rango", "EXTENDED", 2011)] + //Special cases (see comment to the right) [TestCase("Suicide.Squad.2016.EXTENDED.German.DL.AC3.BDRip.x264-hqc", "Suicide Squad", "EXTENDED", 2016)] //edition after year - + [TestCase("Knight.and.Day.2010.Extended.Cut.German.DTS.DL.720p.BluRay.x264-HDS", "Knight and Day", "Extended Cut", 2010)] //edition after year + [TestCase("Der.Soldat.James.German.Bluray.FuckYou.Pso.Why.cant.you.follow.scene.rules.1998", "Der Soldat James", "", 1998)] //year at the end [TestCase("Der.Hobbit.Eine.Unerwartete.Reise.Extended.German.720p.BluRay.x264-EXQUiSiTE", "Der Hobbit Eine Unerwartete Reise", "Extended", 0)] //no year + [TestCase("Wolverine.Weg.des.Kriegers.EXTENDED.German.720p.BluRay.x264-EXQUiSiTE", "Wolverine Weg des Kriegers", "EXTENDED", 0)] //no year [TestCase("Die.Unfassbaren.Now.You.See.Me.EXTENDED.German.DTS.720p.BluRay.x264-RHD", "Die Unfassbaren Now You See Me", "EXTENDED", 0)] //no year - [TestCase("Der.Soldat.James.German.Bluray.FuckYou.Pso.Why.cant.you.follow.scene.rules.1998", "Der Soldat James", "", 1998)] + [TestCase("Die Unfassbaren Now You See Me EXTENDED German DTS 720p BluRay x264-RHD", "Die Unfassbaren Now You See Me", "EXTENDED", 0)] //no year & without dots [TestCase("Passengers.German.DL.AC3.Dubbed..BluRay.x264-PsO", "Passengers", "", 0)] //no year [TestCase("Das.A.Team.Der.Film.Extended.Cut.German.720p.BluRay.x264-ANCIENT", "Das A Team Der Film", "Extended Cut", 0)] //no year [TestCase("Cars.2.German.DL.720p.BluRay.x264-EmpireHD", "Cars 2", "", 0)] //no year [TestCase("Der.Film.deines.Lebens.German.2011.PAL.DVDR-ETM", "Der Film deines Lebens", "", 2011)] //year at wrong position - public void should_parse_german_movie_lenient(string postTitle, string title, string edition, int year) + public void should_parse_german_movie(string postTitle, string title, string edition, int year) { - ParsedMovieInfo movie = Parser.Parser.ParseMovieTitle(postTitle, true); + ParsedMovieInfo movie = Parser.Parser.ParseMovieTitle(postTitle); using (new AssertionScope()) { movie.MovieTitle.Should().Be(title); @@ -128,7 +107,7 @@ public void should_parse_german_movie_lenient(string postTitle, string title, st [TestCase("(1995) Ghost in the Shell", "Ghost in the Shell")] public void should_parse_movie_folder_name(string postTitle, string title) { - Parser.Parser.ParseMovieTitle(postTitle, true, true).MovieTitle.Should().Be(title); + Parser.Parser.ParseMovieTitle(postTitle, true).MovieTitle.Should().Be(title); } [TestCase("1941.1979.EXTENDED.720p.BluRay.X264-AMIABLE", 1979)] @@ -137,7 +116,7 @@ public void should_parse_movie_folder_name(string postTitle, string title) [TestCase("Leaving Jeruselem by Railway (1897) [DVD].mp4", 1897)] public void should_parse_movie_year(string postTitle, int year) { - Parser.Parser.ParseMovieTitle(postTitle, false).Year.Should().Be(year); + Parser.Parser.ParseMovieTitle(postTitle).Year.Should().Be(year); } [TestCase("Prometheus 2012 Directors Cut", "Directors Cut")] @@ -180,7 +159,7 @@ public void should_parse_movie_year(string postTitle, int year) [TestCase("Loving.Pablo.2018.TS.FRENCH.MD.x264-DROGUERiE", "")] public void should_parse_edition(string postTitle, string edition) { - var parsed = Parser.Parser.ParseMovieTitle(postTitle, true); + var parsed = Parser.Parser.ParseMovieTitle(postTitle); parsed.Edition.Should().Be(edition); } diff --git a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetMovieFixture.cs b/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetMovieFixture.cs index 6dac2f9d9..6ccbd53b5 100644 --- a/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetMovieFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/ParsingServiceTests/GetMovieFixture.cs @@ -28,7 +28,7 @@ public void should_use_parsed_series_title() Subject.GetMovie(title); Mocker.GetMock() - .Verify(s => s.FindByTitle(Parser.Parser.ParseMovieTitle(title, false, false).MovieTitle), Times.Once()); + .Verify(s => s.FindByTitle(Parser.Parser.ParseMovieTitle(title, false).MovieTitle), Times.Once()); } /*[Test] diff --git a/src/NzbDrone.Core/Configuration/ConfigService.cs b/src/NzbDrone.Core/Configuration/ConfigService.cs index 4f5438869..deaa0f494 100644 --- a/src/NzbDrone.Core/Configuration/ConfigService.cs +++ b/src/NzbDrone.Core/Configuration/ConfigService.cs @@ -190,12 +190,6 @@ public string WhitelistedHardcodedSubs set { SetValue("WhitelistedHardcodedSubs", value); } } - public ParsingLeniencyType ParsingLeniency - { - get { return GetValueEnum("ParsingLeniency", ParsingLeniencyType.Strict); } - set { SetValue("ParsingLeniency", value); } - } - public bool RemoveCompletedDownloads { get { return GetValueBoolean("RemoveCompletedDownloads", false); } diff --git a/src/NzbDrone.Core/Configuration/IConfigService.cs b/src/NzbDrone.Core/Configuration/IConfigService.cs index 3404c26b2..db1e6f502 100644 --- a/src/NzbDrone.Core/Configuration/IConfigService.cs +++ b/src/NzbDrone.Core/Configuration/IConfigService.cs @@ -61,7 +61,6 @@ public interface IConfigService bool AllowHardcodedSubs { get; set; } string WhitelistedHardcodedSubs { get; set; } - ParsingLeniencyType ParsingLeniency { get; set; } int NetImportSyncInterval { get; set; } string ListSyncLevel { get; set; } diff --git a/src/NzbDrone.Core/Datastore/Migration/117_update_movie_file.cs b/src/NzbDrone.Core/Datastore/Migration/117_update_movie_file.cs index 6e157b9bc..f28ef6f29 100644 --- a/src/NzbDrone.Core/Datastore/Migration/117_update_movie_file.cs +++ b/src/NzbDrone.Core/Datastore/Migration/117_update_movie_file.cs @@ -27,7 +27,7 @@ private void SetSortTitles(IDbConnection conn, IDbTransaction tran) var id = seriesReader.GetInt32(0); var relativePath = seriesReader.GetString(1); - var result = Parser.Parser.ParseMovieTitle(relativePath, false); + var result = Parser.Parser.ParseMovieTitle(relativePath); var edition = ""; diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs index 1e401883b..89214ba1c 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs @@ -89,12 +89,7 @@ private IEnumerable GetDecisions(List reports, Se Quality = new QualityModel(), }; - if (_configService.ParsingLeniency == ParsingLeniencyType.MappingLenient) - { - result = _parsingService.Map(parsedMovieInfo, report.ImdbId.ToString(), searchCriteria); - } - - if (result == null || result.MappingResultType != MappingResultType.SuccessLenientMapping) + if (result == null) { result = new MappingResult { MappingResultType = MappingResultType.NotParsable }; result.Movie = null; //To ensure we have a remote movie, else null exception on next line! @@ -113,7 +108,7 @@ private IEnumerable GetDecisions(List reports, Se remoteMovie.Release = report; remoteMovie.MappingResult = result.MappingResultType; - if (result.MappingResultType != MappingResultType.Success && result.MappingResultType != MappingResultType.SuccessLenientMapping) + if (result.MappingResultType != MappingResultType.Success) { var rejection = result.ToRejection(); decision = new DownloadDecision(remoteMovie, rejection); diff --git a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs index e84e20f51..7ca42a7a5 100644 --- a/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs +++ b/src/NzbDrone.Core/DecisionEngine/DownloadDecisionPriorizationService.cs @@ -27,13 +27,13 @@ public DownloadDecisionPriorizationService(IConfigService configService, IDelayP public List PrioritizeDecisionsForMovies(List decisions) { - return decisions.Where(c => c.RemoteMovie.MappingResult == MappingResultType.Success || c.RemoteMovie.MappingResult == MappingResultType.SuccessLenientMapping) + return decisions.Where(c => c.RemoteMovie.MappingResult == MappingResultType.Success) .GroupBy(c => c.RemoteMovie.Movie.Id, (movieId, downloadDecisions) => { return downloadDecisions.OrderByDescending(decision => decision, new DownloadDecisionComparer(_configService, _delayProfileService, _qualityDefinitionService)); }) .SelectMany(c => c) - .Union(decisions.Where(c => c.RemoteMovie.MappingResult != MappingResultType.Success || c.RemoteMovie.MappingResult != MappingResultType.SuccessLenientMapping)) + .Union(decisions.Where(c => c.RemoteMovie.MappingResult != MappingResultType.Success)) .ToList(); } } diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadata.cs index af8d9ef65..a708161b6 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadata.cs @@ -70,7 +70,7 @@ public override MetadataFile FindMetadataFile(Movie movie, string path) RelativePath = movie.Path.GetRelativePath(path) }; - var parseResult = Parser.Parser.ParseMovieTitle(filename, false); + var parseResult = Parser.Parser.ParseMovieTitle(filename); if (parseResult != null) { diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadata.cs index b1b2c5a42..2bb1a92ac 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadata.cs @@ -72,7 +72,7 @@ public override MetadataFile FindMetadataFile(Movie movie, string path) return metadata; } - var parseResult = Parser.Parser.ParseMovieTitle(filename, false); + var parseResult = Parser.Parser.ParseMovieTitle(filename); if (parseResult != null) { diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs index 66450b035..bc8460020 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs @@ -93,7 +93,7 @@ public override MetadataFile FindMetadataFile(Movie movie, string path) return metadata; } - var parseResult = Parser.Parser.ParseMovieTitle(filename, false); + var parseResult = Parser.Parser.ParseMovieTitle(filename); if (parseResult != null && Path.GetExtension(filename).Equals(".nfo", StringComparison.OrdinalIgnoreCase) && diff --git a/src/NzbDrone.Core/MediaFiles/DownloadedMovieImportService.cs b/src/NzbDrone.Core/MediaFiles/DownloadedMovieImportService.cs index 64baf15ee..2a3947728 100644 --- a/src/NzbDrone.Core/MediaFiles/DownloadedMovieImportService.cs +++ b/src/NzbDrone.Core/MediaFiles/DownloadedMovieImportService.cs @@ -123,7 +123,7 @@ public bool ShouldDeleteFolder(DirectoryInfo directoryInfo, Movie movie) foreach (var videoFile in videoFiles) { var movieParseResult = - Parser.Parser.ParseMovieTitle(Path.GetFileName(videoFile), _config.ParsingLeniency > 0); + Parser.Parser.ParseMovieTitle(Path.GetFileName(videoFile)); if (movieParseResult == null) { diff --git a/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs index cca006ab3..ac1144ebc 100644 --- a/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs @@ -214,7 +214,7 @@ private string GetSceneName(DownloadClientItem downloadClientItem, LocalMovie lo { var title = Parser.Parser.RemoveFileExtension(downloadClientItem.Title); - var parsedTitle = Parser.Parser.ParseMovieTitle(title, false); + var parsedTitle = Parser.Parser.ParseMovieTitle(title); if (parsedTitle != null) { diff --git a/src/NzbDrone.Core/MediaFiles/MovieImport/ImportDecisionMaker.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportDecisionMaker.cs index b3606293a..b252dccc6 100644 --- a/src/NzbDrone.Core/MediaFiles/MovieImport/ImportDecisionMaker.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportDecisionMaker.cs @@ -67,7 +67,7 @@ public List GetImportDecisions(List videoFiles, Movie mo if (downloadClientItem != null) { - downloadClientItemInfo = Parser.Parser.ParseMovieTitle(downloadClientItem.Title, false); + downloadClientItemInfo = Parser.Parser.ParseMovieTitle(downloadClientItem.Title); downloadClientItemInfo = _parsingService.EnhanceMovieInfo(downloadClientItemInfo); } @@ -97,7 +97,7 @@ private ImportDecision GetDecision(LocalMovie localMovie, DownloadClientItem dow { ImportDecision decision = null; - var fileMovieInfo = Parser.Parser.ParseMoviePath(localMovie.Path, false); + var fileMovieInfo = Parser.Parser.ParseMoviePath(localMovie.Path); if (fileMovieInfo != null) { diff --git a/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs index a74ac0015..83115eecb 100644 --- a/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs @@ -129,7 +129,7 @@ private List ProcessFolder(string rootFolder, string baseFolde return processedFiles.Concat(processedFolders).Where(i => i != null).ToList(); } - var folderInfo = Parser.Parser.ParseMovieTitle(directoryInfo.Name, false); + var folderInfo = Parser.Parser.ParseMovieTitle(directoryInfo.Name); var movieFiles = _diskScanService.GetVideoFiles(baseFolder).ToList(); var decisions = _importDecisionMaker.GetImportDecisions(movieFiles, movie, downloadClientItem, folderInfo, SceneSource(movie, baseFolder), filterExistingFiles); @@ -164,7 +164,7 @@ private ManualImportItem ProcessFile(string rootFolder, string baseFolder, strin if (movie == null) { - var relativeParseInfo = Parser.Parser.ParseMoviePath(relativeFile, false); + var relativeParseInfo = Parser.Parser.ParseMoviePath(relativeFile); if (relativeParseInfo != null) { @@ -241,7 +241,7 @@ public void Execute(ManualImportCommand message) var file = message.Files[i]; var movie = _movieService.GetMovie(file.MovieId); - var fileMovieInfo = Parser.Parser.ParseMoviePath(file.Path, false) ?? new ParsedMovieInfo(); + var fileMovieInfo = Parser.Parser.ParseMoviePath(file.Path) ?? new ParsedMovieInfo(); var existingFile = movie.Path.IsParentPath(file.Path); TrackedDownload trackedDownload = null; @@ -264,7 +264,7 @@ public void Execute(ManualImportCommand message) if (file.FolderName.IsNotNullOrWhiteSpace()) { - localMovie.FolderMovieInfo = Parser.Parser.ParseMovieTitle(file.FolderName, false); + localMovie.FolderMovieInfo = Parser.Parser.ParseMovieTitle(file.FolderName); } localMovie = _aggregationService.Augment(localMovie, false); diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index ab745e31a..ab9b913d9 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -290,7 +290,7 @@ public List SearchForNewMovie(string title) lowerTitle = lowerTitle.Replace(".", ""); - var parserResult = Parser.Parser.ParseMovieTitle(title, true, true); + var parserResult = Parser.Parser.ParseMovieTitle(title, true); var yearTerm = ""; diff --git a/src/NzbDrone.Core/NetImport/RSSImport/RSSImportParser.cs b/src/NzbDrone.Core/NetImport/RSSImport/RSSImportParser.cs index 1ae8acd72..84f84cd42 100644 --- a/src/NzbDrone.Core/NetImport/RSSImport/RSSImportParser.cs +++ b/src/NzbDrone.Core/NetImport/RSSImport/RSSImportParser.cs @@ -142,7 +142,7 @@ protected virtual Movie ProcessItem(XElement item, Movie releaseInfo) } releaseInfo.Title = title; - var result = Parser.Parser.ParseMovieTitle(title, false); //Depreciated anyways + var result = Parser.Parser.ParseMovieTitle(title); //Depreciated anyways if (result != null) { diff --git a/src/NzbDrone.Core/Organizer/FileNameValidationService.cs b/src/NzbDrone.Core/Organizer/FileNameValidationService.cs index 86d3911eb..c0ab89ad7 100644 --- a/src/NzbDrone.Core/Organizer/FileNameValidationService.cs +++ b/src/NzbDrone.Core/Organizer/FileNameValidationService.cs @@ -14,7 +14,7 @@ public class FileNameValidationService : IFilenameValidationService public ValidationFailure ValidateMovieFilename(SampleResult sampleResult) { var validationFailure = new ValidationFailure("MovieFormat", ERROR_MESSAGE); - var parsedMovieInfo = Parser.Parser.ParseMovieTitle(sampleResult.FileName, false); //We are not lenient when testing naming schemes + var parsedMovieInfo = Parser.Parser.ParseMovieTitle(sampleResult.FileName); if (parsedMovieInfo == null) { diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index 84ac7d6cc..fb02f5cb7 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -22,6 +22,9 @@ public static class Parser private static readonly Regex[] ReportMovieTitleRegex = new[] { + //Some german or french tracker formats (missing year, ...) (Only applies to german and French/TrueFrench releases) - see ParserFixture for examples and tests + new Regex(@"^(?(?![(\[]).+?)((\W|_))(" + ReportEditionRegex + @".{1,3})?(?:(?<!(19|20)\d{2}.*?)(German|French|TrueFrench))(.+?)(?=((19|20)\d{2}|$))(?<year>(19|20)\d{2}(?!p|i|\d+|\]|\W\d+))?(\W+|_|$)(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled), + //Special, Despecialized, etc. Edition Movies, e.g: Mission.Impossible.3.Special.Edition.2011 new Regex(@"^(?<title>(?![(\[]).+?)?(?:(?:[-_\W](?<![)\[!]))*" + ReportEditionRegex + @".{1,3}(?<year>(1(8|9)|20)\d{2}(?!p|i|\d+|\]|\W\d+)))+(\W+|_|$)(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled), @@ -49,16 +52,6 @@ public static class Parser new Regex(@"^(?:(?:[-_\W](?<![)!]))*(?<year>(19|20)\d{2}(?!p|i|\d+|\W\d+)))+(\W+|_|$)(?<title>.+?)?$") }; - private static readonly Regex[] ReportMovieTitleLenientRegexBefore = new[] - { - //Some german or french tracker formats - new Regex(@"^(?<title>(?![(\[]).+?)((\W|_))(" + ReportEditionRegex + @".{1,3})?(?:(?<!(19|20)\d{2}.*?)(German|French|TrueFrench))(.+?)(?=((19|20)\d{2}|$))(?<year>(19|20)\d{2}(?!p|i|\d+|\]|\W\d+))?(\W+|_|$)(?!\\)", RegexOptions.IgnoreCase | RegexOptions.Compiled), - }; - - private static readonly Regex[] ReportMovieTitleLenientRegexAfter = new Regex[] - { - }; - private static readonly Regex[] RejectHashedReleasesRegex = new Regex[] { // Generic match for md5 and mixed-case hashes. @@ -147,28 +140,28 @@ public static class Parser { "ΓΌ", "ue" }, }; - public static ParsedMovieInfo ParseMoviePath(string path, bool isLenient) + public static ParsedMovieInfo ParseMoviePath(string path) { var fileInfo = new FileInfo(path); - var result = ParseMovieTitle(fileInfo.Name, isLenient, true); + var result = ParseMovieTitle(fileInfo.Name, true); if (result == null) { Logger.Debug("Attempting to parse movie info using directory and file names. {0}", fileInfo.Directory.Name); - result = ParseMovieTitle(fileInfo.Directory.Name + " " + fileInfo.Name, isLenient); + result = ParseMovieTitle(fileInfo.Directory.Name + " " + fileInfo.Name); } if (result == null) { Logger.Debug("Attempting to parse movie info using directory name. {0}", fileInfo.Directory.Name); - result = ParseMovieTitle(fileInfo.Directory.Name + fileInfo.Extension, isLenient); + result = ParseMovieTitle(fileInfo.Directory.Name + fileInfo.Extension); } return result; } - public static ParsedMovieInfo ParseMovieTitle(string title, bool isLenient, bool isDir = false) + public static ParsedMovieInfo ParseMovieTitle(string title, bool isDir = false) { try { @@ -218,13 +211,6 @@ public static ParsedMovieInfo ParseMovieTitle(string title, bool isLenient, bool allRegexes.AddRange(ReportMovieTitleFolderRegex); } - if (isLenient) - { - allRegexes.InsertRange(0, ReportMovieTitleLenientRegexBefore); - - allRegexes.AddRange(ReportMovieTitleLenientRegexAfter); - } - foreach (var regex in allRegexes) { var match = regex.Matches(simpleTitle); diff --git a/src/NzbDrone.Core/Parser/ParsingLeniency.cs b/src/NzbDrone.Core/Parser/ParsingLeniency.cs deleted file mode 100644 index 188c6bc47..000000000 --- a/src/NzbDrone.Core/Parser/ParsingLeniency.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace NzbDrone.Core.Parser -{ - public enum ParsingLeniencyType - { - Strict = 0, - ParsingLenient = 1, - MappingLenient = 2, - } -} diff --git a/src/NzbDrone.Core/Parser/ParsingService.cs b/src/NzbDrone.Core/Parser/ParsingService.cs index aefef6e2b..17f834c41 100644 --- a/src/NzbDrone.Core/Parser/ParsingService.cs +++ b/src/NzbDrone.Core/Parser/ParsingService.cs @@ -51,7 +51,7 @@ public ParsingService(IMovieService movieService, public ParsedMovieInfo ParseMovieInfo(string title, List<object> helpers) { - var result = Parser.ParseMovieTitle(title, _config.ParsingLeniency > 0); + var result = Parser.ParseMovieTitle(title); if (result == null) { @@ -88,7 +88,7 @@ private ParsedMovieInfo AugmentMovieInfo(ParsedMovieInfo minimalInfo, List<objec public ParsedMovieInfo ParseMinimalMovieInfo(string file, bool isDir = false) { - return Parser.ParseMovieTitle(file, _config.ParsingLeniency > 0, isDir); + return Parser.ParseMovieTitle(file, isDir); } public ParsedMovieInfo ParseMinimalPathMovieInfo(string path) @@ -114,7 +114,7 @@ public ParsedMovieInfo ParseMinimalPathMovieInfo(string path) public Movie GetMovie(string title) { - var parsedMovieInfo = Parser.ParseMovieTitle(title, _config.ParsingLeniency > 0); + var parsedMovieInfo = Parser.ParseMovieTitle(title); if (parsedMovieInfo == null) { @@ -220,16 +220,6 @@ private bool TryGetMovieByTitleAndOrYear(ParsedMovieInfo parsedMovieInfo, out Ma return false; } - if (_config.ParsingLeniency == ParsingLeniencyType.MappingLenient) - { - movieByTitleAndOrYear = _movieService.FindByTitleInexact(parsedMovieInfo.MovieTitle, parsedMovieInfo.Year); - if (isNotNull(movieByTitleAndOrYear)) - { - result = new MappingResult { Movie = movieByTitleAndOrYear, MappingResultType = MappingResultType.SuccessLenientMapping }; - return true; - } - } - result = new MappingResult { Movie = movieByTitleAndOrYear, MappingResultType = MappingResultType.TitleNotFound }; return false; } @@ -241,16 +231,6 @@ private bool TryGetMovieByTitleAndOrYear(ParsedMovieInfo parsedMovieInfo, out Ma return true; } - if (_config.ParsingLeniency == ParsingLeniencyType.MappingLenient) - { - movieByTitleAndOrYear = _movieService.FindByTitleInexact(parsedMovieInfo.MovieTitle, null); - if (isNotNull(movieByTitleAndOrYear)) - { - result = new MappingResult { Movie = movieByTitleAndOrYear, MappingResultType = MappingResultType.SuccessLenientMapping }; - return true; - } - } - result = new MappingResult { Movie = movieByTitleAndOrYear, MappingResultType = MappingResultType.TitleNotFound }; return false; } @@ -307,29 +287,6 @@ private bool TryGetMovieBySearchCriteria(ParsedMovieInfo parsedMovieInfo, Search return false; } - if (_config.ParsingLeniency == ParsingLeniencyType.MappingLenient) - { - if (searchCriteria.Movie.CleanTitle.Contains(cleanTitle) || - cleanTitle.Contains(searchCriteria.Movie.CleanTitle)) - { - possibleMovie = searchCriteria.Movie; - if ((parsedMovieInfo.Year > 1800 && parsedMovieInfo.Year == possibleMovie.Year) || possibleMovie.SecondaryYear == parsedMovieInfo.Year) - { - result = new MappingResult { Movie = possibleMovie, MappingResultType = MappingResultType.SuccessLenientMapping }; - return true; - } - - if (parsedMovieInfo.Year < 1800) - { - result = new MappingResult { Movie = possibleMovie, MappingResultType = MappingResultType.SuccessLenientMapping }; - return true; - } - - result = new MappingResult { Movie = possibleMovie, MappingResultType = MappingResultType.WrongYear }; - return false; - } - } - result = new MappingResult { Movie = searchCriteria.Movie, MappingResultType = MappingResultType.WrongTitle }; return false; @@ -346,8 +303,6 @@ public string Message { case MappingResultType.Success: return $"Successfully mapped release name {ReleaseName} to movie {Movie}"; - case MappingResultType.SuccessLenientMapping: - return $"Successfully mapped parts of the release name {ReleaseName} to movie {Movie}"; case MappingResultType.NotParsable: return $"Failed to find movie title in release name {ReleaseName}"; case MappingResultType.TitleNotFound: @@ -400,7 +355,6 @@ public Rejection ToRejection() switch (MappingResultType) { case MappingResultType.Success: - case MappingResultType.SuccessLenientMapping: return null; default: return new Rejection(Message); @@ -412,7 +366,6 @@ public enum MappingResultType { Unknown = -1, Success = 0, - SuccessLenientMapping = 1, WrongYear = 2, WrongTitle = 3, TitleNotFound = 4, diff --git a/src/NzbDrone.Core/Parser/SceneChecker.cs b/src/NzbDrone.Core/Parser/SceneChecker.cs index 9989b3ad9..e23e17345 100644 --- a/src/NzbDrone.Core/Parser/SceneChecker.cs +++ b/src/NzbDrone.Core/Parser/SceneChecker.cs @@ -16,7 +16,7 @@ public static bool IsSceneTitle(string title) return false; } - var parsedTitle = Parser.ParseMovieTitle(title, false); //We are not lenient when it comes to scene checking! + var parsedTitle = Parser.ParseMovieTitle(title); if (parsedTitle == null || parsedTitle.ReleaseGroup == null || diff --git a/src/Radarr.Api.V3/Config/IndexerConfigResource.cs b/src/Radarr.Api.V3/Config/IndexerConfigResource.cs index 3e9910460..b8f445d86 100644 --- a/src/Radarr.Api.V3/Config/IndexerConfigResource.cs +++ b/src/Radarr.Api.V3/Config/IndexerConfigResource.cs @@ -14,7 +14,6 @@ public class IndexerConfigResource : RestResource public int AvailabilityDelay { get; set; } public bool AllowHardcodedSubs { get; set; } public string WhitelistedHardcodedSubs { get; set; } - public ParsingLeniencyType ParsingLeniency { get; set; } } public static class IndexerConfigResourceMapper @@ -31,7 +30,6 @@ public static IndexerConfigResource ToResource(IConfigService model) AvailabilityDelay = model.AvailabilityDelay, AllowHardcodedSubs = model.AllowHardcodedSubs, WhitelistedHardcodedSubs = model.WhitelistedHardcodedSubs, - ParsingLeniency = model.ParsingLeniency, }; } }