Taking another pass at organization/renaming

Works once in a while
pull/2/head
Tim Turner 8 years ago
parent 4c9abe3d84
commit 74c5664a7f

@ -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) public void Handle(EpisodeFolderCreatedEvent message)
{ {
var series = message.Series; var series = message.Series;

@ -8,7 +8,7 @@ namespace NzbDrone.Core.MediaFiles.Commands
{ {
public class RenameMovieCommand : Command public class RenameMovieCommand : Command
{ {
public int MovieId { get; set; } public List<int> MovieIds { get; set; }
public override bool SendUpdatesToClient => true; public override bool SendUpdatesToClient => true;

@ -38,6 +38,7 @@ namespace NzbDrone.Core.MediaFiles
private readonly IDiskProvider _diskProvider; private readonly IDiskProvider _diskProvider;
private readonly IMakeImportDecision _importDecisionMaker; private readonly IMakeImportDecision _importDecisionMaker;
private readonly IImportApprovedEpisodes _importApprovedEpisodes; private readonly IImportApprovedEpisodes _importApprovedEpisodes;
private readonly IImportApprovedMovie _importApprovedMovies;
private readonly IConfigService _configService; private readonly IConfigService _configService;
private readonly ISeriesService _seriesService; private readonly ISeriesService _seriesService;
private readonly IMediaFileTableCleanupService _mediaFileTableCleanupService; private readonly IMediaFileTableCleanupService _mediaFileTableCleanupService;
@ -48,6 +49,7 @@ namespace NzbDrone.Core.MediaFiles
public DiskScanService(IDiskProvider diskProvider, public DiskScanService(IDiskProvider diskProvider,
IMakeImportDecision importDecisionMaker, IMakeImportDecision importDecisionMaker,
IImportApprovedEpisodes importApprovedEpisodes, IImportApprovedEpisodes importApprovedEpisodes,
IImportApprovedMovie importApprovedMovies,
IConfigService configService, IConfigService configService,
ISeriesService seriesService, ISeriesService seriesService,
IMediaFileTableCleanupService mediaFileTableCleanupService, IMediaFileTableCleanupService mediaFileTableCleanupService,
@ -58,6 +60,7 @@ namespace NzbDrone.Core.MediaFiles
_diskProvider = diskProvider; _diskProvider = diskProvider;
_importDecisionMaker = importDecisionMaker; _importDecisionMaker = importDecisionMaker;
_importApprovedEpisodes = importApprovedEpisodes; _importApprovedEpisodes = importApprovedEpisodes;
_importApprovedMovies = importApprovedMovies;
_configService = configService; _configService = configService;
_seriesService = seriesService; _seriesService = seriesService;
_mediaFileTableCleanupService = mediaFileTableCleanupService; _mediaFileTableCleanupService = mediaFileTableCleanupService;
@ -179,7 +182,8 @@ namespace NzbDrone.Core.MediaFiles
decisionsStopwatch.Stop(); decisionsStopwatch.Stop();
_logger.Trace("Import decisions complete for: {0} [{1}]", movie, decisionsStopwatch.Elapsed); _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); _logger.Info("Completed scanning disk for {0}", movie.Title);
_eventAggregator.PublishEvent(new MovieScannedEvent(movie)); _eventAggregator.PublishEvent(new MovieScannedEvent(movie));

@ -47,6 +47,8 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
public List<ImportResult> Import(List<ImportDecision> decisions, bool newDownload, DownloadClientItem downloadClientItem = null, ImportMode importMode = ImportMode.Auto) public List<ImportResult> Import(List<ImportDecision> decisions, bool newDownload, DownloadClientItem downloadClientItem = null, ImportMode importMode = ImportMode.Auto)
{ {
_logger.Debug("Decisions: {0}", decisions.Count);
var qualifiedImports = decisions.Where(c => c.Approved) var qualifiedImports = decisions.Where(c => c.Approved)
.GroupBy(c => c.LocalMovie.Movie.Id, (i, s) => s .GroupBy(c => c.LocalMovie.Movie.Id, (i, s) => s
.OrderByDescending(c => c.LocalMovie.Quality, new QualityModelComparer(s.First().LocalMovie.Movie.Profile)) .OrderByDescending(c => c.LocalMovie.Quality, new QualityModelComparer(s.First().LocalMovie.Movie.Profile))

@ -24,15 +24,15 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
{ {
LocalMovie = localMovie; LocalMovie = localMovie;
Rejections = rejections.ToList(); Rejections = rejections.ToList();
LocalMovie = new LocalMovie //LocalMovie = new LocalMovie
{ //{
Quality = localMovie.Quality, // Quality = localMovie.Quality,
ExistingFile = localMovie.ExistingFile, // ExistingFile = localMovie.ExistingFile,
MediaInfo = localMovie.MediaInfo, // MediaInfo = localMovie.MediaInfo,
ParsedMovieInfo = localMovie.ParsedMovieInfo, // ParsedMovieInfo = localMovie.ParsedMovieInfo,
Path = localMovie.Path, // Path = localMovie.Path,
Size = localMovie.Size // Size = localMovie.Size
}; //};
} }
} }
} }

@ -123,18 +123,18 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
else else
{ {
var localEpisode = new LocalEpisode(); localMovie = new LocalMovie();
localEpisode.Path = file; 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) catch (Exception e)
{ {
_logger.Error(e, "Couldn't import file. " + file); _logger.Error(e, "Couldn't import file. " + file);
var localEpisode = new LocalEpisode { Path = file }; var localMovie = new LocalMovie { Path = file };
decision = new ImportDecision(localEpisode, new Rejection("Unexpected error processing file")); decision = new ImportDecision(localMovie, new Rejection("Unexpected error processing file"));
} }
//LocalMovie nullMovie = null; //LocalMovie nullMovie = null;

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Messaging.Events;

@ -27,6 +27,8 @@ namespace NzbDrone.Core.MediaFiles
List<string> FilterExistingFiles(List<string> files, Movie movie); List<string> FilterExistingFiles(List<string> files, Movie movie);
EpisodeFile Get(int id); EpisodeFile Get(int id);
List<EpisodeFile> Get(IEnumerable<int> ids); List<EpisodeFile> Get(IEnumerable<int> ids);
List<MovieFile> GetMovies(IEnumerable<int> ids);
//List<MovieFile> Get(IEnumerable<int> ids); //List<MovieFile> Get(IEnumerable<int> ids);
} }
@ -125,10 +127,10 @@ namespace NzbDrone.Core.MediaFiles
return _mediaFileRepository.Get(ids).ToList(); return _mediaFileRepository.Get(ids).ToList();
} }
//public List<MovieFile> Get(IEnumerable<int> ids) public List<MovieFile> GetMovies(IEnumerable<int> ids)
//{ {
// return _mediaFileRepository.Get(ids).ToList(); return _movieFileRepository.Get(ids).ToList();
//} }
public void HandleAsync(SeriesDeletedEvent message) public void HandleAsync(SeriesDeletedEvent message)
{ {

@ -110,25 +110,29 @@ namespace NzbDrone.Core.MediaFiles
} }
} }
//public void Execute(RenameMovieFilesCommand message) public void Execute(RenameMovieFilesCommand message)
//{ {
// var movie = _movieService.GetMovie(message.MovieId); var movie = _movieService.GetMovie(message.MovieId);
// var movieFiles = _mediaFileService.Get(message.Files); var movieFiles = _mediaFileService.GetMovies(message.Files);
// _logger.ProgressInfo("Renaming {0} files for {1}", movieFiles.Count, movie.Title); _logger.ProgressInfo("Renaming {0} files for {1}", movieFiles.Count, movie.Title);
// RenameFiles(movieFiles, movie); RenameFiles(movieFiles, movie);
// _logger.ProgressInfo("Selected movie files renamed for {0}", movie.Title); _logger.ProgressInfo("Selected movie files renamed for {0}", movie.Title);
//} }
public void Execute(RenameMovieCommand message) public void Execute(RenameMovieCommand message)
{ {
_logger.Debug("Renaming all files for selected movie"); _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); foreach(var movie in moviesToRename)
_logger.ProgressInfo("Renaming all files in movie: {0}", movieToRename.Title); {
RenameFiles(movieFiles, movieToRename); var movieFiles = _mediaFileService.GetFilesByMovie(movie.Id);
_logger.ProgressInfo("All movie files renamed for {0}", movieToRename.Title); _logger.ProgressInfo("Renaming all files in movie: {0}", movie.Title);
RenameFiles(movieFiles, movie);
_logger.ProgressInfo("All movie files renamed for {0}", movie.Title);
}
} }
} }
} }

@ -97,7 +97,7 @@ module.exports = Marionette.Layout.extend({
CommandController.bindToCommand({ CommandController.bindToCommand({
element : this.ui.rename, element : this.ui.rename,
command : { command : {
name : 'renameFiles', name : 'renameMovieFiles',
movieId : this.model.id, movieId : this.model.id,
seasonNumber : -1 seasonNumber : -1
} }
@ -237,7 +237,7 @@ module.exports = Marionette.Layout.extend({
}, },
_commandComplete : function(options) { _commandComplete : function(options) {
if (options.command.get('name') === 'renamefiles') { if (options.command.get('name') === 'renameMoviefiles') {
if (options.command.get('moviesId') === this.model.get('id')) { if (options.command.get('moviesId') === this.model.get('id')) {
this._refresh(); this._refresh();
} }

@ -15,7 +15,7 @@
<i class="icon-sonarr-refresh icon-can-spin" title="Update movie info and scan disk"/> <i class="icon-sonarr-refresh icon-can-spin" title="Update movie info and scan disk"/>
</div> </div>
<div class="x-rename"> <div class="x-rename">
<i class="icon-sonarr-rename" title="Preview rename for all episodes"/> <i class="icon-sonarr-rename" title="Preview rename for movie"/>
</div> </div>
<div class="x-search"> <div class="x-search">
<i class="icon-sonarr-search" title="Search for movie"/> <i class="icon-sonarr-search" title="Search for movie"/>

@ -89,8 +89,8 @@ module.exports = Marionette.Layout.extend({
// seasonNumber : -1, // seasonNumber : -1,
// files : files // files : files
// }); // });
CommandController.Execute('renameFiles', { CommandController.Execute('renameMovieFiles', {
name : 'renameFiles', name : 'renameMovieFiles',
movieId : this.model.id, movieId : this.model.id,
files : files files : files
}); });

Loading…
Cancel
Save