mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-09 15:20:34 +02:00
Merge pull request #7383 from thornbill/next-up-rewatching
This commit is contained in:
commit
a123391e7e
|
@ -126,7 +126,8 @@ namespace Emby.Server.Implementations.TV
|
||||||
parentsFolders.ToList())
|
parentsFolders.ToList())
|
||||||
.Cast<Episode>()
|
.Cast<Episode>()
|
||||||
.Where(episode => !string.IsNullOrEmpty(episode.SeriesPresentationUniqueKey))
|
.Where(episode => !string.IsNullOrEmpty(episode.SeriesPresentationUniqueKey))
|
||||||
.Select(GetUniqueSeriesKey);
|
.Select(GetUniqueSeriesKey)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
// Avoid implicitly captured closure
|
// Avoid implicitly captured closure
|
||||||
var episodes = GetNextUpEpisodes(request, user, items, options);
|
var episodes = GetNextUpEpisodes(request, user, items, options);
|
||||||
|
@ -134,13 +135,21 @@ namespace Emby.Server.Implementations.TV
|
||||||
return GetResult(episodes, request);
|
return GetResult(episodes, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Episode> GetNextUpEpisodes(NextUpQuery request, User user, IEnumerable<string> seriesKeys, DtoOptions dtoOptions)
|
public IEnumerable<Episode> GetNextUpEpisodes(NextUpQuery request, User user, IReadOnlyList<string> seriesKeys, DtoOptions dtoOptions)
|
||||||
{
|
{
|
||||||
// Avoid implicitly captured closure
|
// Avoid implicitly captured closure
|
||||||
var currentUser = user;
|
var currentUser = user;
|
||||||
|
|
||||||
var allNextUp = seriesKeys
|
var allNextUp = seriesKeys
|
||||||
.Select(i => GetNextUp(i, currentUser, dtoOptions, request.Rewatching));
|
.Select(i => GetNextUp(i, currentUser, dtoOptions, false));
|
||||||
|
|
||||||
|
if (request.EnableRewatching)
|
||||||
|
{
|
||||||
|
allNextUp = allNextUp.Concat(
|
||||||
|
seriesKeys.Select(i => GetNextUp(i, currentUser, dtoOptions, true))
|
||||||
|
)
|
||||||
|
.OrderByDescending(i => i.Item1);
|
||||||
|
}
|
||||||
|
|
||||||
// If viewing all next up for all series, remove first episodes
|
// If viewing all next up for all series, remove first episodes
|
||||||
// But if that returns empty, keep those first episodes (avoid completely empty view)
|
// But if that returns empty, keep those first episodes (avoid completely empty view)
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
/// <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="rewatching">Whether to get a rewatching next up instead of standard next up.</param>
|
/// <param name="enableRewatching">Whether to include watched episode 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,7 +86,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
[FromQuery] DateTime? nextUpDateCutoff,
|
[FromQuery] DateTime? nextUpDateCutoff,
|
||||||
[FromQuery] bool enableTotalRecordCount = true,
|
[FromQuery] bool enableTotalRecordCount = true,
|
||||||
[FromQuery] bool disableFirstEpisode = false,
|
[FromQuery] bool disableFirstEpisode = false,
|
||||||
[FromQuery] bool rewatching = false)
|
[FromQuery] bool enableRewatching = false)
|
||||||
{
|
{
|
||||||
var options = new DtoOptions { Fields = fields }
|
var options = new DtoOptions { Fields = fields }
|
||||||
.AddClientFields(Request)
|
.AddClientFields(Request)
|
||||||
|
@ -103,7 +103,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
EnableTotalRecordCount = enableTotalRecordCount,
|
EnableTotalRecordCount = enableTotalRecordCount,
|
||||||
DisableFirstEpisode = disableFirstEpisode,
|
DisableFirstEpisode = disableFirstEpisode,
|
||||||
NextUpDateCutoff = nextUpDateCutoff ?? DateTime.MinValue,
|
NextUpDateCutoff = nextUpDateCutoff ?? DateTime.MinValue,
|
||||||
Rewatching = rewatching
|
EnableRewatching = enableRewatching
|
||||||
},
|
},
|
||||||
options);
|
options);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace MediaBrowser.Model.Querying
|
||||||
EnableTotalRecordCount = true;
|
EnableTotalRecordCount = true;
|
||||||
DisableFirstEpisode = false;
|
DisableFirstEpisode = false;
|
||||||
NextUpDateCutoff = DateTime.MinValue;
|
NextUpDateCutoff = DateTime.MinValue;
|
||||||
Rewatching = false;
|
EnableRewatching = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -86,6 +86,6 @@ namespace MediaBrowser.Model.Querying
|
||||||
/// <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>
|
||||||
public bool Rewatching { get; set; }
|
public bool EnableRewatching { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue