From 48bf793746b046d0f956b314bebc57761937cc8c Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Tue, 16 Jul 2013 17:53:33 -0700 Subject: [PATCH] updated around import episodes, update series. --- .../MediaFiles/DownloadedEpisodesImportService.cs | 6 +++--- .../MediaFiles/EpisodeImport/ImportDecisionMaker.cs | 2 +- NzbDrone.Core/Tv/Episode.cs | 8 +++++++- NzbDrone.Core/Tv/RefreshSeriesService.cs | 12 ++++-------- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs b/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs index dd6bb58f4..df6346736 100644 --- a/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs +++ b/NzbDrone.Core/MediaFiles/DownloadedEpisodesImportService.cs @@ -89,7 +89,7 @@ private void ProcessDownloadedEpisodesFolder() if (series == null) { - _logger.Trace("Unknown Series for file: {0}", videoFile); + _logger.Debug("Unknown Series for file: {0}", videoFile); } ProcessVideoFile(videoFile, series); @@ -107,7 +107,7 @@ private void ProcessSubFolder(DirectoryInfo subfolderInfo) if (series == null) { - _logger.Trace("Unknown Series {0}", subfolderInfo.Name); + _logger.Debug("Unknown Series {0}", subfolderInfo.Name); return; } @@ -120,7 +120,7 @@ private void ProcessVideoFile(string videoFile, Series series) { if (_diskProvider.IsFileLocked(new FileInfo(videoFile))) { - _logger.Trace("[{0}] is currently locked by another process, skipping", videoFile); + _logger.Debug("[{0}] is currently locked by another process, skipping", videoFile); return; } diff --git a/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs b/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs index 19e31bfab..d2f1164bc 100644 --- a/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs +++ b/NzbDrone.Core/MediaFiles/EpisodeImport/ImportDecisionMaker.cs @@ -67,7 +67,7 @@ private IEnumerable GetDecisions(IEnumerable videoFiles, } catch (Exception e) { - _logger.ErrorException("Couldn't process report.", e); + _logger.ErrorException("Couldn't import file." + file, e); } if (decision != null) diff --git a/NzbDrone.Core/Tv/Episode.cs b/NzbDrone.Core/Tv/Episode.cs index fb0e04682..09be230e4 100644 --- a/NzbDrone.Core/Tv/Episode.cs +++ b/NzbDrone.Core/Tv/Episode.cs @@ -2,6 +2,7 @@ using Marr.Data; using NzbDrone.Core.Datastore; using NzbDrone.Core.MediaFiles; +using NzbDrone.Common; namespace NzbDrone.Core.Tv @@ -25,12 +26,17 @@ public class Episode : ModelBase public String SeriesTitle { get; private set; } public LazyLoaded EpisodeFile { get; set; } - + public Series Series { get; set; } public Boolean HasFile { get { return EpisodeFileId > 0; } } + + public override string ToString() + { + return string.Format("[0]{1}", TvDbEpisodeId, Title.NullSafe()); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Tv/RefreshSeriesService.cs b/NzbDrone.Core/Tv/RefreshSeriesService.cs index e1ca59db5..94381c8bb 100644 --- a/NzbDrone.Core/Tv/RefreshSeriesService.cs +++ b/NzbDrone.Core/Tv/RefreshSeriesService.cs @@ -100,12 +100,9 @@ private void RefreshEpisodeInfo(Series series, IEnumerable remoteEpisod { try { - var episodeToUpdate = seriesEpisodes.SingleOrDefault(e => e.TvDbEpisodeId == episode.TvDbEpisodeId); + var episodeToUpdate = seriesEpisodes.SingleOrDefault(e => e.TvDbEpisodeId == episode.TvDbEpisodeId) ?? + seriesEpisodes.SingleOrDefault(e => e.SeasonNumber == episode.SeasonNumber && e.EpisodeNumber == episode.EpisodeNumber); - if (episodeToUpdate == null) - { - episodeToUpdate = seriesEpisodes.SingleOrDefault(e => e.SeasonNumber == episode.SeasonNumber && e.EpisodeNumber == episode.EpisodeNumber); - } if (episodeToUpdate == null) { episodeToUpdate = new Episode(); @@ -119,8 +116,7 @@ private void RefreshEpisodeInfo(Series series, IEnumerable remoteEpisod else { var season = seasons.FirstOrDefault(c => c.SeasonNumber == episode.SeasonNumber); - - episodeToUpdate.Monitored = season != null ? season.Monitored : true; + episodeToUpdate.Monitored = season == null || season.Monitored; } } else @@ -148,7 +144,7 @@ private void RefreshEpisodeInfo(Series series, IEnumerable remoteEpisod } catch (Exception e) { - _logger.FatalException(String.Format("An error has occurred while updating episode info for series {0}", series), e); + _logger.FatalException(String.Format("An error has occurred while updating episode info for series {0}. {1}", series, episode), e); failCount++; } }