updated live tv models
This commit is contained in:
parent
cb882a4b48
commit
81e59040d0
|
@ -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.LiveTv
|
|||
var 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;
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -59,15 +59,27 @@ namespace MediaBrowser.Controller.LiveTv
|
|||
public 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; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -52,9 +52,9 @@ namespace MediaBrowser.Model.LiveTv
|
|||
public 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.LiveTv
|
|||
public 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
|
||||
{
|
||||
Stereo
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -44,9 +44,9 @@ namespace MediaBrowser.Model.LiveTv
|
|||
public 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>();
|
||||
|
|
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,16 +64,28 @@ namespace MediaBrowser.Model.LiveTv
|
|||
public 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.
|
||||
|
|
|
@ -64,6 +64,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||
get { return _services; }
|
||||
}
|
||||
|
||||
public ILiveTvService ActiveService { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Adds the parts.
|
||||
/// </summary>
|
||||
|
@ -71,6 +73,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||
public void AddParts(IEnumerable<ILiveTvService> services)
|
||||
{
|
||||
_services.AddRange(services);
|
||||
|
||||
ActiveService = _services.FirstOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -196,7 +200,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||
return 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.LiveTv
|
|||
ServiceName = 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.LiveTv
|
|||
var 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.LiveTv
|
|||
ChannelType = 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.LiveTv
|
|||
ChannelId = 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;
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||
|
||||
public bool IsHidden
|
||||
{
|
||||
get { return _liveTvManager.Services.Count == 0; }
|
||||
get { return _liveTvManager.ActiveService == null; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user