diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs
index b850efb720..588fad8bd3 100644
--- a/MediaBrowser.Api/LiveTv/LiveTvService.cs
+++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs
@@ -55,6 +55,12 @@ namespace MediaBrowser.Api.LiveTv
[ApiMember(Name = "GroupId", Description = "Optional filter by recording group.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string GroupId { get; set; }
+
+ [ApiMember(Name = "StartIndex", Description = "Optional. The record index to start at. All items with a lower index will be dropped from the results.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
+ public int? StartIndex { get; set; }
+
+ [ApiMember(Name = "Limit", Description = "Optional. The maximum number of records to return", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
+ public int? Limit { get; set; }
}
[Route("/LiveTv/Recordings/Groups", "GET")]
@@ -259,7 +265,9 @@ namespace MediaBrowser.Api.LiveTv
{
ChannelId = request.ChannelId,
UserId = request.UserId,
- GroupId = request.GroupId
+ GroupId = request.GroupId,
+ StartIndex = request.StartIndex,
+ Limit = request.Limit
}, CancellationToken.None).Result;
diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs
index c1ab50e281..8ea225186b 100644
--- a/MediaBrowser.Api/UserLibrary/ItemsService.cs
+++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs
@@ -1,6 +1,4 @@
-using System.Globalization;
-using System.IO;
-using MediaBrowser.Controller.Dto;
+using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Movies;
@@ -13,6 +11,8 @@ using MediaBrowser.Model.Querying;
using ServiceStack;
using System;
using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
using System.Linq;
namespace MediaBrowser.Api.UserLibrary
diff --git a/MediaBrowser.Model/LiveTv/RecordingQuery.cs b/MediaBrowser.Model/LiveTv/RecordingQuery.cs
index 10161b99a8..e63a250e6e 100644
--- a/MediaBrowser.Model/LiveTv/RecordingQuery.cs
+++ b/MediaBrowser.Model/LiveTv/RecordingQuery.cs
@@ -28,6 +28,18 @@
///
/// The group identifier.
public string GroupId { get; set; }
+
+ ///
+ /// Skips over a given number of items within the results. Use for paging.
+ ///
+ /// The start index.
+ public int? StartIndex { get; set; }
+
+ ///
+ /// The maximum number of items to return
+ ///
+ /// The limit.
+ public int? Limit { get; set; }
}
public class RecordingGroupQuery
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
index 04aad469ad..2ef68c2392 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -462,7 +462,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
var guid = new Guid(query.Id);
var currentServiceName = service.Name;
-
+
list = list
.Where(i => _tvDtoService.GetInternalRecordingId(currentServiceName, i.Id) == guid)
.ToList();
@@ -476,11 +476,24 @@ namespace MediaBrowser.Server.Implementations.LiveTv
.ToList();
}
- var entities = await GetEntities(list, service.Name, cancellationToken).ConfigureAwait(false);
+ IEnumerable entities = await GetEntities(list, service.Name, cancellationToken).ConfigureAwait(false);
+
+ entities = entities.OrderByDescending(i => i.RecordingInfo.StartDate);
if (user != null)
{
- entities = entities.Where(i => i.IsParentalAllowed(user, _localization)).ToArray();
+ var currentUser = user;
+ entities = entities.Where(i => i.IsParentalAllowed(currentUser, _localization));
+ }
+
+ if (query.StartIndex.HasValue)
+ {
+ entities = entities.Skip(query.StartIndex.Value);
+ }
+
+ if (query.Limit.HasValue)
+ {
+ entities = entities.Take(query.Limit.Value);
}
var returnArray = entities
@@ -489,7 +502,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv
var channel = string.IsNullOrEmpty(i.RecordingInfo.ChannelId) ? null : GetInternalChannel(_tvDtoService.GetInternalChannelId(service.Name, i.RecordingInfo.ChannelId));
return _tvDtoService.GetRecordingInfoDto(i, channel, service, user);
})
- .OrderByDescending(i => i.StartDate)
.ToArray();
return new QueryResult
@@ -784,10 +796,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv
{
list.Add("Others");
}
-
+
return list;
}
-
+
private List GetRecordingGroupIds(RecordingInfo recording)
{
return GetRecordingGroupNames(recording).Select(i => i.ToLower()