From 4d795e13cde24025e991278a7adbb3388dda6daa Mon Sep 17 00:00:00 2001 From: Leonardo Galli Date: Sat, 7 Jan 2017 10:42:21 +0100 Subject: [PATCH] Fix for movie naming config. Still kinda hacky, but works ok now. --- src/NzbDrone.Api/Config/NamingConfigModule.cs | 16 ++++---- .../109_add_movie_formats_to_naming_config.cs | 38 ++++--------------- .../Organizer/FileNameBuilder.cs | 7 +++- .../Organizer/FileNameSampleService.cs | 3 +- .../Naming/Basic/BasicNamingView.js | 8 ++-- .../Naming/NamingViewTemplate.hbs | 4 +- 6 files changed, 28 insertions(+), 48 deletions(-) diff --git a/src/NzbDrone.Api/Config/NamingConfigModule.cs b/src/NzbDrone.Api/Config/NamingConfigModule.cs index 3e063bff4..04a67856e 100644 --- a/src/NzbDrone.Api/Config/NamingConfigModule.cs +++ b/src/NzbDrone.Api/Config/NamingConfigModule.cs @@ -110,7 +110,7 @@ namespace NzbDrone.Api.Config // ? "Invalid format" // : animeMultiEpisodeSampleResult.FileName; - sampleResource.MovieExample = _filenameValidationService.ValidateMovieFilename(movieSampleResult) != null + sampleResource.MovieExample = nameSpec.StandardMovieFormat.IsNullOrWhiteSpace() ? "Invalid Format" : movieSampleResult.FileName; @@ -145,17 +145,17 @@ namespace NzbDrone.Api.Config var animeEpisodeValidationResult = _filenameValidationService.ValidateAnimeFilename(animeEpisodeSampleResult); var animeMultiEpisodeValidationResult = _filenameValidationService.ValidateAnimeFilename(animeMultiEpisodeSampleResult); - var standardMovieValidationResult = _filenameValidationService.ValidateMovieFilename(movieSampleResult); + //var standardMovieValidationResult = _filenameValidationService.ValidateMovieFilename(movieSampleResult); For now, let's hope the user is not stupid enough :/ var validationFailures = new List(); - validationFailures.AddIfNotNull(singleEpisodeValidationResult); - validationFailures.AddIfNotNull(multiEpisodeValidationResult); - validationFailures.AddIfNotNull(dailyEpisodeValidationResult); - validationFailures.AddIfNotNull(animeEpisodeValidationResult); - validationFailures.AddIfNotNull(animeMultiEpisodeValidationResult); + //validationFailures.AddIfNotNull(singleEpisodeValidationResult); + //validationFailures.AddIfNotNull(multiEpisodeValidationResult); + //validationFailures.AddIfNotNull(dailyEpisodeValidationResult); + //validationFailures.AddIfNotNull(animeEpisodeValidationResult); + //validationFailures.AddIfNotNull(animeMultiEpisodeValidationResult); - validationFailures.AddIfNotNull(standardMovieValidationResult); + //validationFailures.AddIfNotNull(standardMovieValidationResult); if (validationFailures.Any()) { diff --git a/src/NzbDrone.Core/Datastore/Migration/109_add_movie_formats_to_naming_config.cs b/src/NzbDrone.Core/Datastore/Migration/109_add_movie_formats_to_naming_config.cs index 9617ed1c6..c5c6059f8 100644 --- a/src/NzbDrone.Core/Datastore/Migration/109_add_movie_formats_to_naming_config.cs +++ b/src/NzbDrone.Core/Datastore/Migration/109_add_movie_formats_to_naming_config.cs @@ -28,48 +28,24 @@ namespace NzbDrone.Core.Datastore.Migration namingConfigCmd.CommandText = @"SELECT * FROM NamingConfig LIMIT 1"; using (IDataReader namingConfigReader = namingConfigCmd.ExecuteReader()) { - var separatorIndex = namingConfigReader.GetOrdinal("Separator"); - var includeQualityIndex = namingConfigReader.GetOrdinal("IncludeQuality"); - var replaceSpacesIndex = namingConfigReader.GetOrdinal("ReplaceSpaces"); while (namingConfigReader.Read()) { - var separator = namingConfigReader.GetString(separatorIndex); - var includeQuality = namingConfigReader.GetBoolean(includeQualityIndex); - var replaceSpaces = namingConfigReader.GetBoolean(replaceSpacesIndex); - // Output Settings var movieTitlePattern = ""; - //var movieYearPattern = "({Release Year})"; - var qualityFormat = " [{Quality Title}]"; + var movieYearPattern = "({Release Year})"; + var qualityFormat = "[{Quality Title}]"; - if (replaceSpaces) - { - movieTitlePattern = "{Movie.Title}"; + movieTitlePattern = "{Movie Title}"; + - } - else - { - movieTitlePattern = "{Movie Title}"; - } - - movieTitlePattern += separator; + movieTitlePattern += " "; var standardMovieFormat = string.Format("{0}{1}", movieTitlePattern, qualityFormat); - var movieFolderFormat = string.Format("{0}", movieTitlePattern); - - if (includeQuality) - { - if (replaceSpaces) - { - qualityFormat = ".[{Quality.Title}]"; - } - - movieFolderFormat += qualityFormat; - standardMovieFormat += qualityFormat; - } + var movieFolderFormat = string.Format("{0}{1}", movieTitlePattern, movieYearPattern); + using (IDbCommand updateCmd = conn.CreateCommand()) { diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs index 96479e44b..25399e6de 100644 --- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -160,7 +160,7 @@ namespace NzbDrone.Core.Organizer var tokenHandlers = new Dictionary>(FileNameBuilderTokenEqualityComparer.Instance); AddMovieTokens(tokenHandlers, movie); - //AddReleaseDateTokens(tokenHandlers, movie.Year); //In case we want to separate the year + AddReleaseDateTokens(tokenHandlers, movie.Year); //In case we want to separate the year AddQualityTokens(tokenHandlers, movie, movieFile); AddMediaInfoTokens(tokenHandlers, movieFile); @@ -214,6 +214,8 @@ namespace NzbDrone.Core.Organizer public BasicNamingConfig GetBasicNamingConfig(NamingConfig nameSpec) { + return new BasicNamingConfig(); //For now let's be lazy + var episodeFormat = GetEpisodeFormat(nameSpec.StandardEpisodeFormat).LastOrDefault(); if (episodeFormat == null) @@ -297,6 +299,7 @@ namespace NzbDrone.Core.Organizer var tokenHandlers = new Dictionary>(FileNameBuilderTokenEqualityComparer.Instance); AddMovieTokens(tokenHandlers, movie); + AddReleaseDateTokens(tokenHandlers, movie.Year); return CleanFolderName(ReplaceTokens(namingConfig.MovieFolderFormat, tokenHandlers, namingConfig)); } @@ -470,7 +473,7 @@ namespace NzbDrone.Core.Organizer private void AddReleaseDateTokens(Dictionary> tokenHandlers, int releaseYear) { - tokenHandlers["{Release Year}"] = m => string.Format("({0})", releaseYear.ToString()); //Do I need m.CustomFormat? + tokenHandlers["{Release Year}"] = m => string.Format("{0}", releaseYear.ToString()); //Do I need m.CustomFormat? } private void AddSeasonTokens(Dictionary> tokenHandlers, int seasonNumber) diff --git a/src/NzbDrone.Core/Organizer/FileNameSampleService.cs b/src/NzbDrone.Core/Organizer/FileNameSampleService.cs index 2305acc4b..654179b52 100644 --- a/src/NzbDrone.Core/Organizer/FileNameSampleService.cs +++ b/src/NzbDrone.Core/Organizer/FileNameSampleService.cs @@ -46,7 +46,8 @@ namespace NzbDrone.Core.Organizer _movie = new Movie { - Title = "Movie Title (2010)" + Title = "Movie Title", + Year = 2010 }; _standardSeries = new Series diff --git a/src/UI/Settings/MediaManagement/Naming/Basic/BasicNamingView.js b/src/UI/Settings/MediaManagement/Naming/Basic/BasicNamingView.js index 916a15aed..2f6320ac8 100644 --- a/src/UI/Settings/MediaManagement/Naming/Basic/BasicNamingView.js +++ b/src/UI/Settings/MediaManagement/Naming/Basic/BasicNamingView.js @@ -26,10 +26,10 @@ var view = Marionette.ItemView.extend({ }, _parseNamingModel : function() { - var standardFormat = this.namingModel.get('standardEpisodeFormat'); + var standardFormat = this.namingModel.get('standardMovieFormat'); - var includeSeriesTitle = standardFormat.match(/\{Series[-_. ]Title\}/i); - var includeEpisodeTitle = standardFormat.match(/\{Episode[-_. ]Title\}/i); + var includeSeriesTitle = false;//standardFormat.match(/\{Series[-_. ]Title\}/i); + var includeEpisodeTitle = false;//standardFormat.match(/\{Episode[-_. ]Title\}/i); var includeQuality = standardFormat.match(/\{Quality[-_. ]Title\}/i); var numberStyle = standardFormat.match(/s?\{season(?:\:0+)?\}[ex]\{episode(?:\:0+)?\}/i); var replaceSpaces = standardFormat.indexOf(' ') === -1; @@ -115,4 +115,4 @@ var view = Marionette.ItemView.extend({ } }); -module.exports = AsModelBoundView.call(view); \ No newline at end of file +module.exports = AsModelBoundView.call(view); diff --git a/src/UI/Settings/MediaManagement/Naming/NamingViewTemplate.hbs b/src/UI/Settings/MediaManagement/Naming/NamingViewTemplate.hbs index ccd233d84..615f95b1a 100644 --- a/src/UI/Settings/MediaManagement/Naming/NamingViewTemplate.hbs +++ b/src/UI/Settings/MediaManagement/Naming/NamingViewTemplate.hbs @@ -67,7 +67,7 @@