From df197d2e165e414904c0f707354dbb9d62f4c190 Mon Sep 17 00:00:00 2001 From: Qstick Date: Mon, 24 Aug 2020 20:57:45 -0400 Subject: [PATCH] New: Movie Collection naming token --- .../MediaManagement/Naming/NamingModal.js | 1 + .../FileNameBuilderFixture.cs | 29 +++++++++++++++++++ .../Organizer/FileNameBuilder.cs | 1 + .../Organizer/FileNameSampleService.cs | 2 ++ 4 files changed, 33 insertions(+) diff --git a/frontend/src/Settings/MediaManagement/Naming/NamingModal.js b/frontend/src/Settings/MediaManagement/Naming/NamingModal.js index 747ddede0..4965d985c 100644 --- a/frontend/src/Settings/MediaManagement/Naming/NamingModal.js +++ b/frontend/src/Settings/MediaManagement/Naming/NamingModal.js @@ -119,6 +119,7 @@ class NamingModal extends Component { { token: '{Movie CleanTitle}', example: 'Movie Title' }, { token: '{Movie TitleThe}', example: 'Movie Title, The' }, { token: '{Movie TitleFirstCharacter}', example: 'M' }, + { token: '{Movie Collection}', example: 'The Movie Collection' }, { token: '{Movie Certification}', example: 'R' }, { token: '{Release Year}', example: '2009' } ]; diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs index d208c1a20..bdbbf31dd 100644 --- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs +++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/FileNameBuilderFixture.cs @@ -198,6 +198,35 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests .Should().Be("South.Park.1997"); } + [Test] + public void should_replace_movie_certification() + { + _namingConfig.StandardMovieFormat = "{Movie Certification}"; + _movie.Certification = "R"; + + Subject.BuildFileName(_movie, _movieFile) + .Should().Be("R"); + } + + [Test] + public void should_replace_movie_collection() + { + _namingConfig.StandardMovieFormat = "{Movie Collection}"; + _movie.Collection = new MovieCollection { Name = "South Part Collection" }; + + Subject.BuildFileName(_movie, _movieFile) + .Should().Be("South Part Collection"); + } + + [Test] + public void should_be_empty_for_null_collection() + { + _namingConfig.StandardMovieFormat = "{Movie Collection}"; + + Subject.BuildFileName(_movie, _movieFile) + .Should().BeEmpty(); + } + [Test] public void should_replace_quality_title() { diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs index 404d21743..c6cd11eb9 100644 --- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -234,6 +234,7 @@ namespace NzbDrone.Core.Organizer tokenHandlers["{Movie TitleFirstCharacter}"] = m => TitleThe(movie.Title).Substring(0, 1).FirstCharToUpper(); tokenHandlers["{Movie Certification}"] = m => movie.Certification ?? string.Empty; + tokenHandlers["{Movie Collection}"] = m => movie.Collection?.Name ?? string.Empty; } private string GetLanguageTitle(Movie movie, string isoCodes) diff --git a/src/NzbDrone.Core/Organizer/FileNameSampleService.cs b/src/NzbDrone.Core/Organizer/FileNameSampleService.cs index 09fb08820..5735e061b 100644 --- a/src/NzbDrone.Core/Organizer/FileNameSampleService.cs +++ b/src/NzbDrone.Core/Organizer/FileNameSampleService.cs @@ -52,6 +52,8 @@ namespace NzbDrone.Core.Organizer _movie = new Movie { Title = "The Movie: Title", + Collection = new MovieCollection { Name = "The Movie Collection", TmdbId = 123654 }, + Certification = "R", Year = 2010, ImdbId = "tt0066921", TmdbId = 345691,