Simply completed download service

pull/260/head
Devin Buhl 8 years ago
parent 4bb5857444
commit 6c413d83eb

@ -94,88 +94,20 @@ namespace NzbDrone.Core.Download
return; return;
} }
var series = _parsingService.GetSeries(trackedDownload.DownloadItem.Title);
if (series == null)
{
if (historyItem != null)
{
//series = _seriesService.GetSeries(historyItem.SeriesId);
}
if (series == null)
{
var movie = _parsingService.GetMovie(trackedDownload.DownloadItem.Title); var movie = _parsingService.GetMovie(trackedDownload.DownloadItem.Title);
if (movie == null) if (movie == null)
{ {
if (historyItem != null) if (historyItem != null)
{ {
movie = _movieService.GetMovie(historyItem.MovieId); movie = _movieService.GetMovie(historyItem.MovieId);
if (movie.MovieFile != null)
{
movie.MovieFile.LazyLoad();
if (movie.MovieFile.Value != null)
{
_logger.Debug("File Title: {0}, download item title: {1}", Parser.Parser.CleanSeriesTitle(movie.MovieFile.Value.RelativePath), Parser.Parser.CleanSeriesTitle(trackedDownload.DownloadItem.Title));
if (Parser.Parser.CleanSeriesTitle(movie.MovieFile.Value.RelativePath).Contains(Parser.Parser.CleanSeriesTitle(trackedDownload.DownloadItem.Title)))
{
trackedDownload.Warn("Seems like the movie already has a file associated with this download item. Maybe the History failed?");
return;
}
}
}
}
else
{
var parserResult = Parser.Parser.ParseMovieTitle(trackedDownload.DownloadItem.Title);
if (parserResult != null)
{
movie = _movieService.FindByTitle(parserResult.MovieTitle);
if (movie.MovieFile != null)
{
movie.MovieFile.LazyLoad();
if (movie.MovieFile.Value != null)
{
_logger.Debug("File Title: {0}, download item title: {1}", Parser.Parser.CleanSeriesTitle(movie.MovieFile.Value.RelativePath), Parser.Parser.CleanSeriesTitle(trackedDownload.DownloadItem.Title));
if (Parser.Parser.CleanSeriesTitle(movie.MovieFile.Value.RelativePath).Contains(Parser.Parser.CleanSeriesTitle(trackedDownload.DownloadItem.Title)))
{
trackedDownload.Warn("Seems like the movie already has a file associated with this download item. Maybe the History failed?");
return;
}
}
}
} }
}
if (movie == null) if (movie == null)
{ {
trackedDownload.Warn("Movie title mismatch, automatic import is not possible."); trackedDownload.Warn("Movie title mismatch, automatic import is not possible.");
return; return;
} }
} }
else
{
if (movie.MovieFile != null)
{
movie.MovieFile.LazyLoad();
if (movie.MovieFile.Value != null)
{
_logger.Debug("File Title: {0}, download item title: {1}", Parser.Parser.CleanSeriesTitle(movie.MovieFile.Value.RelativePath), Parser.Parser.CleanSeriesTitle(trackedDownload.DownloadItem.Title));
if (Parser.Parser.CleanSeriesTitle(movie.MovieFile.Value.RelativePath).Contains(Parser.Parser.CleanSeriesTitle(trackedDownload.DownloadItem.Title)))
{
trackedDownload.Warn("Seems like the movie already has a file associated with this download item. Maybe the History failed?");
return;
}
}
}
}
//trackedDownload.Warn("Series title mismatch, automatic import is not possible.");
//return;
}
}
} }
Import(trackedDownload); Import(trackedDownload);
@ -184,8 +116,6 @@ namespace NzbDrone.Core.Download
private void Import(TrackedDownload trackedDownload) private void Import(TrackedDownload trackedDownload)
{ {
var outputPath = trackedDownload.DownloadItem.OutputPath.FullPath; var outputPath = trackedDownload.DownloadItem.OutputPath.FullPath;
if (trackedDownload.RemoteMovie != null && trackedDownload.RemoteMovie.Movie != null)
{
var importResults = _downloadedMovieImportService.ProcessPath(outputPath, ImportMode.Auto, trackedDownload.RemoteMovie.Movie, trackedDownload.DownloadItem); var importResults = _downloadedMovieImportService.ProcessPath(outputPath, ImportMode.Auto, trackedDownload.RemoteMovie.Movie, trackedDownload.DownloadItem);
if (importResults.Empty()) if (importResults.Empty())
@ -211,34 +141,5 @@ namespace NzbDrone.Core.Download
trackedDownload.Warn(statusMessages); trackedDownload.Warn(statusMessages);
} }
} }
else if (trackedDownload.RemoteEpisode != null && trackedDownload.RemoteEpisode.Series != null)
{
var importResults = _downloadedEpisodesImportService.ProcessPath(outputPath, ImportMode.Auto, trackedDownload.RemoteEpisode.Series, trackedDownload.DownloadItem);
if (importResults.Empty())
{
trackedDownload.Warn("No files found are eligible for import in {0}", outputPath);
return;
}
if (importResults.Count(c => c.Result == ImportResultType.Imported) >= Math.Max(1, trackedDownload.RemoteEpisode.Episodes.Count))
{
trackedDownload.State = TrackedDownloadStage.Imported;
_eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload));
return;
}
if (importResults.Any(c => c.Result != ImportResultType.Imported))
{
var statusMessages = importResults
.Where(v => v.Result != ImportResultType.Imported)
.Select(v => new TrackedDownloadStatusMessage(Path.GetFileName(v.ImportDecision.LocalEpisode.Path), v.Errors))
.ToArray();
trackedDownload.Warn(statusMessages);
}
}
}
} }
} }

Loading…
Cancel
Save