diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs b/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs index ebaa0efa7..2794e6da2 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs @@ -112,24 +112,26 @@ namespace NzbDrone.Core.Download.TrackedDownloads private TrackedDownload ProcessClientItem(IDownloadClient downloadClient, DownloadClientItem downloadItem) { + TrackedDownload trackedDownload = null; + try { - var trackedDownload = _trackedDownloadService.TrackDownload((DownloadClientDefinition)downloadClient.Definition, downloadItem); + trackedDownload = + _trackedDownloadService.TrackDownload((DownloadClientDefinition)downloadClient.Definition, + downloadItem); if (trackedDownload != null && trackedDownload.State == TrackedDownloadState.Downloading) { _failedDownloadService.Check(trackedDownload); _completedDownloadService.Check(trackedDownload); } - - return trackedDownload; } catch (Exception e) { _logger.Error(e, "Couldn't process tracked download {0}", downloadItem.Title); } - return null; + return trackedDownload; } private bool DownloadIsTrackable(TrackedDownload trackedDownload) diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs index 15ee14cc0..a883d8ed7 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs @@ -10,6 +10,7 @@ using NzbDrone.Core.Download.Aggregation; using NzbDrone.Core.Download.History; using NzbDrone.Core.History; using NzbDrone.Core.Messaging.Events; +using NzbDrone.Core.Movies; using NzbDrone.Core.Movies.Events; using NzbDrone.Core.Parser; @@ -145,11 +146,12 @@ namespace NzbDrone.Core.Download.TrackedDownloads trackedDownload.RemoteMovie == null || trackedDownload.RemoteMovie.Movie == null) { - parsedMovieInfo = _parsingService.ParseMovieInfo(firstHistoryItem.SourceTitle, new List { grabbedHistoryItem }); + parsedMovieInfo = Parser.Parser.ParseMovieTitle(firstHistoryItem.SourceTitle); if (parsedMovieInfo != null) { - trackedDownload.RemoteMovie = _parsingService.Map(parsedMovieInfo, "", null); + trackedDownload.RemoteMovie = _parsingService.Map(parsedMovieInfo, + firstHistoryItem.MovieId); } } } @@ -166,6 +168,12 @@ namespace NzbDrone.Core.Download.TrackedDownloads _logger.Trace("No Movie found for download '{0}'", trackedDownload.DownloadItem.Title); } } + catch (MultipleMoviesFoundException e) + { + _logger.Debug(e, "Found multiple movies for " + downloadItem.Title); + + trackedDownload.Warn("Unable to import automatically, found multiple movies: {0}", string.Join(", ", e.Movies)); + } catch (Exception e) { _logger.Debug(e, "Failed to find movie for " + downloadItem.Title); diff --git a/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs index 3d94dbb65..41d31d34a 100644 --- a/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs +++ b/src/NzbDrone.Core/MediaFiles/MovieImport/Manual/ManualImportService.cs @@ -255,6 +255,7 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Manual Path = file, RelativePath = rootFolder.GetRelativePath(file), Name = Path.GetFileNameWithoutExtension(file), + Size = _diskProvider.GetFileSize(file), Rejections = new List() }; } diff --git a/src/NzbDrone.Core/Movies/MovieService.cs b/src/NzbDrone.Core/Movies/MovieService.cs index bfce2f4f4..784602e16 100644 --- a/src/NzbDrone.Core/Movies/MovieService.cs +++ b/src/NzbDrone.Core/Movies/MovieService.cs @@ -403,7 +403,7 @@ namespace NzbDrone.Core.Movies return movies.First(); } - throw new MultipleMoviesFoundException("Expected one movie, but found {0}. Matching movies: {1}", movies.Count, string.Join(",", movies)); + throw new MultipleMoviesFoundException(movies, "Expected one movie, but found {0}. Matching movies: {1}", movies.Count, string.Join(",", movies)); } public void Handle(MovieFileAddedEvent message) diff --git a/src/NzbDrone.Core/Movies/MultipleMoviesFoundException.cs b/src/NzbDrone.Core/Movies/MultipleMoviesFoundException.cs index 1010c15d4..c3db6c660 100644 --- a/src/NzbDrone.Core/Movies/MultipleMoviesFoundException.cs +++ b/src/NzbDrone.Core/Movies/MultipleMoviesFoundException.cs @@ -1,12 +1,16 @@ +using System.Collections.Generic; using NzbDrone.Common.Exceptions; namespace NzbDrone.Core.Movies { public class MultipleMoviesFoundException : NzbDroneException { - public MultipleMoviesFoundException(string message, params object[] args) + public List Movies { get; set; } + + public MultipleMoviesFoundException(List movies, string message, params object[] args) : base(message, args) { + Movies = movies; } } } diff --git a/src/NzbDrone.Core/Parser/ParsingService.cs b/src/NzbDrone.Core/Parser/ParsingService.cs index 4daec475e..ac49d234f 100644 --- a/src/NzbDrone.Core/Parser/ParsingService.cs +++ b/src/NzbDrone.Core/Parser/ParsingService.cs @@ -14,6 +14,7 @@ namespace NzbDrone.Core.Parser { Movie GetMovie(string title); RemoteMovie Map(ParsedMovieInfo parsedMovieInfo, string imdbId, SearchCriteriaBase searchCriteria = null); + RemoteMovie Map(ParsedMovieInfo parsedMovieInfo, int movieId); ParsedMovieInfo ParseMovieInfo(string title, List helpers); ParsedMovieInfo ParseMinimalMovieInfo(string path, bool isDir = false); ParsedMovieInfo ParseMinimalPathMovieInfo(string path); @@ -98,6 +99,15 @@ namespace NzbDrone.Core.Parser return Map(parsedMovieInfo, imdbId, null, searchCriteria); } + public RemoteMovie Map(ParsedMovieInfo parsedMovieInfo, int movieId) + { + return new RemoteMovie + { + ParsedMovieInfo = parsedMovieInfo, + Movie = _movieService.GetMovie(movieId) + }; + } + public RemoteMovie Map(ParsedMovieInfo parsedMovieInfo, string imdbId, Movie movie, SearchCriteriaBase searchCriteria) { var remoteMovie = new RemoteMovie