From f339969258c777230e05b00ad02d1ee6682dbc76 Mon Sep 17 00:00:00 2001 From: Jamie Rees Date: Tue, 3 Jul 2018 20:56:32 +0100 Subject: [PATCH] Fixed the issue where episodes were not being marked as available in the search #2367 --- .../Rule/Rules/Search/EmbyAvailabilityRule.cs | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/Ombi.Core/Rule/Rules/Search/EmbyAvailabilityRule.cs b/src/Ombi.Core/Rule/Rules/Search/EmbyAvailabilityRule.cs index 4f2f56b28..b61efc8ac 100644 --- a/src/Ombi.Core/Rule/Rules/Search/EmbyAvailabilityRule.cs +++ b/src/Ombi.Core/Rule/Rules/Search/EmbyAvailabilityRule.cs @@ -1,4 +1,6 @@ -using System.Linq; +using System; +using System.Linq; +using System.Linq.Expressions; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Ombi.Core.Models.Search; @@ -59,10 +61,19 @@ namespace Ombi.Core.Rule.Rules.Search { EmbyEpisode epExists = null; - epExists = await allEpisodes.FirstOrDefaultAsync(x => - x.EpisodeNumber == episode.EpisodeNumber && x.SeasonNumber == season.SeasonNumber && - x.Series.ProviderId == item.ProviderId.ToString()); - + if (item.HasImdb) + { + epExists = await allEpisodes.FirstOrDefaultAsync(e => e.EpisodeNumber == episode.EpisodeNumber && e.SeasonNumber == season.SeasonNumber + && e.ImdbId == item.ImdbId); + } if (item.HasTvDb) + { + epExists = await allEpisodes.FirstOrDefaultAsync(e => e.EpisodeNumber == episode.EpisodeNumber && e.SeasonNumber == season.SeasonNumber + && e.TvDbId == item.TvDbId); + } if (item.HasTheMovieDb) + { + epExists = await allEpisodes.FirstOrDefaultAsync(e => e.EpisodeNumber == episode.EpisodeNumber && e.SeasonNumber == season.SeasonNumber + && e.TheMovieDbId == item.TheMovieDbId); + } if (epExists != null) {