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