diff --git a/src/NzbDrone.Core/Extras/ExtraService.cs b/src/NzbDrone.Core/Extras/ExtraService.cs index 5906de176..012e8f921 100644 --- a/src/NzbDrone.Core/Extras/ExtraService.cs +++ b/src/NzbDrone.Core/Extras/ExtraService.cs @@ -111,6 +111,18 @@ namespace NzbDrone.Core.Extras } } + //TODO: Implementing this will fix a lot of our warning exceptions + //public void Handle(MediaCoversUpdatedEvent message) + //{ + // var movie = message.Movie; + // var movieFiles = GetMovieFiles(movie.Id); + + // foreach (var extraFileManager in _extraFileManagers) + // { + // extraFileManager.CreateAfterMovieScan(movie, movieFiles); + // } + //} + public void Handle(EpisodeFolderCreatedEvent message) { var series = message.Series; diff --git a/src/NzbDrone.Core/MediaFiles/Commands/RenameMovieCommand.cs b/src/NzbDrone.Core/MediaFiles/Commands/RenameMovieCommand.cs index fad7b76c7..012a835f8 100644 --- a/src/NzbDrone.Core/MediaFiles/Commands/RenameMovieCommand.cs +++ b/src/NzbDrone.Core/MediaFiles/Commands/RenameMovieCommand.cs @@ -8,7 +8,7 @@ namespace NzbDrone.Core.MediaFiles.Commands { public class RenameMovieCommand : Command { - public int MovieId { get; set; } + public List MovieIds { get; set; } public override bool SendUpdatesToClient => true; diff --git a/src/NzbDrone.Core/MediaFiles/DiskScanService.cs b/src/NzbDrone.Core/MediaFiles/DiskScanService.cs index 916c5681b..d4d2ec71c 100644 --- a/src/NzbDrone.Core/MediaFiles/DiskScanService.cs +++ b/src/NzbDrone.Core/MediaFiles/DiskScanService.cs @@ -38,6 +38,7 @@ namespace NzbDrone.Core.MediaFiles private readonly IDiskProvider _diskProvider; private readonly IMakeImportDecision _importDecisionMaker; private readonly IImportApprovedEpisodes _importApprovedEpisodes; + private readonly IImportApprovedMovie _importApprovedMovies; private readonly IConfigService _configService; private readonly ISeriesService _seriesService; private readonly IMediaFileTableCleanupService _mediaFileTableCleanupService; @@ -48,6 +49,7 @@ namespace NzbDrone.Core.MediaFiles public DiskScanService(IDiskProvider diskProvider, IMakeImportDecision importDecisionMaker, IImportApprovedEpisodes importApprovedEpisodes, + IImportApprovedMovie importApprovedMovies, IConfigService configService, ISeriesService seriesService, IMediaFileTableCleanupService mediaFileTableCleanupService, @@ -58,6 +60,7 @@ namespace NzbDrone.Core.MediaFiles _diskProvider = diskProvider; _importDecisionMaker = importDecisionMaker; _importApprovedEpisodes = importApprovedEpisodes; + _importApprovedMovies = importApprovedMovies; _configService = configService; _seriesService = seriesService; _mediaFileTableCleanupService = mediaFileTableCleanupService; @@ -179,7 +182,8 @@ namespace NzbDrone.Core.MediaFiles decisionsStopwatch.Stop(); _logger.Trace("Import decisions complete for: {0} [{1}]", movie, decisionsStopwatch.Elapsed); - _importApprovedEpisodes.Import(decisions, false); + //_importApprovedEpisodes.Import(decisions, false); + _importApprovedMovies.Import(decisions, false); _logger.Info("Completed scanning disk for {0}", movie.Title); _eventAggregator.PublishEvent(new MovieScannedEvent(movie)); diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedMovie.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedMovie.cs index 619afe3ba..128ca64f9 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedMovie.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedMovie.cs @@ -47,6 +47,8 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport public List Import(List decisions, bool newDownload, DownloadClientItem downloadClientItem = null, ImportMode importMode = ImportMode.Auto) { + _logger.Debug("Decisions: {0}", decisions.Count); + var qualifiedImports = decisions.Where(c => c.Approved) .GroupBy(c => c.LocalMovie.Movie.Id, (i, s) => s .OrderByDescending(c => c.LocalMovie.Quality, new QualityModelComparer(s.First().LocalMovie.Movie.Profile)) diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecision.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecision.cs index 9ba0cc706..406866b65 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecision.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecision.cs @@ -24,15 +24,15 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport { LocalMovie = localMovie; Rejections = rejections.ToList(); - LocalMovie = new LocalMovie - { - Quality = localMovie.Quality, - ExistingFile = localMovie.ExistingFile, - MediaInfo = localMovie.MediaInfo, - ParsedMovieInfo = localMovie.ParsedMovieInfo, - Path = localMovie.Path, - Size = localMovie.Size - }; + //LocalMovie = new LocalMovie + //{ + // Quality = localMovie.Quality, + // ExistingFile = localMovie.ExistingFile, + // MediaInfo = localMovie.MediaInfo, + // ParsedMovieInfo = localMovie.ParsedMovieInfo, + // Path = localMovie.Path, + // Size = localMovie.Size + //}; } } } diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs index 5718382b7..9d4abe042 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs @@ -123,18 +123,18 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport else { - var localEpisode = new LocalEpisode(); - localEpisode.Path = file; + localMovie = new LocalMovie(); + localMovie.Path = file; - decision = new ImportDecision(localEpisode, new Rejection("Unable to parse file")); + decision = new ImportDecision(localMovie, new Rejection("Unable to parse file")); } } catch (Exception e) { _logger.Error(e, "Couldn't import file. " + file); - var localEpisode = new LocalEpisode { Path = file }; - decision = new ImportDecision(localEpisode, new Rejection("Unexpected error processing file")); + var localMovie = new LocalMovie { Path = file }; + decision = new ImportDecision(localMovie, new Rejection("Unexpected error processing file")); } //LocalMovie nullMovie = null; diff --git a/src/NzbDrone.Core/MediaFiles/MediaFileRepository.cs b/src/NzbDrone.Core/MediaFiles/MediaFileRepository.cs index 206942356..3cc90af0f 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaFileRepository.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaFileRepository.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using NzbDrone.Core.Datastore; using NzbDrone.Core.Messaging.Events; diff --git a/src/NzbDrone.Core/MediaFiles/MediaFileService.cs b/src/NzbDrone.Core/MediaFiles/MediaFileService.cs index 4a2dd195c..0587bb793 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaFileService.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaFileService.cs @@ -27,6 +27,8 @@ namespace NzbDrone.Core.MediaFiles List FilterExistingFiles(List files, Movie movie); EpisodeFile Get(int id); List Get(IEnumerable ids); + List GetMovies(IEnumerable ids); + //List Get(IEnumerable ids); } @@ -125,10 +127,10 @@ namespace NzbDrone.Core.MediaFiles return _mediaFileRepository.Get(ids).ToList(); } - //public List Get(IEnumerable ids) - //{ - // return _mediaFileRepository.Get(ids).ToList(); - //} + public List GetMovies(IEnumerable ids) + { + return _movieFileRepository.Get(ids).ToList(); + } public void HandleAsync(SeriesDeletedEvent message) { diff --git a/src/NzbDrone.Core/MediaFiles/RenameMovieFileService.cs b/src/NzbDrone.Core/MediaFiles/RenameMovieFileService.cs index f5ad3bf50..cb4382a66 100644 --- a/src/NzbDrone.Core/MediaFiles/RenameMovieFileService.cs +++ b/src/NzbDrone.Core/MediaFiles/RenameMovieFileService.cs @@ -110,25 +110,29 @@ namespace NzbDrone.Core.MediaFiles } } - //public void Execute(RenameMovieFilesCommand message) - //{ - // var movie = _movieService.GetMovie(message.MovieId); - // var movieFiles = _mediaFileService.Get(message.Files); + public void Execute(RenameMovieFilesCommand message) + { + var movie = _movieService.GetMovie(message.MovieId); + var movieFiles = _mediaFileService.GetMovies(message.Files); - // _logger.ProgressInfo("Renaming {0} files for {1}", movieFiles.Count, movie.Title); - // RenameFiles(movieFiles, movie); - // _logger.ProgressInfo("Selected movie files renamed for {0}", movie.Title); - //} + _logger.ProgressInfo("Renaming {0} files for {1}", movieFiles.Count, movie.Title); + RenameFiles(movieFiles, movie); + _logger.ProgressInfo("Selected movie files renamed for {0}", movie.Title); + } public void Execute(RenameMovieCommand message) { _logger.Debug("Renaming all files for selected movie"); - var movieToRename = _movieService.GetMovie(message.MovieId); + var moviesToRename = _movieService.GetMovies(message.MovieIds); - var movieFiles = _mediaFileService.GetFilesByMovie(movieToRename.Id); - _logger.ProgressInfo("Renaming all files in movie: {0}", movieToRename.Title); - RenameFiles(movieFiles, movieToRename); - _logger.ProgressInfo("All movie files renamed for {0}", movieToRename.Title); + foreach(var movie in moviesToRename) + { + var movieFiles = _mediaFileService.GetFilesByMovie(movie.Id); + _logger.ProgressInfo("Renaming all files in movie: {0}", movie.Title); + RenameFiles(movieFiles, movie); + _logger.ProgressInfo("All movie files renamed for {0}", movie.Title); + } + } } } diff --git a/src/UI/Movies/Details/MoviesDetailsLayout.js b/src/UI/Movies/Details/MoviesDetailsLayout.js index a38793aa4..da92d260a 100644 --- a/src/UI/Movies/Details/MoviesDetailsLayout.js +++ b/src/UI/Movies/Details/MoviesDetailsLayout.js @@ -97,7 +97,7 @@ module.exports = Marionette.Layout.extend({ CommandController.bindToCommand({ element : this.ui.rename, command : { - name : 'renameFiles', + name : 'renameMovieFiles', movieId : this.model.id, seasonNumber : -1 } @@ -237,7 +237,7 @@ module.exports = Marionette.Layout.extend({ }, _commandComplete : function(options) { - if (options.command.get('name') === 'renamefiles') { + if (options.command.get('name') === 'renameMoviefiles') { if (options.command.get('moviesId') === this.model.get('id')) { this._refresh(); } diff --git a/src/UI/Movies/Details/MoviesDetailsTemplate.hbs b/src/UI/Movies/Details/MoviesDetailsTemplate.hbs index 9c3f6675a..8516e5665 100644 --- a/src/UI/Movies/Details/MoviesDetailsTemplate.hbs +++ b/src/UI/Movies/Details/MoviesDetailsTemplate.hbs @@ -15,7 +15,7 @@
- +