From 3d754fa5bfcd1b5376124f08b88e51bda5ff7e81 Mon Sep 17 00:00:00 2001 From: crobibero Date: Fri, 15 Jan 2021 15:06:11 -0700 Subject: [PATCH 1/3] Revert "Don't return first episodes in next up" --- .../TV/TVSeriesManager.cs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/TV/TVSeriesManager.cs b/Emby.Server.Implementations/TV/TVSeriesManager.cs index f0734340be..a8b1064cb7 100644 --- a/Emby.Server.Implementations/TV/TVSeriesManager.cs +++ b/Emby.Server.Implementations/TV/TVSeriesManager.cs @@ -143,10 +143,28 @@ namespace Emby.Server.Implementations.TV var allNextUp = seriesKeys .Select(i => GetNextUp(i, currentUser, dtoOptions)); + // allNextUp = allNextUp.OrderByDescending(i => i.Item1); + + // If viewing all next up for all series, remove first episodes + // But if that returns empty, keep those first episodes (avoid completely empty view) + var alwaysEnableFirstEpisode = !string.IsNullOrEmpty(request.SeriesId); + var anyFound = false; + return allNextUp .Where(i => { - return i.Item1 != DateTime.MinValue; + if (alwaysEnableFirstEpisode || i.Item1 != DateTime.MinValue) + { + anyFound = true; + return true; + } + + if (!anyFound && i.Item1 == DateTime.MinValue) + { + return true; + } + + return false; }) .Select(i => i.Item2()) .Where(i => i != null); From 3b9567d58364c1eac0e99169ba8aef8d3bd6777f Mon Sep 17 00:00:00 2001 From: crobibero Date: Fri, 15 Jan 2021 15:08:48 -0700 Subject: [PATCH 2/3] Add query parameter to disable returning first episode as next up --- Emby.Server.Implementations/TV/TVSeriesManager.cs | 5 +++++ Jellyfin.Api/Controllers/TvShowsController.cs | 7 +++++-- MediaBrowser.Model/Querying/NextUpQuery.cs | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Emby.Server.Implementations/TV/TVSeriesManager.cs b/Emby.Server.Implementations/TV/TVSeriesManager.cs index a8b1064cb7..168c8fea06 100644 --- a/Emby.Server.Implementations/TV/TVSeriesManager.cs +++ b/Emby.Server.Implementations/TV/TVSeriesManager.cs @@ -153,6 +153,11 @@ namespace Emby.Server.Implementations.TV return allNextUp .Where(i => { + if (request.DisableFirstEpisode) + { + return i.Item1 != DateTime.MinValue; + } + if (alwaysEnableFirstEpisode || i.Item1 != DateTime.MinValue) { anyFound = true; diff --git a/Jellyfin.Api/Controllers/TvShowsController.cs b/Jellyfin.Api/Controllers/TvShowsController.cs index ca18901e5d..223f588593 100644 --- a/Jellyfin.Api/Controllers/TvShowsController.cs +++ b/Jellyfin.Api/Controllers/TvShowsController.cs @@ -67,6 +67,7 @@ namespace Jellyfin.Api.Controllers /// Optional. The image types to include in the output. /// Optional. Include user data. /// Whether to enable the total records count. Defaults to true. + /// Whether to disable sending the first episode in a series as next up. /// A with the next up episodes. [HttpGet("NextUp")] [ProducesResponseType(StatusCodes.Status200OK)] @@ -81,7 +82,8 @@ namespace Jellyfin.Api.Controllers [FromQuery] int? imageTypeLimit, [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes, [FromQuery] bool? enableUserData, - [FromQuery] bool enableTotalRecordCount = true) + [FromQuery] bool enableTotalRecordCount = true, + [FromQuery] bool disableFirstEpisode = false) { var options = new DtoOptions { Fields = fields } .AddClientFields(Request) @@ -95,7 +97,8 @@ namespace Jellyfin.Api.Controllers SeriesId = seriesId, StartIndex = startIndex, UserId = userId ?? Guid.Empty, - EnableTotalRecordCount = enableTotalRecordCount + EnableTotalRecordCount = enableTotalRecordCount, + DisableFirstEpisode = disableFirstEpisode }, options); diff --git a/MediaBrowser.Model/Querying/NextUpQuery.cs b/MediaBrowser.Model/Querying/NextUpQuery.cs index 4ad336d333..001d0623cc 100644 --- a/MediaBrowser.Model/Querying/NextUpQuery.cs +++ b/MediaBrowser.Model/Querying/NextUpQuery.cs @@ -64,10 +64,16 @@ namespace MediaBrowser.Model.Querying public bool EnableTotalRecordCount { get; set; } + /// + /// Gets or sets a value indicating whether do disable sending first episode as next up. + /// + public bool DisableFirstEpisode { get; set; } + public NextUpQuery() { EnableImageTypes = Array.Empty(); EnableTotalRecordCount = true; + DisableFirstEpisode = false; } } } From 1455c2aa101ea80ba772b648f869c73cac655830 Mon Sep 17 00:00:00 2001 From: crobibero Date: Mon, 18 Jan 2021 06:47:18 -0700 Subject: [PATCH 3/3] Remove commented code --- Emby.Server.Implementations/TV/TVSeriesManager.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Emby.Server.Implementations/TV/TVSeriesManager.cs b/Emby.Server.Implementations/TV/TVSeriesManager.cs index 168c8fea06..839b62448b 100644 --- a/Emby.Server.Implementations/TV/TVSeriesManager.cs +++ b/Emby.Server.Implementations/TV/TVSeriesManager.cs @@ -143,8 +143,6 @@ namespace Emby.Server.Implementations.TV var allNextUp = seriesKeys .Select(i => GetNextUp(i, currentUser, dtoOptions)); - // allNextUp = allNextUp.OrderByDescending(i => i.Item1); - // If viewing all next up for all series, remove first episodes // But if that returns empty, keep those first episodes (avoid completely empty view) var alwaysEnableFirstEpisode = !string.IsNullOrEmpty(request.SeriesId);