From d3c33fa804d77afe120fda6610401574123185e0 Mon Sep 17 00:00:00 2001 From: Jamie Date: Fri, 26 Oct 2018 22:29:29 +0100 Subject: [PATCH] Show the TV show as available when we have all the episodes but future episodes have not aired. #2585 --- .../Rule/Rules/Search/PlexAvailabilityRule.cs | 18 +++++++++++++++++- src/Ombi/Controllers/TokenController.cs | 3 +++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Ombi.Core/Rule/Rules/Search/PlexAvailabilityRule.cs b/src/Ombi.Core/Rule/Rules/Search/PlexAvailabilityRule.cs index 016a2817c..e1ddcecd0 100644 --- a/src/Ombi.Core/Rule/Rules/Search/PlexAvailabilityRule.cs +++ b/src/Ombi.Core/Rule/Rules/Search/PlexAvailabilityRule.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Ombi.Core.Models.Search; @@ -104,6 +105,21 @@ namespace Ombi.Core.Rule.Rules.Search { search.FullyAvailable = true; } + else + { + var airedButNotAvailable = search.SeasonRequests.Any(x => + x.Episodes.Any(c => !c.Available && c.AirDate <= DateTime.Now.Date)); + if (!airedButNotAvailable) + { + var unairedEpisodes = search.SeasonRequests.Any(x => + x.Episodes.Any(c => !c.Available && c.AirDate > DateTime.Now.Date)); + if (unairedEpisodes) + { + search.FullyAvailable = true; + } + } + + } } } } diff --git a/src/Ombi/Controllers/TokenController.cs b/src/Ombi/Controllers/TokenController.cs index 0c05c81fe..75e40639f 100644 --- a/src/Ombi/Controllers/TokenController.cs +++ b/src/Ombi/Controllers/TokenController.cs @@ -96,6 +96,9 @@ namespace Ombi.Controllers return new UnauthorizedResult(); } + /// + /// Returns the Token for the Ombi User if we can match the Plex user with a valid Ombi User + /// [HttpPost("plextoken")] public async Task GetTokenWithPlexToken([FromBody] PlexTokenAuthentication model) {