From a23920e2ad45c01439c668fe524ae892af1b1569 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Wed, 15 Jul 2020 13:18:02 +0200 Subject: [PATCH 1/2] Only fetch Next Up for episodes that have been fully matched --- .../TV/TVSeriesManager.cs | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/Emby.Server.Implementations/TV/TVSeriesManager.cs b/Emby.Server.Implementations/TV/TVSeriesManager.cs index 21c12ae79f..552c9d1c1a 100644 --- a/Emby.Server.Implementations/TV/TVSeriesManager.cs +++ b/Emby.Server.Implementations/TV/TVSeriesManager.cs @@ -117,23 +117,19 @@ namespace Emby.Server.Implementations.TV limit = limit.Value + 10; } - var items = _libraryManager.GetItemList(new InternalItemsQuery(user) - { - IncludeItemTypes = new[] { typeof(Episode).Name }, - OrderBy = new[] { new ValueTuple(ItemSortBy.DatePlayed, SortOrder.Descending) }, - SeriesPresentationUniqueKey = presentationUniqueKey, - Limit = limit, - DtoOptions = new DtoOptions + var items = _libraryManager + .GetItemList(new InternalItemsQuery(user) { - Fields = new ItemFields[] - { - ItemFields.SeriesPresentationUniqueKey - }, - EnableImages = false - }, - GroupBySeriesPresentationUniqueKey = true - - }, parentsFolders.ToList()).Cast().Select(GetUniqueSeriesKey); + IncludeItemTypes = new[] {typeof(Episode).Name}, + OrderBy = new[] {new ValueTuple(ItemSortBy.DatePlayed, SortOrder.Descending)}, + SeriesPresentationUniqueKey = presentationUniqueKey, + Limit = limit, + DtoOptions = new DtoOptions {Fields = new ItemFields[] {ItemFields.SeriesPresentationUniqueKey}, EnableImages = false}, + GroupBySeriesPresentationUniqueKey = true + }, parentsFolders.ToList()) + .Cast() + .Where(episode => !string.IsNullOrEmpty(episode.SeriesPresentationUniqueKey)) + .Select(GetUniqueSeriesKey); // Avoid implicitly captured closure var episodes = GetNextUpEpisodes(request, user, items, dtoOptions); From 90fa1149fa8d7b770c91fd881bf150fd3fec521e Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Wed, 15 Jul 2020 19:04:36 +0200 Subject: [PATCH 2/2] Fix warnings --- .../TV/TVSeriesManager.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Emby.Server.Implementations/TV/TVSeriesManager.cs b/Emby.Server.Implementations/TV/TVSeriesManager.cs index 552c9d1c1a..d1818deff4 100644 --- a/Emby.Server.Implementations/TV/TVSeriesManager.cs +++ b/Emby.Server.Implementations/TV/TVSeriesManager.cs @@ -118,15 +118,16 @@ namespace Emby.Server.Implementations.TV } var items = _libraryManager - .GetItemList(new InternalItemsQuery(user) - { - IncludeItemTypes = new[] {typeof(Episode).Name}, - OrderBy = new[] {new ValueTuple(ItemSortBy.DatePlayed, SortOrder.Descending)}, - SeriesPresentationUniqueKey = presentationUniqueKey, - Limit = limit, - DtoOptions = new DtoOptions {Fields = new ItemFields[] {ItemFields.SeriesPresentationUniqueKey}, EnableImages = false}, - GroupBySeriesPresentationUniqueKey = true - }, parentsFolders.ToList()) + .GetItemList( + new InternalItemsQuery(user) + { + IncludeItemTypes = new[] { typeof(Episode).Name }, + OrderBy = new[] { new ValueTuple(ItemSortBy.DatePlayed, SortOrder.Descending) }, + SeriesPresentationUniqueKey = presentationUniqueKey, + Limit = limit, + DtoOptions = new DtoOptions { Fields = new[] { ItemFields.SeriesPresentationUniqueKey }, EnableImages = false }, + GroupBySeriesPresentationUniqueKey = true + }, parentsFolders.ToList()) .Cast() .Where(episode => !string.IsNullOrEmpty(episode.SeriesPresentationUniqueKey)) .Select(GetUniqueSeriesKey);