mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-06-29 10:23:36 +02:00
Add option to include resumable items in next up requests
This commit is contained in:
parent
5c5daac98c
commit
9c64f94458
|
@ -135,13 +135,13 @@ namespace Emby.Server.Implementations.TV
|
||||||
|
|
||||||
private IEnumerable<Episode> GetNextUpEpisodes(NextUpQuery request, User user, IReadOnlyList<string> seriesKeys, DtoOptions dtoOptions)
|
private IEnumerable<Episode> GetNextUpEpisodes(NextUpQuery request, User user, IReadOnlyList<string> seriesKeys, DtoOptions dtoOptions)
|
||||||
{
|
{
|
||||||
var allNextUp = seriesKeys.Select(i => GetNextUp(i, user, dtoOptions, false));
|
var allNextUp = seriesKeys.Select(i => GetNextUp(i, user, dtoOptions, request.EnableResumable, false));
|
||||||
|
|
||||||
if (request.EnableRewatching)
|
if (request.EnableRewatching)
|
||||||
{
|
{
|
||||||
allNextUp = allNextUp.Concat(
|
allNextUp = allNextUp
|
||||||
seriesKeys.Select(i => GetNextUp(i, user, dtoOptions, true)))
|
.Concat(seriesKeys.Select(i => GetNextUp(i, user, dtoOptions, false, true)))
|
||||||
.OrderByDescending(i => i.LastWatchedDate);
|
.OrderByDescending(i => i.LastWatchedDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If viewing all next up for all series, remove first episodes
|
// If viewing all next up for all series, remove first episodes
|
||||||
|
@ -183,7 +183,7 @@ namespace Emby.Server.Implementations.TV
|
||||||
/// Gets the next up.
|
/// Gets the next up.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Task{Episode}.</returns>
|
/// <returns>Task{Episode}.</returns>
|
||||||
private (DateTime LastWatchedDate, Func<Episode?> GetEpisodeFunction) GetNextUp(string seriesKey, User user, DtoOptions dtoOptions, bool rewatching)
|
private (DateTime LastWatchedDate, Func<Episode?> GetEpisodeFunction) GetNextUp(string seriesKey, User user, DtoOptions dtoOptions, bool includeResumable, bool includePlayed)
|
||||||
{
|
{
|
||||||
var lastQuery = new InternalItemsQuery(user)
|
var lastQuery = new InternalItemsQuery(user)
|
||||||
{
|
{
|
||||||
|
@ -200,8 +200,8 @@ namespace Emby.Server.Implementations.TV
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// If rewatching is enabled, sort first by date played and then by season and episode numbers
|
// If including played results, sort first by date played and then by season and episode numbers
|
||||||
lastQuery.OrderBy = rewatching
|
lastQuery.OrderBy = includePlayed
|
||||||
? new[] { (ItemSortBy.DatePlayed, SortOrder.Descending), (ItemSortBy.ParentIndexNumber, SortOrder.Descending), (ItemSortBy.IndexNumber, SortOrder.Descending) }
|
? new[] { (ItemSortBy.DatePlayed, SortOrder.Descending), (ItemSortBy.ParentIndexNumber, SortOrder.Descending), (ItemSortBy.IndexNumber, SortOrder.Descending) }
|
||||||
: new[] { (ItemSortBy.ParentIndexNumber, SortOrder.Descending), (ItemSortBy.IndexNumber, SortOrder.Descending) };
|
: new[] { (ItemSortBy.ParentIndexNumber, SortOrder.Descending), (ItemSortBy.IndexNumber, SortOrder.Descending) };
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ namespace Emby.Server.Implementations.TV
|
||||||
IncludeItemTypes = new[] { BaseItemKind.Episode },
|
IncludeItemTypes = new[] { BaseItemKind.Episode },
|
||||||
OrderBy = new[] { (ItemSortBy.ParentIndexNumber, SortOrder.Ascending), (ItemSortBy.IndexNumber, SortOrder.Ascending) },
|
OrderBy = new[] { (ItemSortBy.ParentIndexNumber, SortOrder.Ascending), (ItemSortBy.IndexNumber, SortOrder.Ascending) },
|
||||||
Limit = 1,
|
Limit = 1,
|
||||||
IsPlayed = rewatching,
|
IsPlayed = includePlayed,
|
||||||
IsVirtualItem = false,
|
IsVirtualItem = false,
|
||||||
ParentIndexNumberNotEquals = 0,
|
ParentIndexNumberNotEquals = 0,
|
||||||
DtoOptions = dtoOptions
|
DtoOptions = dtoOptions
|
||||||
|
@ -240,7 +240,7 @@ namespace Emby.Server.Implementations.TV
|
||||||
SeriesPresentationUniqueKey = seriesKey,
|
SeriesPresentationUniqueKey = seriesKey,
|
||||||
ParentIndexNumber = 0,
|
ParentIndexNumber = 0,
|
||||||
IncludeItemTypes = new[] { BaseItemKind.Episode },
|
IncludeItemTypes = new[] { BaseItemKind.Episode },
|
||||||
IsPlayed = rewatching,
|
IsPlayed = includePlayed,
|
||||||
IsVirtualItem = false,
|
IsVirtualItem = false,
|
||||||
DtoOptions = dtoOptions
|
DtoOptions = dtoOptions
|
||||||
})
|
})
|
||||||
|
@ -269,7 +269,7 @@ namespace Emby.Server.Implementations.TV
|
||||||
nextEpisode = sortedConsideredEpisodes.FirstOrDefault();
|
nextEpisode = sortedConsideredEpisodes.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextEpisode is not null)
|
if (nextEpisode is not null && !includeResumable)
|
||||||
{
|
{
|
||||||
var userData = _userDataManager.GetUserData(user, nextEpisode);
|
var userData = _userDataManager.GetUserData(user, nextEpisode);
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,8 @@ public class TvShowsController : BaseJellyfinApiController
|
||||||
/// <param name="nextUpDateCutoff">Optional. Starting date of shows to show in Next Up section.</param>
|
/// <param name="nextUpDateCutoff">Optional. Starting date of shows to show in Next Up section.</param>
|
||||||
/// <param name="enableTotalRecordCount">Whether to enable the total records count. Defaults to true.</param>
|
/// <param name="enableTotalRecordCount">Whether to enable the total records count. Defaults to true.</param>
|
||||||
/// <param name="disableFirstEpisode">Whether to disable sending the first episode in a series as next up.</param>
|
/// <param name="disableFirstEpisode">Whether to disable sending the first episode in a series as next up.</param>
|
||||||
/// <param name="enableRewatching">Whether to include watched episode in next up results.</param>
|
/// <param name="enableResumable">Whether to include resumable episodes in next up results.</param>
|
||||||
|
/// <param name="enableRewatching">Whether to include watched episodes in next up results.</param>
|
||||||
/// <returns>A <see cref="QueryResult{BaseItemDto}"/> with the next up episodes.</returns>
|
/// <returns>A <see cref="QueryResult{BaseItemDto}"/> with the next up episodes.</returns>
|
||||||
[HttpGet("NextUp")]
|
[HttpGet("NextUp")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
@ -86,6 +87,7 @@ public class TvShowsController : BaseJellyfinApiController
|
||||||
[FromQuery] DateTime? nextUpDateCutoff,
|
[FromQuery] DateTime? nextUpDateCutoff,
|
||||||
[FromQuery] bool enableTotalRecordCount = true,
|
[FromQuery] bool enableTotalRecordCount = true,
|
||||||
[FromQuery] bool disableFirstEpisode = false,
|
[FromQuery] bool disableFirstEpisode = false,
|
||||||
|
[FromQuery] bool enableResumable = true,
|
||||||
[FromQuery] bool enableRewatching = false)
|
[FromQuery] bool enableRewatching = false)
|
||||||
{
|
{
|
||||||
userId = RequestHelpers.GetUserId(User, userId);
|
userId = RequestHelpers.GetUserId(User, userId);
|
||||||
|
@ -104,6 +106,7 @@ public class TvShowsController : BaseJellyfinApiController
|
||||||
EnableTotalRecordCount = enableTotalRecordCount,
|
EnableTotalRecordCount = enableTotalRecordCount,
|
||||||
DisableFirstEpisode = disableFirstEpisode,
|
DisableFirstEpisode = disableFirstEpisode,
|
||||||
NextUpDateCutoff = nextUpDateCutoff ?? DateTime.MinValue,
|
NextUpDateCutoff = nextUpDateCutoff ?? DateTime.MinValue,
|
||||||
|
EnableResumable = enableResumable,
|
||||||
EnableRewatching = enableRewatching
|
EnableRewatching = enableRewatching
|
||||||
},
|
},
|
||||||
options);
|
options);
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace MediaBrowser.Model.Querying
|
||||||
EnableTotalRecordCount = true;
|
EnableTotalRecordCount = true;
|
||||||
DisableFirstEpisode = false;
|
DisableFirstEpisode = false;
|
||||||
NextUpDateCutoff = DateTime.MinValue;
|
NextUpDateCutoff = DateTime.MinValue;
|
||||||
|
EnableResumable = false;
|
||||||
EnableRewatching = false;
|
EnableRewatching = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +84,11 @@ namespace MediaBrowser.Model.Querying
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime NextUpDateCutoff { get; set; }
|
public DateTime NextUpDateCutoff { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether to include resumable episodes as next up.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableResumable { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether getting rewatching next up list.
|
/// Gets or sets a value indicating whether getting rewatching next up list.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in a new issue