The Free Software Media System - Server Backend & API
graphical display of latest recordings
Luke Pulverenti052e632a9701
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.csindex 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.csindex 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.UserLibrarydiff --git a/MediaBrowser.Model/LiveTv/RecordingQuery.cs b/MediaBrowser.Model/LiveTv/RecordingQuery.csindex 10161b99a8..e63a250e6e 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 RecordingGroupQuerydiff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.csindex 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.LiveTvvar 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.LiveTvvar 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()