From 460c86911c25af6c17a77a761317cb152bdd7e84 Mon Sep 17 00:00:00 2001 From: Qstick Date: Tue, 17 Nov 2020 22:22:31 -0500 Subject: [PATCH] Fixed: Scene Name not being stored properly during import if not linked to a download client item and filename is obfuscated Fixes #5370 Fixes $5358 Fixes #5361 --- .../MediaFiles/ImportApprovedMoviesFixture.cs | 48 ++++++++++++------- .../MovieImport/ImportApprovedMovie.cs | 6 +++ .../MovieImport/Manual/ManualImportService.cs | 1 + 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedMoviesFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedMoviesFixture.cs index d55ac2c13..d3b9a4e3b 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedMoviesFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/ImportApprovedMoviesFixture.cs @@ -171,28 +171,14 @@ public void should_remove_extension_from_nzb_title_for_scene_name(string extensi } [Test] - [Ignore("Series")] - public void should_not_use_nzb_title_as_scene_name_if_full_season() - { - GivenNewDownload(); - _approvedDecisions.First().LocalMovie.Path = Path.Combine(_downloadClientItem.OutputPath.ToString(), "malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot.mkv"); - _downloadClientItem.Title = "malcolm.in.the.middle.s02.dvdrip.xvid-ingot"; - - Subject.Import(new List { _approvedDecisions.First() }, true, _downloadClientItem); - - Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == "malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot"))); - } - - [Test] - [Ignore("Series")] public void should_use_file_name_as_scenename_only_if_it_looks_like_scenename() { GivenNewDownload(); - _approvedDecisions.First().LocalMovie.Path = Path.Combine(_downloadClientItem.OutputPath.ToString(), "malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot.mkv"); + _approvedDecisions.First().LocalMovie.Path = Path.Combine(_downloadClientItem.OutputPath.ToString(), "movie.title.2018.dvdrip.xvid-ingot.mkv"); Subject.Import(new List { _approvedDecisions.First() }, true); - Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == "malcolm.in.the.middle.s02e23.dvdrip.xvid-ingot"))); + Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == "movie.title.2018.dvdrip.xvid-ingot"))); } [Test] @@ -206,6 +192,36 @@ public void should_not_use_file_name_as_scenename_if_it_doesnt_looks_like_scenen Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == null))); } + [Test] + public void should_use_folder_name_as_scenename_only_if_it_looks_like_scenename() + { + GivenNewDownload(); + _approvedDecisions.First().LocalMovie.Path = Path.Combine(_downloadClientItem.OutputPath.ToString(), "aaaaa.mkv"); + _approvedDecisions.First().LocalMovie.FolderMovieInfo = new ParsedMovieInfo + { + ReleaseTitle = "movie.title.2018.dvdrip.xvid-ingot" + }; + + Subject.Import(new List { _approvedDecisions.First() }, true); + + Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == "movie.title.2018.dvdrip.xvid-ingot"))); + } + + [Test] + public void should_not_use_folder_name_as_scenename_if_it_doesnt_looks_like_scenename() + { + GivenNewDownload(); + _approvedDecisions.First().LocalMovie.Path = Path.Combine(_downloadClientItem.OutputPath.ToString(), "aaaaa.mkv"); + _approvedDecisions.First().LocalMovie.FolderMovieInfo = new ParsedMovieInfo + { + ReleaseTitle = "aaaaa.mkv" + }; + + Subject.Import(new List { _approvedDecisions.First() }, true); + + Mocker.GetMock().Verify(v => v.Add(It.Is(c => c.SceneName == null))); + } + [Test] public void should_import_larger_files_first() { diff --git a/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs index 1078f92d9..1722f9f99 100644 --- a/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/ImportApprovedMovie.cs @@ -231,6 +231,12 @@ private string GetSceneName(DownloadClientItem downloadClientItem, LocalMovie lo return sceneNameFile; } + var folderTitle = localMovie.FolderMovieInfo?.ReleaseTitle; + if (folderTitle.IsNotNullOrWhiteSpace() && SceneChecker.IsSceneTitle(folderTitle)) + { + return folderTitle; + } + return null; } } diff --git a/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs index 76e48914e..96434fa98 100644 --- a/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs @@ -268,6 +268,7 @@ public void Execute(ManualImportCommand message) if (file.FolderName.IsNotNullOrWhiteSpace()) { localMovie.FolderMovieInfo = Parser.Parser.ParseMovieTitle(file.FolderName); + localMovie.SceneSource = !existingFile; } localMovie = _aggregationService.Augment(localMovie, trackedDownload?.DownloadItem, false);