From 87f343ef06a8077705bdb5e16f27e58ee137a51d Mon Sep 17 00:00:00 2001 From: tidusjar Date: Tue, 16 Aug 2016 19:49:48 +0100 Subject: [PATCH] Update the availability checker to search for TV Episodes --- .../Jobs/PlexAvailabilityChecker.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/PlexRequests.Services/Jobs/PlexAvailabilityChecker.cs b/PlexRequests.Services/Jobs/PlexAvailabilityChecker.cs index cd6854688..e58a18c17 100644 --- a/PlexRequests.Services/Jobs/PlexAvailabilityChecker.cs +++ b/PlexRequests.Services/Jobs/PlexAvailabilityChecker.cs @@ -109,15 +109,23 @@ namespace PlexRequests.Services.Jobs foreach (var r in requestedModels) { var releaseDate = r.ReleaseDate == DateTime.MinValue ? string.Empty : r.ReleaseDate.ToString("yyyy"); - bool matchResult; + switch (r.Type) { case RequestType.Movie: matchResult = IsMovieAvailable(movies, r.Title, releaseDate, r.ImdbId); break; case RequestType.TvShow: - matchResult = IsTvShowAvailable(shows, r.Title, releaseDate, r.TvDbId); + if (!plexSettings.EnableTvEpisodeSearching) + { + matchResult = IsTvShowAvailable(shows, r.Title, releaseDate, r.TvDbId); + } + else + { + matchResult = + r.Episodes.All(x => IsEpisodeAvailable(r.TvDbId, x.SeasonNumber, x.EpisodeNumber)); + } break; case RequestType.Album: matchResult = IsAlbumAvailable(albums, r.Title, r.ReleaseDate.Year.ToString(), r.ArtistName); @@ -126,6 +134,7 @@ namespace PlexRequests.Services.Jobs throw new ArgumentOutOfRangeException(); } + if (matchResult) { r.Available = true;