From 21a67a66d250cdb8569cc85398d8378c88b52013 Mon Sep 17 00:00:00 2001 From: MrTimscampi Date: Tue, 1 Dec 2020 13:55:52 +0100 Subject: [PATCH 1/4] Prevent GetUpNext from returning episodes in progress --- Emby.Server.Implementations/TV/TVSeriesManager.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/TV/TVSeriesManager.cs b/Emby.Server.Implementations/TV/TVSeriesManager.cs index a697c6476..a079d76ef 100644 --- a/Emby.Server.Implementations/TV/TVSeriesManager.cs +++ b/Emby.Server.Implementations/TV/TVSeriesManager.cs @@ -192,7 +192,7 @@ namespace Emby.Server.Implementations.TV Func getEpisode = () => { - return _libraryManager.GetItemList(new InternalItemsQuery(user) + var nextEpsiode = _libraryManager.GetItemList(new InternalItemsQuery(user) { AncestorWithPresentationUniqueKey = null, SeriesPresentationUniqueKey = seriesKey, @@ -205,6 +205,15 @@ namespace Emby.Server.Implementations.TV MinSortName = lastWatchedEpisode?.SortName, DtoOptions = dtoOptions }).Cast().FirstOrDefault(); + + var userData = _userDataManager.GetUserData(user, nextEpsiode); + + if (userData.PlaybackPositionTicks > 0) + { + return null; + } + + return nextEpsiode; }; if (lastWatchedEpisode != null) From 7ba9ba4780d9ce3a17ff8218d45e46638407e3c7 Mon Sep 17 00:00:00 2001 From: MrTimscampi Date: Tue, 1 Dec 2020 19:26:51 +0100 Subject: [PATCH 2/4] Fix typo --- Emby.Server.Implementations/TV/TVSeriesManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Emby.Server.Implementations/TV/TVSeriesManager.cs b/Emby.Server.Implementations/TV/TVSeriesManager.cs index a079d76ef..35fc12d55 100644 --- a/Emby.Server.Implementations/TV/TVSeriesManager.cs +++ b/Emby.Server.Implementations/TV/TVSeriesManager.cs @@ -192,7 +192,7 @@ namespace Emby.Server.Implementations.TV Func getEpisode = () => { - var nextEpsiode = _libraryManager.GetItemList(new InternalItemsQuery(user) + var nextEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user) { AncestorWithPresentationUniqueKey = null, SeriesPresentationUniqueKey = seriesKey, @@ -206,14 +206,14 @@ namespace Emby.Server.Implementations.TV DtoOptions = dtoOptions }).Cast().FirstOrDefault(); - var userData = _userDataManager.GetUserData(user, nextEpsiode); + var userData = _userDataManager.GetUserData(user, nextEpisode); if (userData.PlaybackPositionTicks > 0) { return null; } - return nextEpsiode; + return nextEpisode; }; if (lastWatchedEpisode != null) From 371092cf62f423fe62eb72f6c3d450966dc49b7d Mon Sep 17 00:00:00 2001 From: MrTimscampi Date: Tue, 1 Dec 2020 19:33:18 +0100 Subject: [PATCH 3/4] Fix possible nullref --- Emby.Server.Implementations/TV/TVSeriesManager.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Emby.Server.Implementations/TV/TVSeriesManager.cs b/Emby.Server.Implementations/TV/TVSeriesManager.cs index 35fc12d55..4dff8e252 100644 --- a/Emby.Server.Implementations/TV/TVSeriesManager.cs +++ b/Emby.Server.Implementations/TV/TVSeriesManager.cs @@ -206,11 +206,13 @@ namespace Emby.Server.Implementations.TV DtoOptions = dtoOptions }).Cast().FirstOrDefault(); - var userData = _userDataManager.GetUserData(user, nextEpisode); + if (!(nextEpisode is null)) { + var userData = _userDataManager.GetUserData(user, nextEpisode); - if (userData.PlaybackPositionTicks > 0) - { - return null; + if (userData.PlaybackPositionTicks > 0) + { + return null; + } } return nextEpisode; From 673d2c0d261bffae1769c3a357cd5f01912afc80 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Tue, 1 Dec 2020 22:31:55 +0100 Subject: [PATCH 4/4] Update Emby.Server.Implementations/TV/TVSeriesManager.cs --- Emby.Server.Implementations/TV/TVSeriesManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/TV/TVSeriesManager.cs b/Emby.Server.Implementations/TV/TVSeriesManager.cs index 4dff8e252..3cfcecbd1 100644 --- a/Emby.Server.Implementations/TV/TVSeriesManager.cs +++ b/Emby.Server.Implementations/TV/TVSeriesManager.cs @@ -206,7 +206,8 @@ namespace Emby.Server.Implementations.TV DtoOptions = dtoOptions }).Cast().FirstOrDefault(); - if (!(nextEpisode is null)) { + if (nextEpisode != null) + { var userData = _userDataManager.GetUserData(user, nextEpisode); if (userData.PlaybackPositionTicks > 0)