Update Rename Preview to support folder renaming

This commit is contained in:
Tim Turner 2017-01-25 19:03:40 -05:00
parent 68f58fb37d
commit 72aac6e551
5 changed files with 34 additions and 6 deletions

View File

@ -71,8 +71,9 @@ namespace NzbDrone.Core.MediaFiles
{
MovieId = movie.Id,
MovieFileId = file.Id,
ExistingPath = file.RelativePath,
NewPath = movie.Path.GetRelativePath(newPath)
ExistingPath = movieFilePath,
//NewPath = movie.Path.GetRelativePath(newPath)
NewPath = newPath
};
}

View File

@ -155,12 +155,11 @@ namespace NzbDrone.Core.Organizer
return GetOriginalTitle(movieFile);
}
//TODO: Update namingConfig for Movies!
var pattern = namingConfig.StandardMovieFormat;
var tokenHandlers = new Dictionary<string, Func<TokenMatch, string>>(FileNameBuilderTokenEqualityComparer.Instance);
AddMovieTokens(tokenHandlers, movie);
AddReleaseDateTokens(tokenHandlers, movie.Year); //In case we want to separate the year
AddReleaseDateTokens(tokenHandlers, movie.Year);
AddImdbIdTokens(tokenHandlers, movie.ImdbId);
AddQualityTokens(tokenHandlers, movie, movieFile);
AddMediaInfoTokens(tokenHandlers, movieFile);
@ -186,11 +185,37 @@ namespace NzbDrone.Core.Organizer
{
Ensure.That(extension, () => extension).IsNotNullOrWhiteSpace();
var path = movie.Path;
var path = BuildMoviePath(movie);
return Path.Combine(path, fileName + extension);
}
public string BuildMoviePath(Movie movie)
{
var path = movie.Path;
var directory = new DirectoryInfo(path).Name;
var parentDirectoryPath = new DirectoryInfo(path).Parent.FullName;
var namingConfig = _namingConfigService.GetConfig();
var movieFile = movie.MovieFile;
var pattern = namingConfig.MovieFolderFormat;
var tokenHandlers = new Dictionary<string, Func<TokenMatch, string>>(FileNameBuilderTokenEqualityComparer.Instance);
AddMovieTokens(tokenHandlers, movie);
AddReleaseDateTokens(tokenHandlers, movie.Year);
AddImdbIdTokens(tokenHandlers, movie.ImdbId);
AddQualityTokens(tokenHandlers, movie, movieFile);
AddMediaInfoTokens(tokenHandlers, movieFile);
AddMovieFileTokens(tokenHandlers, movieFile);
var directoryName = ReplaceTokens(pattern, tokenHandlers, namingConfig).Trim();
directoryName = FileNameCleanupRegex.Replace(directoryName, match => match.Captures[0].Value[0].ToString());
directoryName = TrimSeparatorsRegex.Replace(directoryName, string.Empty);
return Path.Combine(parentDirectoryPath, directoryName);
}
public string BuildSeasonPath(Series series, int seasonNumber)
{
var path = series.Path;

View File

@ -9,6 +9,7 @@ module.exports = Marionette.ItemView.extend({
//var type = this.model.get('seriesType');
return {
rename : this.naming.get('renameEpisodes'),
folderFormat: this.naming.get('movieFolderFormat'),
format : this.naming.get('standardMovieFormat')
};
},

View File

@ -1,3 +1,4 @@
{{#if rename}}
Folder Naming pattern: {{folderFormat}}<br>
Naming pattern: {{format}}
{{/if}}

View File

@ -9,7 +9,7 @@
</div>
<div class="modal-body">
<div class="alert alert-info">
<div class="path-info x-path-info">All paths are relative to: <strong>{{path}}</strong></div>
<div class="path-info x-path-info">Your movie may be moved; see the paths below</div>
<div class="x-format-region"></div>
</div>