diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs b/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs index 70e53b369..02119e7f6 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/DownloadMonitoringService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using NLog; @@ -113,24 +113,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 0626f0f25..30bdc1e83 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.History; using NzbDrone.Core.History; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser; +using NzbDrone.Core.Tv; using NzbDrone.Core.Tv.Events; namespace NzbDrone.Core.Download.TrackedDownloads @@ -141,11 +142,15 @@ namespace NzbDrone.Core.Download.TrackedDownloads { // Try parsing the original source title and if that fails, try parsing it as a special // TODO: Pass the TVDB ID and TVRage IDs in as well so we have a better chance for finding the item - parsedEpisodeInfo = Parser.Parser.ParseTitle(firstHistoryItem.SourceTitle) ?? _parsingService.ParseSpecialEpisodeTitle(parsedEpisodeInfo, firstHistoryItem.SourceTitle, 0, 0); + parsedEpisodeInfo = Parser.Parser.ParseTitle(firstHistoryItem.SourceTitle) ?? + _parsingService.ParseSpecialEpisodeTitle(parsedEpisodeInfo, firstHistoryItem.SourceTitle, 0, 0); if (parsedEpisodeInfo != null) { - trackedDownload.RemoteEpisode = _parsingService.Map(parsedEpisodeInfo, firstHistoryItem.SeriesId, historyItems.Where(v => v.EventType == EpisodeHistoryEventType.Grabbed).Select(h => h.EpisodeId).Distinct()); + trackedDownload.RemoteEpisode = _parsingService.Map(parsedEpisodeInfo, + firstHistoryItem.SeriesId, + historyItems.Where(v => v.EventType == EpisodeHistoryEventType.Grabbed) + .Select(h => h.EpisodeId).Distinct()); } } } @@ -162,10 +167,17 @@ namespace NzbDrone.Core.Download.TrackedDownloads _logger.Trace("No Episode found for download '{0}'", trackedDownload.DownloadItem.Title); } } + catch (MultipleSeriesFoundException e) + { + _logger.Debug(e, "Found multiple series for " + downloadItem.Title); + + trackedDownload.Warn("Unable to import automatically, found multiple series: {0}", string.Join(", ", e.Series)); + } catch (Exception e) { _logger.Debug(e, "Failed to find episode for " + downloadItem.Title); - return null; + + trackedDownload.Warn("Unable to parse episodes from title"); } LogItemChange(trackedDownload, existingItem?.DownloadItem, trackedDownload.DownloadItem); diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportService.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportService.cs index 5696c10ae..ed5e33849 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportService.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportService.cs @@ -334,6 +334,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual Path = file, RelativePath = rootFolder.GetRelativePath(file), Name = Path.GetFileNameWithoutExtension(file), + Size = _diskProvider.GetFileSize(file), Rejections = new List() }; } diff --git a/src/NzbDrone.Core/Tv/MultipleSeriesFoundException.cs b/src/NzbDrone.Core/Tv/MultipleSeriesFoundException.cs index 37e13ecd7..92e2d88c4 100644 --- a/src/NzbDrone.Core/Tv/MultipleSeriesFoundException.cs +++ b/src/NzbDrone.Core/Tv/MultipleSeriesFoundException.cs @@ -1,12 +1,16 @@ -using NzbDrone.Common.Exceptions; +using System.Collections.Generic; +using NzbDrone.Common.Exceptions; namespace NzbDrone.Core.Tv { public class MultipleSeriesFoundException : NzbDroneException { - public MultipleSeriesFoundException(string message, params object[] args) + public List Series { get; set; } + + public MultipleSeriesFoundException(List series, string message, params object[] args) : base(message, args) { + Series = series; } } } diff --git a/src/NzbDrone.Core/Tv/SeriesRepository.cs b/src/NzbDrone.Core/Tv/SeriesRepository.cs index 045f76281..46ff5d506 100644 --- a/src/NzbDrone.Core/Tv/SeriesRepository.cs +++ b/src/NzbDrone.Core/Tv/SeriesRepository.cs @@ -103,7 +103,7 @@ namespace NzbDrone.Core.Tv return series.First(); } - throw new MultipleSeriesFoundException("Expected one series, but found {0}. Matching series: {1}", series.Count, string.Join(",", series)); + throw new MultipleSeriesFoundException(series, "Expected one series, but found {0}. Matching series: {1}", series.Count, string.Join(", ", series)); } } }