aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-12-28 18:09:24 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-12-28 18:09:24 -0500
commit052e632a97011b178d0ec6c139a10c1f316dce77 (patch)
treea462a0f2e91596f52e94e46688ab7ea5adc3ce6c
parentc3532d7949d32be026ab0d5fca70947d69efd127 (diff)
graphical display of latest recordings
-rw-r--r--MediaBrowser.Api/LiveTv/LiveTvService.cs10
-rw-r--r--MediaBrowser.Api/UserLibrary/ItemsService.cs6
-rw-r--r--MediaBrowser.Model/LiveTv/RecordingQuery.cs12
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs24
4 files changed, 42 insertions, 10 deletions
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs
index b850efb72..588fad8bd 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 c1ab50e28..8ea225186 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 10161b99a..e63a250e6 100644
--- a/MediaBrowser.Model/LiveTv/RecordingQuery.cs
+++ b/MediaBrowser.Model/LiveTv/RecordingQuery.cs
@@ -28,6 +28,18 @@
/// </summary>
/// <value>The group identifier.</value>
public string GroupId { get; set; }
+
+ /// <summary>
+ /// Skips over a given number of items within the results. Use for paging.
+ /// </summary>
+ /// <value>The start index.</value>
+ public int? StartIndex { get; set; }
+
+ /// <summary>
+ /// The maximum number of items to return
+ /// </summary>
+ /// <value>The limit.</value>
+ 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 04aad469a..2ef68c239 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<LiveTvRecording> 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<RecordingInfoDto>
@@ -784,10 +796,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv
{
list.Add("Others");
}
-
+
return list;
}
-
+
private List<Guid> GetRecordingGroupIds(RecordingInfo recording)
{
return GetRecordingGroupNames(recording).Select(i => i.ToLower()