mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 05:47:14 -04:00
commit
36d401218b
@ -77,7 +77,7 @@ namespace Emby.Server.Implementations.TV
|
||||
// Avoid implicitly captured closure
|
||||
var episodes = GetNextUpEpisodes(request, user, items);
|
||||
|
||||
return GetResult(episodes, null, request);
|
||||
return GetResult(episodes, request);
|
||||
}
|
||||
|
||||
public QueryResult<BaseItem> GetNextUp(NextUpQuery request, List<Folder> parentsFolders)
|
||||
@ -128,7 +128,7 @@ namespace Emby.Server.Implementations.TV
|
||||
// Avoid implicitly captured closure
|
||||
var episodes = GetNextUpEpisodes(request, user, items);
|
||||
|
||||
return GetResult(episodes, null, request);
|
||||
return GetResult(episodes, request);
|
||||
}
|
||||
|
||||
public IEnumerable<Episode> GetNextUpEpisodes(NextUpQuery request, User user, IEnumerable<string> seriesKeys)
|
||||
@ -163,8 +163,7 @@ namespace Emby.Server.Implementations.TV
|
||||
return false;
|
||||
})
|
||||
.Select(i => i.Item2())
|
||||
.Where(i => i != null)
|
||||
.Take(request.Limit ?? int.MaxValue);
|
||||
.Where(i => i != null);
|
||||
}
|
||||
|
||||
private string GetUniqueSeriesKey(BaseItem series)
|
||||
@ -232,24 +231,30 @@ namespace Emby.Server.Implementations.TV
|
||||
return new Tuple<DateTime, Func<Episode>>(DateTime.MinValue, getEpisode);
|
||||
}
|
||||
|
||||
private QueryResult<BaseItem> GetResult(IEnumerable<BaseItem> items, int? totalRecordLimit, NextUpQuery query)
|
||||
private QueryResult<BaseItem> GetResult(IEnumerable<BaseItem> items, NextUpQuery query)
|
||||
{
|
||||
var itemsArray = totalRecordLimit.HasValue ? items.Take(totalRecordLimit.Value).ToArray() : items.ToArray();
|
||||
var totalCount = itemsArray.Length;
|
||||
int totalCount = 0;
|
||||
|
||||
if (query.EnableTotalRecordCount)
|
||||
{
|
||||
var list = items.ToList();
|
||||
totalCount = list.Count;
|
||||
items = list;
|
||||
}
|
||||
|
||||
if (query.StartIndex.HasValue)
|
||||
{
|
||||
items = items.Skip(query.StartIndex.Value);
|
||||
}
|
||||
if (query.Limit.HasValue)
|
||||
{
|
||||
itemsArray = itemsArray.Skip(query.StartIndex ?? 0).Take(query.Limit.Value).ToArray();
|
||||
}
|
||||
else if (query.StartIndex.HasValue)
|
||||
{
|
||||
itemsArray = itemsArray.Skip(query.StartIndex.Value).ToArray();
|
||||
items = items.Take(query.Limit.Value);
|
||||
}
|
||||
|
||||
return new QueryResult<BaseItem>
|
||||
{
|
||||
TotalRecordCount = totalCount,
|
||||
Items = itemsArray
|
||||
Items = items.ToArray()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -72,6 +72,12 @@ namespace MediaBrowser.Api
|
||||
|
||||
[ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
|
||||
public bool? EnableUserData { get; set; }
|
||||
public bool EnableTotalRecordCount { get; set; }
|
||||
|
||||
public GetNextUpEpisodes()
|
||||
{
|
||||
EnableTotalRecordCount = true;
|
||||
}
|
||||
}
|
||||
|
||||
[Route("/Shows/Upcoming", "GET", Summary = "Gets a list of upcoming episodes")]
|
||||
@ -376,7 +382,8 @@ namespace MediaBrowser.Api
|
||||
ParentId = request.ParentId,
|
||||
SeriesId = request.SeriesId,
|
||||
StartIndex = request.StartIndex,
|
||||
UserId = request.UserId
|
||||
UserId = request.UserId,
|
||||
EnableTotalRecordCount = request.EnableTotalRecordCount
|
||||
});
|
||||
|
||||
var user = _userManager.GetUserById(request.UserId);
|
||||
|
@ -55,9 +55,12 @@ namespace MediaBrowser.Model.Querying
|
||||
/// <value>The enable image types.</value>
|
||||
public ImageType[] EnableImageTypes { get; set; }
|
||||
|
||||
public bool EnableTotalRecordCount { get; set; }
|
||||
|
||||
public NextUpQuery()
|
||||
{
|
||||
EnableImageTypes = new ImageType[] {};
|
||||
EnableTotalRecordCount = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyVersion("3.2.8.6")]
|
||||
[assembly: AssemblyVersion("3.2.8.7")]
|
||||
|
Loading…
Reference in New Issue
Block a user