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)
{
var series = message.Series;

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

@ -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));

@ -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)
{
_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))

@ -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
//};
}
}
}

@ -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;

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

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

@ -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);
}
}
}
}

@ -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();
}

@ -15,7 +15,7 @@
<i class="icon-sonarr-refresh icon-can-spin" title="Update movie info and scan disk"/>
</div>
<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 class="x-search">
<i class="icon-sonarr-search" title="Search for movie"/>

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

Loading…
Cancel
Save