From f2ce5bef184698ed15fb287fabdd955e88925292 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Tue, 17 May 2011 22:10:46 -0700 Subject: [PATCH] Super smart season ignore logic. ;) --- NzbDrone.Core/Providers/Jobs/NewSeriesUpdate.cs | 16 +++++++++++++++- NzbDrone.Core/Providers/MediaFileProvider.cs | 9 ++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/NzbDrone.Core/Providers/Jobs/NewSeriesUpdate.cs b/NzbDrone.Core/Providers/Jobs/NewSeriesUpdate.cs index ae78b62db..d0ad46c07 100644 --- a/NzbDrone.Core/Providers/Jobs/NewSeriesUpdate.cs +++ b/NzbDrone.Core/Providers/Jobs/NewSeriesUpdate.cs @@ -60,8 +60,22 @@ namespace NzbDrone.Core.Providers.Jobs notification.CurrentMessage = String.Format("Scanning disk for '{0}' files", updatedSeries.Title); _mediaFileProvider.Scan(_seriesProvider.GetSeries(updatedSeries.SeriesId)); - } + if (_mediaFileProvider.GetSeriesFiles(currentSeries.SeriesId).Count() != 0) + { + Logger.Debug("Looking for seasons to ignore"); + foreach (var season in updatedSeries.Seasons) + { + if (season.SeasonNumber != updatedSeries.Seasons.Max(s => s.SeasonNumber) && _mediaFileProvider.GetSeasonFiles(season.SeasonId).Count() == 0) + { + Logger.Info("Season {0} of {1} doesn't have any files on disk. season will not be monitored.", season.SeasonNumber, updatedSeries.Title); + season.Monitored = false; + _seasonProvider.SaveSeason(season); + } + } + } + + } catch (Exception e) { Logger.ErrorException(e.Message, e); diff --git a/NzbDrone.Core/Providers/MediaFileProvider.cs b/NzbDrone.Core/Providers/MediaFileProvider.cs index 32956d4e4..6f1046af2 100644 --- a/NzbDrone.Core/Providers/MediaFileProvider.cs +++ b/NzbDrone.Core/Providers/MediaFileProvider.cs @@ -182,11 +182,14 @@ namespace NzbDrone.Core.Providers return _repository.All().ToList(); } - public virtual List GetSeasonFiles(int seasonId) + public virtual IEnumerable GetSeasonFiles(int seasonId) { - var res = _seasonProvider.GetSeason(seasonId).Episodes.Where(c => c.EpisodeFile != null).Select(c => c.EpisodeFile); + return _seasonProvider.GetSeason(seasonId).Episodes.Where(c => c.EpisodeFile != null).Select(c => c.EpisodeFile); + } - return res.ToList(); + public virtual IEnumerable GetSeriesFiles(int seriesId) + { + return _seriesProvider.GetSeries(seriesId).Episodes.Where(c => c.EpisodeFile != null).Select(c => c.EpisodeFile); } private List GetMediaFileList(string path)