The Free Software Media System - Server Backend & API
updated live tv models
Luke Pulverenti81e59040d004
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.csindex 0e40db58cd..409b04b413 100644--- a/MediaBrowser.Api/LiveTv/LiveTvService.cs+++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs@@ -14,17 +14,12 @@ namespace MediaBrowser.Api.LiveTv[Api(Description = "Gets available live tv services.")]public class GetServices : IReturn<List<LiveTvServiceInfo>>{- [ApiMember(Name = "ServiceName", Description = "Optional filter by service.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]- public string ServiceName { get; set; }}[Route("/LiveTv/Channels", "GET")][Api(Description = "Gets available live tv channels.")]public class GetChannels : IReturn<QueryResult<ChannelInfoDto>>{- [ApiMember(Name = "ServiceName", Description = "Optional filter by service.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]- public string ServiceName { get; set; }-[ApiMember(Name = "Type", Description = "Optional filter by channel type.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]public ChannelType? Type { get; set; }@@ -51,9 +46,6 @@ namespace MediaBrowser.Api.LiveTv[Api(Description = "Gets live tv recordings")]public class GetRecordings : IReturn<QueryResult<RecordingInfoDto>>{- [ApiMember(Name = "ServiceName", Description = "Optional filter by service.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]- public string ServiceName { get; set; }-[ApiMember(Name = "ChannelId", Description = "Optional filter by channel id.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]public string ChannelId { get; set; }}@@ -78,9 +70,6 @@ namespace MediaBrowser.Api.LiveTv[Api(Description = "Gets live tv timers")]public class GetTimers : IReturn<QueryResult<TimerInfoDto>>{- [ApiMember(Name = "ServiceName", Description = "Optional filter by service.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]- public string ServiceName { get; set; }-[ApiMember(Name = "ChannelId", Description = "Optional filter by channel id.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]public string ChannelId { get; set; }}@@ -89,9 +78,6 @@ namespace MediaBrowser.Api.LiveTv[Api(Description = "Gets available live tv epgs..")]public class GetPrograms : IReturn<QueryResult<ProgramInfoDto>>{- [ApiMember(Name = "ServiceName", Description = "Live tv service name", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]- public string ServiceName { get; set; }-[ApiMember(Name = "ChannelIds", Description = "The channels to return guide information for.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]public string ChannelIds { get; set; }@@ -124,21 +110,9 @@ namespace MediaBrowser.Api.LiveTv_liveTvManager = liveTvManager;}- private IEnumerable<ILiveTvService> GetServices(string serviceName)- {- IEnumerable<ILiveTvService> services = _liveTvManager.Services;-- if (!string.IsNullOrEmpty(serviceName))- {- services = services.Where(i => string.Equals(i.Name, serviceName, StringComparison.OrdinalIgnoreCase));- }-- return services;- }-public object Get(GetServices request){- var services = GetServices(request.ServiceName)+ var services = _liveTvManager.Services.Select(GetServiceInfo).ToList();@@ -158,7 +132,6 @@ namespace MediaBrowser.Api.LiveTvvar result = _liveTvManager.GetChannels(new ChannelQuery{ChannelType = request.Type,- ServiceName = request.ServiceName,UserId = request.UserId});@@ -177,7 +150,6 @@ namespace MediaBrowser.Api.LiveTv{var result = _liveTvManager.GetPrograms(new ProgramQuery{- ServiceName = request.ServiceName,ChannelIdList = (request.ChannelIds ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray(),UserId = request.UserId@@ -190,8 +162,7 @@ namespace MediaBrowser.Api.LiveTv{var result = _liveTvManager.GetRecordings(new RecordingQuery{- ChannelId = request.ChannelId,- ServiceName = request.ServiceName+ ChannelId = request.ChannelId}, CancellationToken.None).Result;@@ -216,8 +187,7 @@ namespace MediaBrowser.Api.LiveTv{var result = _liveTvManager.GetTimers(new TimerQuery{- ChannelId = request.ChannelId,- ServiceName = request.ServiceName+ ChannelId = request.ChannelId}, CancellationToken.None).Result;diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.csindex 4e73fc109f..b8dfbe05dd 100644--- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs+++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs@@ -11,6 +11,12 @@ namespace MediaBrowser.Controller.LiveTv/// </summary>public interface ILiveTvManager{+ /// <summary>+ /// Gets the active service.+ /// </summary>+ /// <value>The active service.</value>+ ILiveTvService ActiveService { get; }+/// <summary>/// Gets the services./// </summary>@@ -37,7 +43,7 @@ namespace MediaBrowser.Controller.LiveTv/// <param name="id">The identifier.</param>/// <returns>Task.</returns>Task CancelTimer(string id);-+/// <summary>/// Adds the parts./// </summary>@@ -82,7 +88,7 @@ namespace MediaBrowser.Controller.LiveTv/// <param name="cancellationToken">The cancellation token.</param>/// <returns>Task{QueryResult{TimerInfoDto}}.</returns>Task<QueryResult<TimerInfoDto>> GetTimers(TimerQuery query, CancellationToken cancellationToken);-+/// <summary>/// Gets the channel./// </summary>diff --git a/MediaBrowser.Controller/LiveTv/ProgramInfo.cs b/MediaBrowser.Controller/LiveTv/ProgramInfo.csindex cf5cdb94c9..8059c1100b 100644--- a/MediaBrowser.Controller/LiveTv/ProgramInfo.cs+++ b/MediaBrowser.Controller/LiveTv/ProgramInfo.cs@@ -27,11 +27,12 @@ namespace MediaBrowser.Controller.LiveTv/// </summary>/// <value>The official rating.</value>public string OfficialRating { get; set; }-+/// <summary>- /// Description of the progam.+ /// Gets or sets the overview./// </summary>- public string Description { get; set; }+ /// <value>The overview.</value>+ public string Overview { get; set; }/// <summary>/// The start date of the program, in UTC.@@ -54,23 +55,23 @@ namespace MediaBrowser.Controller.LiveTv/// </summary>public List<string> Genres { get; set; }- /// <summary>- /// Gets or sets the quality.- /// </summary>- /// <value>The quality.</value>- public ProgramVideoQuality Quality { get; set; }-/// <summary>/// Gets or sets the original air date./// </summary>/// <value>The original air date.</value>public DateTime? OriginalAirDate { get; set; }+ /// <summary>+ /// Gets or sets a value indicating whether this instance is hd.+ /// </summary>+ /// <value><c>true</c> if this instance is hd; otherwise, <c>false</c>.</value>+ public bool? IsHD { get; set; }+/// <summary>/// Gets or sets the audio./// </summary>/// <value>The audio.</value>- public ProgramAudio Audio { get; set; }+ public ProgramAudio? Audio { get; set; }/// <summary>/// Gets or sets the community rating.diff --git a/MediaBrowser.Controller/LiveTv/RecordingInfo.cs b/MediaBrowser.Controller/LiveTv/RecordingInfo.csindex 2c8e8cb464..1ffbb7e237 100644--- a/MediaBrowser.Controller/LiveTv/RecordingInfo.cs+++ b/MediaBrowser.Controller/LiveTv/RecordingInfo.cs@@ -37,11 +37,12 @@ namespace MediaBrowser.Controller.LiveTv/// </summary>/// <value>The path.</value>public string Path { get; set; }-+/// <summary>- /// Description of the recording.+ /// Gets or sets the overview./// </summary>- public string Description { get; set; }+ /// <value>The overview.</value>+ public string Overview { get; set; }/// <summary>/// The start date of the recording, in UTC.@@ -82,6 +83,18 @@ namespace MediaBrowser.Controller.LiveTv/// <value>The episode title.</value>public string EpisodeTitle { get; set; }+ /// <summary>+ /// Gets or sets a value indicating whether this instance is hd.+ /// </summary>+ /// <value><c>true</c> if this instance is hd; otherwise, <c>false</c>.</value>+ public bool? IsHD { get; set; }++ /// <summary>+ /// Gets or sets the audio.+ /// </summary>+ /// <value>The audio.</value>+ public ProgramAudio? Audio { get; set; }+/// <summary>/// Gets or sets the official rating./// </summary>diff --git a/MediaBrowser.Controller/LiveTv/TimerInfo.cs b/MediaBrowser.Controller/LiveTv/TimerInfo.csindex 3df0b8ccab..26e5869cea 100644--- a/MediaBrowser.Controller/LiveTv/TimerInfo.cs+++ b/MediaBrowser.Controller/LiveTv/TimerInfo.cs@@ -59,15 +59,27 @@ namespace MediaBrowser.Controller.LiveTvpublic RecordingStatus Status { get; set; }/// <summary>- /// Gets or sets the pre padding seconds.+ /// Gets or sets the requested pre padding seconds./// </summary>- /// <value>The pre padding seconds.</value>- public int PrePaddingSeconds { get; set; }+ /// <value>The requested pre padding seconds.</value>+ public int RequestedPrePaddingSeconds { get; set; }/// <summary>- /// Gets or sets the post padding seconds.+ /// Gets or sets the requested post padding seconds./// </summary>- /// <value>The post padding seconds.</value>- public int PostPaddingSeconds { get; set; }+ /// <value>The requested post padding seconds.</value>+ public int RequestedPostPaddingSeconds { get; set; }++ /// <summary>+ /// Gets or sets the required pre padding seconds.+ /// </summary>+ /// <value>The required pre padding seconds.</value>+ public int RequiredPrePaddingSeconds { get; set; }++ /// <summary>+ /// Gets or sets the required post padding seconds.+ /// </summary>+ /// <value>The required post padding seconds.</value>+ public int RequiredPostPaddingSeconds { get; set; }}}diff --git a/MediaBrowser.Model/LiveTv/ChannelQuery.cs b/MediaBrowser.Model/LiveTv/ChannelQuery.csindex 9fe74502fd..578f3039bb 100644--- a/MediaBrowser.Model/LiveTv/ChannelQuery.cs+++ b/MediaBrowser.Model/LiveTv/ChannelQuery.cs@@ -6,12 +6,6 @@ namespace MediaBrowser.Model.LiveTv/// </summary>public class ChannelQuery{- /// <summary>- /// Gets or sets the name of the service.- /// </summary>- /// <value>The name of the service.</value>- public string ServiceName { get; set; }-/// <summary>/// Gets or sets the type of the channel./// </summary>diff --git a/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs b/MediaBrowser.Model/LiveTv/ProgramInfoDto.csindex 6884d355d1..5f35de086d 100644--- a/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs+++ b/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs@@ -52,9 +52,9 @@ namespace MediaBrowser.Model.LiveTvpublic string Name { get; set; }/// <summary>- /// Description of the progam.+ /// Overview of the recording./// </summary>- public string Description { get; set; }+ public string Overview { get; set; }/// <summary>/// The start date of the program, in UTC.@@ -72,16 +72,16 @@ namespace MediaBrowser.Model.LiveTvpublic List<string> Genres { get; set; }/// <summary>- /// Gets or sets the quality.+ /// Gets or sets a value indicating whether this instance is hd./// </summary>- /// <value>The quality.</value>- public ProgramVideoQuality Quality { get; set; }+ /// <value><c>true</c> if this instance is hd; otherwise, <c>false</c>.</value>+ public bool? IsHD { get; set; }/// <summary>/// Gets or sets the audio./// </summary>/// <value>The audio.</value>- public ProgramAudio Audio { get; set; }+ public ProgramAudio? Audio { get; set; }/// <summary>/// Gets or sets the original air date.@@ -107,12 +107,6 @@ namespace MediaBrowser.Model.LiveTv}}- public enum ProgramVideoQuality- {- StandardDefinition,- HighDefinition- }-public enum ProgramAudio{Stereodiff --git a/MediaBrowser.Model/LiveTv/ProgramQuery.cs b/MediaBrowser.Model/LiveTv/ProgramQuery.csindex ce0639aa0e..c2a913bc85 100644--- a/MediaBrowser.Model/LiveTv/ProgramQuery.cs+++ b/MediaBrowser.Model/LiveTv/ProgramQuery.cs@@ -5,12 +5,6 @@/// </summary>public class ProgramQuery{- /// <summary>- /// Gets or sets the name of the service.- /// </summary>- /// <value>The name of the service.</value>- public string ServiceName { get; set; }-/// <summary>/// Gets or sets the channel identifier./// </summary>diff --git a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs b/MediaBrowser.Model/LiveTv/RecordingInfoDto.csindex 86e82b562d..a095e1751b 100644--- a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs+++ b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs@@ -44,9 +44,9 @@ namespace MediaBrowser.Model.LiveTvpublic string Path { get; set; }/// <summary>- /// Description of the recording.+ /// Overview of the recording./// </summary>- public string Description { get; set; }+ public string Overview { get; set; }/// <summary>/// The start date of the recording, in UTC.@@ -111,6 +111,18 @@ namespace MediaBrowser.Model.LiveTv/// <value>The community rating.</value>public float? CommunityRating { get; set; }+ /// <summary>+ /// Gets or sets a value indicating whether this instance is hd.+ /// </summary>+ /// <value><c>true</c> if this instance is hd; otherwise, <c>false</c>.</value>+ public bool? IsHD { get; set; }++ /// <summary>+ /// Gets or sets the audio.+ /// </summary>+ /// <value>The audio.</value>+ public ProgramAudio? Audio { get; set; }+public RecordingInfoDto(){Genres = new List<string>();diff --git a/MediaBrowser.Model/LiveTv/RecordingQuery.cs b/MediaBrowser.Model/LiveTv/RecordingQuery.csindex 0820c7785e..cd5ebe6282 100644--- a/MediaBrowser.Model/LiveTv/RecordingQuery.cs+++ b/MediaBrowser.Model/LiveTv/RecordingQuery.cs@@ -10,12 +10,6 @@/// </summary>/// <value>The channel identifier.</value>public string ChannelId { get; set; }-- /// <summary>- /// Gets or sets the name of the service.- /// </summary>- /// <value>The name of the service.</value>- public string ServiceName { get; set; }}public class TimerQuery@@ -25,11 +19,5 @@/// </summary>/// <value>The channel identifier.</value>public string ChannelId { get; set; }-- /// <summary>- /// Gets or sets the name of the service.- /// </summary>- /// <value>The name of the service.</value>- public string ServiceName { get; set; }}}diff --git a/MediaBrowser.Model/LiveTv/TimerInfoDto.cs b/MediaBrowser.Model/LiveTv/TimerInfoDto.csindex 9ebc2314d4..e8085fc92f 100644--- a/MediaBrowser.Model/LiveTv/TimerInfoDto.cs+++ b/MediaBrowser.Model/LiveTv/TimerInfoDto.cs@@ -64,16 +64,28 @@ namespace MediaBrowser.Model.LiveTvpublic string SeriesTimerId { get; set; }/// <summary>- /// Gets or sets the pre padding seconds.+ /// Gets or sets the requested pre padding seconds./// </summary>- /// <value>The pre padding seconds.</value>- public int PrePaddingSeconds { get; set; }+ /// <value>The requested pre padding seconds.</value>+ public int RequestedPrePaddingSeconds { get; set; }/// <summary>- /// Gets or sets the post padding seconds.+ /// Gets or sets the requested post padding seconds./// </summary>- /// <value>The post padding seconds.</value>- public int PostPaddingSeconds { get; set; }+ /// <value>The requested post padding seconds.</value>+ public int RequestedPostPaddingSeconds { get; set; }++ /// <summary>+ /// Gets or sets the required pre padding seconds.+ /// </summary>+ /// <value>The required pre padding seconds.</value>+ public int RequiredPrePaddingSeconds { get; set; }++ /// <summary>+ /// Gets or sets the required post padding seconds.+ /// </summary>+ /// <value>The required post padding seconds.</value>+ public int RequiredPostPaddingSeconds { get; set; }/// <summary>/// Gets or sets the duration ms.diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.csindex 4fd1f0e43b..1ed9733537 100644--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs@@ -64,6 +64,8 @@ namespace MediaBrowser.Server.Implementations.LiveTvget { return _services; }}+ public ILiveTvService ActiveService { get; private set; }+/// <summary>/// Adds the parts./// </summary>@@ -71,6 +73,8 @@ namespace MediaBrowser.Server.Implementations.LiveTvpublic void AddParts(IEnumerable<ILiveTvService> services){_services.AddRange(services);++ ActiveService = _services.FirstOrDefault();}/// <summary>@@ -196,7 +200,7 @@ namespace MediaBrowser.Server.Implementations.LiveTvreturn new ProgramInfoDto{ChannelId = channel.Id.ToString("N"),- Description = program.Description,+ Overview = program.Overview,EndDate = program.EndDate,Genres = program.Genres,ExternalId = program.Id,@@ -205,7 +209,7 @@ namespace MediaBrowser.Server.Implementations.LiveTvServiceName = channel.ServiceName,StartDate = program.StartDate,OfficialRating = program.OfficialRating,- Quality = program.Quality,+ IsHD = program.IsHD,OriginalAirDate = program.OriginalAirDate,Audio = program.Audio,CommunityRating = program.CommunityRating,@@ -285,11 +289,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.OrderBy(i => i.StartDate).ThenBy(i => i.EndDate);- if (!string.IsNullOrEmpty(query.ServiceName))- {- programs = programs.Where(i => string.Equals(i.ServiceName, query.ServiceName, StringComparison.OrdinalIgnoreCase));- }-if (query.ChannelIdList.Length > 0){var guids = query.ChannelIdList.Select(i => new Guid(i)).ToList();@@ -380,7 +379,7 @@ namespace MediaBrowser.Server.Implementations.LiveTvvar dto = new RecordingInfoDto{ChannelName = info.ChannelName,- Description = info.Description,+ Overview = info.Overview,EndDate = info.EndDate,Name = info.Name,StartDate = info.StartDate,@@ -395,7 +394,9 @@ namespace MediaBrowser.Server.Implementations.LiveTvChannelType = info.ChannelType,MediaType = info.ChannelType == ChannelType.Radio ? MediaType.Audio : MediaType.Video,CommunityRating = info.CommunityRating,- OfficialRating = info.OfficialRating+ OfficialRating = info.OfficialRating,+ Audio = info.Audio,+ IsHD = info.IsHD};var duration = info.EndDate - info.StartDate;@@ -413,9 +414,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv{var list = new List<RecordingInfoDto>();- foreach (var service in GetServices(query.ServiceName, query.ChannelId))+ if (ActiveService != null){- var recordings = await GetRecordings(service, cancellationToken).ConfigureAwait(false);+ var recordings = await GetRecordings(ActiveService, cancellationToken).ConfigureAwait(false);list.AddRange(recordings);}@@ -466,9 +467,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv{var list = new List<TimerInfoDto>();- foreach (var service in GetServices(query.ServiceName, query.ChannelId))+ if (ActiveService != null){- var timers = await GetTimers(service, cancellationToken).ConfigureAwait(false);+ var timers = await GetTimers(ActiveService, cancellationToken).ConfigureAwait(false);list.AddRange(timers);}@@ -513,8 +514,10 @@ namespace MediaBrowser.Server.Implementations.LiveTvChannelId = GetInternalChannelId(service.Name, info.ChannelId, info.ChannelName).ToString("N"),Status = info.Status,SeriesTimerId = info.SeriesTimerId,- PrePaddingSeconds = info.PrePaddingSeconds,- PostPaddingSeconds = info.PostPaddingSeconds+ RequestedPostPaddingSeconds = info.RequestedPostPaddingSeconds,+ RequestedPrePaddingSeconds = info.RequestedPrePaddingSeconds,+ RequiredPostPaddingSeconds = info.RequiredPostPaddingSeconds,+ RequiredPrePaddingSeconds = info.RequiredPrePaddingSeconds};var duration = info.EndDate - info.StartDate;diff --git a/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs b/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.csindex 00bf9e55ba..fe565e0947 100644--- a/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs+++ b/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs@@ -53,7 +53,7 @@ namespace MediaBrowser.Server.Implementations.LiveTvpublic bool IsHidden{- get { return _liveTvManager.Services.Count == 0; }+ get { return _liveTvManager.ActiveService == null; }}}}