Fix for movie naming config. Still kinda hacky, but works ok now.

pull/38/head
Leonardo Galli 8 years ago
parent 23249de728
commit 4d795e13cd

@ -110,7 +110,7 @@ namespace NzbDrone.Api.Config
// ? "Invalid format" // ? "Invalid format"
// : animeMultiEpisodeSampleResult.FileName; // : animeMultiEpisodeSampleResult.FileName;
sampleResource.MovieExample = _filenameValidationService.ValidateMovieFilename(movieSampleResult) != null sampleResource.MovieExample = nameSpec.StandardMovieFormat.IsNullOrWhiteSpace()
? "Invalid Format" ? "Invalid Format"
: movieSampleResult.FileName; : movieSampleResult.FileName;
@ -145,17 +145,17 @@ namespace NzbDrone.Api.Config
var animeEpisodeValidationResult = _filenameValidationService.ValidateAnimeFilename(animeEpisodeSampleResult); var animeEpisodeValidationResult = _filenameValidationService.ValidateAnimeFilename(animeEpisodeSampleResult);
var animeMultiEpisodeValidationResult = _filenameValidationService.ValidateAnimeFilename(animeMultiEpisodeSampleResult); 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<ValidationFailure>(); var validationFailures = new List<ValidationFailure>();
validationFailures.AddIfNotNull(singleEpisodeValidationResult); //validationFailures.AddIfNotNull(singleEpisodeValidationResult);
validationFailures.AddIfNotNull(multiEpisodeValidationResult); //validationFailures.AddIfNotNull(multiEpisodeValidationResult);
validationFailures.AddIfNotNull(dailyEpisodeValidationResult); //validationFailures.AddIfNotNull(dailyEpisodeValidationResult);
validationFailures.AddIfNotNull(animeEpisodeValidationResult); //validationFailures.AddIfNotNull(animeEpisodeValidationResult);
validationFailures.AddIfNotNull(animeMultiEpisodeValidationResult); //validationFailures.AddIfNotNull(animeMultiEpisodeValidationResult);
validationFailures.AddIfNotNull(standardMovieValidationResult); //validationFailures.AddIfNotNull(standardMovieValidationResult);
if (validationFailures.Any()) if (validationFailures.Any())
{ {

@ -28,48 +28,24 @@ namespace NzbDrone.Core.Datastore.Migration
namingConfigCmd.CommandText = @"SELECT * FROM NamingConfig LIMIT 1"; namingConfigCmd.CommandText = @"SELECT * FROM NamingConfig LIMIT 1";
using (IDataReader namingConfigReader = namingConfigCmd.ExecuteReader()) using (IDataReader namingConfigReader = namingConfigCmd.ExecuteReader())
{ {
var separatorIndex = namingConfigReader.GetOrdinal("Separator");
var includeQualityIndex = namingConfigReader.GetOrdinal("IncludeQuality");
var replaceSpacesIndex = namingConfigReader.GetOrdinal("ReplaceSpaces");
while (namingConfigReader.Read()) while (namingConfigReader.Read())
{ {
var separator = namingConfigReader.GetString(separatorIndex);
var includeQuality = namingConfigReader.GetBoolean(includeQualityIndex);
var replaceSpaces = namingConfigReader.GetBoolean(replaceSpacesIndex);
// Output Settings // Output Settings
var movieTitlePattern = ""; var movieTitlePattern = "";
//var movieYearPattern = "({Release Year})"; var movieYearPattern = "({Release Year})";
var qualityFormat = " [{Quality Title}]"; 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, var standardMovieFormat = string.Format("{0}{1}", movieTitlePattern,
qualityFormat); qualityFormat);
var movieFolderFormat = string.Format("{0}", movieTitlePattern); var movieFolderFormat = string.Format("{0}{1}", movieTitlePattern, movieYearPattern);
if (includeQuality)
{
if (replaceSpaces)
{
qualityFormat = ".[{Quality.Title}]";
}
movieFolderFormat += qualityFormat;
standardMovieFormat += qualityFormat;
}
using (IDbCommand updateCmd = conn.CreateCommand()) using (IDbCommand updateCmd = conn.CreateCommand())
{ {

@ -160,7 +160,7 @@ namespace NzbDrone.Core.Organizer
var tokenHandlers = new Dictionary<string, Func<TokenMatch, string>>(FileNameBuilderTokenEqualityComparer.Instance); var tokenHandlers = new Dictionary<string, Func<TokenMatch, string>>(FileNameBuilderTokenEqualityComparer.Instance);
AddMovieTokens(tokenHandlers, movie); 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); AddQualityTokens(tokenHandlers, movie, movieFile);
AddMediaInfoTokens(tokenHandlers, movieFile); AddMediaInfoTokens(tokenHandlers, movieFile);
@ -214,6 +214,8 @@ namespace NzbDrone.Core.Organizer
public BasicNamingConfig GetBasicNamingConfig(NamingConfig nameSpec) public BasicNamingConfig GetBasicNamingConfig(NamingConfig nameSpec)
{ {
return new BasicNamingConfig(); //For now let's be lazy
var episodeFormat = GetEpisodeFormat(nameSpec.StandardEpisodeFormat).LastOrDefault(); var episodeFormat = GetEpisodeFormat(nameSpec.StandardEpisodeFormat).LastOrDefault();
if (episodeFormat == null) if (episodeFormat == null)
@ -297,6 +299,7 @@ namespace NzbDrone.Core.Organizer
var tokenHandlers = new Dictionary<string, Func<TokenMatch, string>>(FileNameBuilderTokenEqualityComparer.Instance); var tokenHandlers = new Dictionary<string, Func<TokenMatch, string>>(FileNameBuilderTokenEqualityComparer.Instance);
AddMovieTokens(tokenHandlers, movie); AddMovieTokens(tokenHandlers, movie);
AddReleaseDateTokens(tokenHandlers, movie.Year);
return CleanFolderName(ReplaceTokens(namingConfig.MovieFolderFormat, tokenHandlers, namingConfig)); return CleanFolderName(ReplaceTokens(namingConfig.MovieFolderFormat, tokenHandlers, namingConfig));
} }
@ -470,7 +473,7 @@ namespace NzbDrone.Core.Organizer
private void AddReleaseDateTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, int releaseYear) private void AddReleaseDateTokens(Dictionary<string, Func<TokenMatch, string>> 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<string, Func<TokenMatch, string>> tokenHandlers, int seasonNumber) private void AddSeasonTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, int seasonNumber)

@ -46,7 +46,8 @@ namespace NzbDrone.Core.Organizer
_movie = new Movie _movie = new Movie
{ {
Title = "Movie Title (2010)" Title = "Movie Title",
Year = 2010
}; };
_standardSeries = new Series _standardSeries = new Series

@ -26,10 +26,10 @@ var view = Marionette.ItemView.extend({
}, },
_parseNamingModel : function() { _parseNamingModel : function() {
var standardFormat = this.namingModel.get('standardEpisodeFormat'); var standardFormat = this.namingModel.get('standardMovieFormat');
var includeSeriesTitle = standardFormat.match(/\{Series[-_. ]Title\}/i); var includeSeriesTitle = false;//standardFormat.match(/\{Series[-_. ]Title\}/i);
var includeEpisodeTitle = standardFormat.match(/\{Episode[-_. ]Title\}/i); var includeEpisodeTitle = false;//standardFormat.match(/\{Episode[-_. ]Title\}/i);
var includeQuality = standardFormat.match(/\{Quality[-_. ]Title\}/i); var includeQuality = standardFormat.match(/\{Quality[-_. ]Title\}/i);
var numberStyle = standardFormat.match(/s?\{season(?:\:0+)?\}[ex]\{episode(?:\:0+)?\}/i); var numberStyle = standardFormat.match(/s?\{season(?:\:0+)?\}[ex]\{episode(?:\:0+)?\}/i);
var replaceSpaces = standardFormat.indexOf(' ') === -1; var replaceSpaces = standardFormat.indexOf(' ') === -1;

@ -67,7 +67,7 @@
</button> </button>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
{{> MovieTitleNamingPartial}} {{> MovieTitleNamingPartial}}
{{!--{{> ReleaseYearNamingPartial}}--}} {{> ReleaseYearNamingPartial}}
{{> QualityNamingPartial}} {{> QualityNamingPartial}}
{{> MediaInfoNamingPartial}} {{> MediaInfoNamingPartial}}
{{> ReleaseGroupNamingPartial}} {{> ReleaseGroupNamingPartial}}
@ -160,7 +160,7 @@
</button> </button>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
{{> MovieTitleNamingPartial}} {{> MovieTitleNamingPartial}}
{{!--{{> ReleaseYearNamingPartial}}--}} {{> ReleaseYearNamingPartial}}
</ul> </ul>
</div> </div>
</div> </div>

Loading…
Cancel
Save