aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-11-11 14:36:48 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-11-11 14:36:48 -0500
commit78e6304ac03f79f1cb104bda1bac3b2e917173a4 (patch)
tree069d14f8cf7a7dbfeb6645146d7fd840539bc1b1
parenta347475b7b16a12735f26a3bd855c4b9df5327b4 (diff)
updated live tv api
-rw-r--r--MediaBrowser.Api/LiveTv/LiveTvService.cs48
-rw-r--r--MediaBrowser.Controller/LiveTv/ILiveTvService.cs17
2 files changed, 47 insertions, 18 deletions
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs
index 6a914a35f..71da40348 100644
--- a/MediaBrowser.Api/LiveTv/LiveTvService.cs
+++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs
@@ -12,27 +12,35 @@ 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<List<ChannelInfoDto>>
{
- // Add filter by service if needed, and/or other filters
+ [ApiMember(Name = "ServiceName", Description = "Optional filter by service.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
+ public string ServiceName { get; set; }
}
[Route("/LiveTv/Recordings", "GET")]
[Api(Description = "Gets available live tv recordings.")]
public class GetRecordings : IReturn<List<RecordingInfo>>
{
- // Add filter by service if needed, and/or other filters
+ [ApiMember(Name = "ServiceName", Description = "Optional filter by service.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
+ public string ServiceName { get; set; }
}
[Route("/LiveTv/EPG", "GET")]
[Api(Description = "Gets available live tv epgs..")]
- public class GetEpg : IReturn<List<EpgFullInfo>>
+ public class GetEpg : IReturn<EpgFullInfo>
{
- // Add filter by service if needed, and/or other filters
+ [ApiMember(Name = "ServiceName", Description = "The live tv service name", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
+ public string ServiceName { get; set; }
+
+ [ApiMember(Name = "ChannelId", Description = "The channel id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
+ public string ChannelId { get; set; }
}
public class LiveTvService : BaseApiService
@@ -44,14 +52,25 @@ namespace MediaBrowser.Api.LiveTv
_liveTvManager = liveTvManager;
}
- public object Get(GetServices request)
+ private IEnumerable<ILiveTvService> GetServices(string serviceName)
{
- var services = _liveTvManager.Services;
+ IEnumerable<ILiveTvService> services = _liveTvManager.Services;
+
+ if (!string.IsNullOrEmpty(serviceName))
+ {
+ services = services.Where(i => string.Equals(i.Name, serviceName, System.StringComparison.OrdinalIgnoreCase));
+ }
+
+ return services;
+ }
- var result = services.Select(GetServiceInfo)
+ public object Get(GetServices request)
+ {
+ var services = GetServices(request.ServiceName)
+ .Select(GetServiceInfo)
.ToList();
- return ToOptimizedResult(result);
+ return ToOptimizedResult(services);
}
private LiveTvServiceInfo GetServiceInfo(ILiveTvService service)
@@ -71,7 +90,7 @@ namespace MediaBrowser.Api.LiveTv
private async Task<IEnumerable<ChannelInfoDto>> GetChannelsAsync(GetChannels request)
{
- var services = _liveTvManager.Services;
+ var services = GetServices(request.ServiceName);
var tasks = services.Select(i => i.GetChannelsAsync(CancellationToken.None));
@@ -91,7 +110,7 @@ namespace MediaBrowser.Api.LiveTv
private async Task<IEnumerable<RecordingInfo>> GetRecordingsAsync(GetRecordings request)
{
- var services = _liveTvManager.Services;
+ var services = GetServices(request.ServiceName);
var tasks = services.Select(i => i.GetRecordingsAsync(CancellationToken.None));
@@ -109,13 +128,12 @@ namespace MediaBrowser.Api.LiveTv
private async Task<IEnumerable<EpgFullInfo>> GetEpgAsync(GetEpg request)
{
- var services = _liveTvManager.Services;
-
- var tasks = services.Select(i => i.GetEpgAsync(CancellationToken.None));
+ var service = GetServices(request.ServiceName)
+ .First();
- var epg = await Task.WhenAll(tasks).ConfigureAwait(false);
+ var epg = await service.GetEpgAsync(request.ChannelId, CancellationToken.None).ConfigureAwait(false);
- return epg.SelectMany(i => i);
+ return epg;
}
}
} \ No newline at end of file
diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs
index 86058696d..f7181a99b 100644
--- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs
+++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs
@@ -1,7 +1,7 @@
-using System.Collections.Generic;
+using MediaBrowser.Model.LiveTv;
+using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
-using MediaBrowser.Model.LiveTv;
namespace MediaBrowser.Controller.LiveTv
{
@@ -23,8 +23,19 @@ namespace MediaBrowser.Controller.LiveTv
/// <returns>Task{IEnumerable{ChannelInfo}}.</returns>
Task<IEnumerable<ChannelInfo>> GetChannelsAsync(CancellationToken cancellationToken);
+ /// <summary>
+ /// Gets the recordings asynchronous.
+ /// </summary>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>Task{IEnumerable{RecordingInfo}}.</returns>
Task<IEnumerable<RecordingInfo>> GetRecordingsAsync(CancellationToken cancellationToken);
- Task<IEnumerable<EpgFullInfo>> GetEpgAsync(CancellationToken cancellationToken);
+ /// <summary>
+ /// Gets the epg asynchronous.
+ /// </summary>
+ /// <param name="channelId">The channel identifier.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>Task{IEnumerable{EpgFullInfo}}.</returns>
+ Task<IEnumerable<EpgFullInfo>> GetEpgAsync(string channelId, CancellationToken cancellationToken);
}
}