mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-23 06:45:19 -07:00
Merge branch 'rename-existing-folder' into develop
This commit is contained in:
commit
a340bc4da3
12 changed files with 397 additions and 330 deletions
|
@ -64,6 +64,11 @@ namespace NzbDrone.Common.Extensions
|
|||
return childPath.Substring(parentPath.Length).Trim(Path.DirectorySeparatorChar);
|
||||
}
|
||||
|
||||
public static string GetRelativePathWithoutChildCheck(this string parentPath, string childPath)
|
||||
{
|
||||
return childPath.Substring(parentPath.Length).Trim(Path.DirectorySeparatorChar);
|
||||
}
|
||||
|
||||
public static string GetParentPath(this string childPath)
|
||||
{
|
||||
var parentPath = childPath.TrimEnd('\\', '/');
|
||||
|
|
|
@ -123,6 +123,17 @@ namespace NzbDrone.Core.Extras
|
|||
// }
|
||||
//}
|
||||
|
||||
// TODO
|
||||
public void Handle(MovieFolderCreatedEvent message)
|
||||
{
|
||||
var movie = message.Movie;
|
||||
|
||||
foreach(var extraFileManager in _extraFileManagers)
|
||||
{
|
||||
//extraFileManager.CreateAfterMovieImport(movie, message.MovieFolder);
|
||||
}
|
||||
}
|
||||
|
||||
public void Handle(EpisodeFolderCreatedEvent message)
|
||||
{
|
||||
var series = message.Series;
|
||||
|
|
|
@ -116,6 +116,12 @@ namespace NzbDrone.Core.MediaFiles
|
|||
|
||||
_diskTransferService.TransferFile(movieFilePath, destinationFilePath, mode);
|
||||
|
||||
var oldMoviePath = new OsPath(movieFilePath).Directory.FullPath.TrimEnd(Path.DirectorySeparatorChar);
|
||||
|
||||
|
||||
var newMoviePath = new OsPath(destinationFilePath).Directory.FullPath.TrimEnd(Path.DirectorySeparatorChar);
|
||||
movie.Path = newMoviePath;
|
||||
|
||||
movieFile.RelativePath = movie.Path.GetRelativePath(destinationFilePath);
|
||||
|
||||
_updateMovieFileService.ChangeFileDateForFile(movieFile, movie);
|
||||
|
@ -132,6 +138,8 @@ namespace NzbDrone.Core.MediaFiles
|
|||
|
||||
_mediaFileAttributeService.SetFilePermissions(destinationFilePath);
|
||||
|
||||
_diskProvider.DeleteFolder(oldMoviePath, true);
|
||||
|
||||
return movieFile;
|
||||
}
|
||||
|
||||
|
@ -144,6 +152,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
{
|
||||
var movieFolder = Path.GetDirectoryName(filePath);
|
||||
var rootFolder = new OsPath(movieFolder).Directory.FullPath;
|
||||
var fileName = Path.GetFileName(filePath);
|
||||
|
||||
if (!_diskProvider.FolderExists(rootFolder))
|
||||
{
|
||||
|
@ -156,7 +165,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
if (!_diskProvider.FolderExists(movieFolder))
|
||||
{
|
||||
CreateFolder(movieFolder);
|
||||
newEvent.SeriesFolder = movieFolder;
|
||||
newEvent.MovieFolder = movieFolder;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -94,6 +95,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
_movieFileMover.MoveMovieFile(movieFile, movie);
|
||||
|
||||
_mediaFileService.Update(movieFile);
|
||||
_movieService.UpdateMovie(movie);
|
||||
renamed.Add(movieFile);
|
||||
|
||||
_logger.Debug("Renamed movie file: {0}", movieFile);
|
||||
|
@ -122,7 +124,7 @@ namespace NzbDrone.Core.MediaFiles
|
|||
|
||||
public void Execute(RenameMovieCommand message)
|
||||
{
|
||||
_logger.Debug("Renaming all files for selected movie");
|
||||
_logger.Debug("Renaming all files for selected movies");
|
||||
var moviesToRename = _movieService.GetMovies(message.MovieIds);
|
||||
|
||||
foreach(var movie in moviesToRename)
|
||||
|
|
|
@ -158,12 +158,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);
|
||||
|
@ -190,11 +189,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;
|
||||
|
|
|
@ -74,6 +74,19 @@ module.exports = Marionette.Layout.extend({
|
|||
var file = movie.model.get("movieFile");
|
||||
this.filesCollection.add(file);
|
||||
//this.listenTo(this.releaseCollection, 'sync', this._showSearchResults);
|
||||
|
||||
this.listenTo(this.model, 'change', function(model, options) {
|
||||
if (options && options.changeSource === 'signalr') {
|
||||
this._refresh(movie);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_refresh : function(movie) {
|
||||
this.filesCollection = new FilesCollection();
|
||||
var file = movie.model.get("movieFile");
|
||||
this.filesCollection.add(file);
|
||||
this.onShow();
|
||||
},
|
||||
|
||||
onShow : function() {
|
||||
|
|
|
@ -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')
|
||||
};
|
||||
},
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{{#if rename}}
|
||||
Folder Naming pattern: {{folderFormat}}<br>
|
||||
Naming pattern: {{format}}
|
||||
{{/if}}
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue