From 83d70c54ec303fab934f76fdd493cfa73c89533f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 15 Nov 2013 16:31:44 -0500 Subject: [PATCH] Updated live tv api --- MediaBrowser.Api/LiveTv/LiveTvService.cs | 31 +++++++++------- MediaBrowser.Controller/LiveTv/ChannelInfo.cs | 6 +++ .../LiveTv/ILiveTvManager.cs | 2 - .../LiveTv/ILiveTvService.cs | 11 +++--- .../MediaBrowser.Model.Portable.csproj | 15 +++++--- .../MediaBrowser.Model.net35.csproj | 15 +++++--- MediaBrowser.Model/LiveTv/ChannelInfoDto.cs | 10 +++++ MediaBrowser.Model/LiveTv/EpgFullInfo.cs | 17 --------- MediaBrowser.Model/LiveTv/EpgInfo.cs | 37 ------------------- MediaBrowser.Model/MediaBrowser.Model.csproj | 5 ++- .../LiveTv/LiveTvManager.cs | 8 +--- 11 files changed, 63 insertions(+), 94 deletions(-) delete mode 100644 MediaBrowser.Model/LiveTv/EpgFullInfo.cs delete mode 100644 MediaBrowser.Model/LiveTv/EpgInfo.cs diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index 6c3fcbac15..72e5eee92f 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -32,17 +32,17 @@ namespace MediaBrowser.Api.LiveTv public string ServiceName { get; set; } } - [Route("/LiveTv/EPG", "GET")] + [Route("/LiveTv/Guide", "GET")] [Api(Description = "Gets available live tv epgs..")] - public class GetEpg : IReturn + public class GetGuide : IReturn> { - [ApiMember(Name = "ServiceName", Description = "The live tv service name", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")] + [ApiMember(Name = "ServiceName", Description = "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; } + [ApiMember(Name = "ChannelIds", Description = "The channels to return guide information for.", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")] + public string ChannelIds { get; set; } } - + public class LiveTvService : BaseApiService { private readonly ILiveTvManager _liveTvManager; @@ -112,28 +112,33 @@ namespace MediaBrowser.Api.LiveTv { var services = GetServices(request.ServiceName); - var tasks = services.Select(i => i.GetRecordingsAsync(CancellationToken.None)); + var query = new RecordingQuery + { + + }; + + var tasks = services.Select(i => i.GetRecordingsAsync(query, CancellationToken.None)); var recordings = await Task.WhenAll(tasks).ConfigureAwait(false); - return recordings.SelectMany(i => i).Select(_liveTvManager.GetRecordingInfo); + return recordings.SelectMany(i => i); } - public object Get(GetEpg request) + public object Get(GetGuide request) { - var result = GetEpgAsync(request).Result; + var result = GetGuideAsync(request).Result; return ToOptimizedResult(result); } - private async Task GetEpgAsync(GetEpg request) + private async Task> GetGuideAsync(GetGuide request) { var service = GetServices(request.ServiceName) .First(); - var epg = await service.GetEpgAsync(request.ChannelId, CancellationToken.None).ConfigureAwait(false); + var channels = request.ChannelIds.Split(','); - return epg; + return await service.GetChannelGuidesAsync(channels, CancellationToken.None).ConfigureAwait(false); } } } \ No newline at end of file diff --git a/MediaBrowser.Controller/LiveTv/ChannelInfo.cs b/MediaBrowser.Controller/LiveTv/ChannelInfo.cs index 8d8b638477..721c1e40a8 100644 --- a/MediaBrowser.Controller/LiveTv/ChannelInfo.cs +++ b/MediaBrowser.Controller/LiveTv/ChannelInfo.cs @@ -13,6 +13,12 @@ namespace MediaBrowser.Controller.LiveTv /// The name. public string Name { get; set; } + /// + /// Gets or sets the number. + /// + /// The number. + public string Number { get; set; } + /// /// Get or sets the Id. /// diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index a48a6a5515..62bfdf3e58 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -27,7 +27,5 @@ namespace MediaBrowser.Controller.LiveTv /// The info. /// ChannelInfoDto. ChannelInfoDto GetChannelInfoDto(ChannelInfo info); - - RecordingInfo GetRecordingInfo(RecordingInfo info); } } diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs index 8cad0bd351..5c019ae8c4 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs @@ -26,16 +26,17 @@ namespace MediaBrowser.Controller.LiveTv /// /// Gets the recordings asynchronous. /// + /// The query. /// The cancellation token. /// Task{IEnumerable{RecordingInfo}}. - Task> GetRecordingsAsync(CancellationToken cancellationToken); + Task> GetRecordingsAsync(RecordingQuery query, CancellationToken cancellationToken); /// - /// Gets the epg asynchronous. + /// Gets the channel guides. /// - /// The channel identifier. + /// The channel identifier list. /// The cancellation token. - /// Task{EpgFullInfo}. - Task GetEpgAsync(string channelId, CancellationToken cancellationToken); + /// Task{IEnumerable{ChannelGuide}}. + Task> GetChannelGuidesAsync(IEnumerable channelIdList, CancellationToken cancellationToken); } } diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index a5bff2b40b..726df1eb54 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -224,24 +224,27 @@ IO\IZipClient.cs + + LiveTv\ChannelGuide.cs + LiveTv\ChannelInfoDto.cs LiveTv\ChannelType.cs - - LiveTv\EpgFullInfo.cs - - - LiveTv\EpgInfo.cs - LiveTv\LiveTvServiceInfo.cs + + LiveTv\ProgramInfo.cs + LiveTv\RecordingInfo.cs + + LiveTv\RecordingQuery.cs + Logging\ILogger.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index 60deab47d3..471db6f25d 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -211,24 +211,27 @@ IO\IZipClient.cs + + LiveTv\ChannelGuide.cs + LiveTv\ChannelInfoDto.cs LiveTv\ChannelType.cs - - LiveTv\EpgFullInfo.cs - - - LiveTv\EpgInfo.cs - LiveTv\LiveTvServiceInfo.cs + + LiveTv\ProgramInfo.cs + LiveTv\RecordingInfo.cs + + LiveTv\RecordingQuery.cs + Logging\ILogger.cs diff --git a/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs b/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs index 15c9055817..8daaa75cad 100644 --- a/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs @@ -12,7 +12,17 @@ namespace MediaBrowser.Model.LiveTv /// The name. public string Name { get; set; } + /// + /// Gets or sets the identifier. + /// + /// The identifier. public string Id { get; set; } + + /// + /// Gets or sets the number. + /// + /// The number. + public string Number { get; set; } /// /// Gets or sets the name of the service. diff --git a/MediaBrowser.Model/LiveTv/EpgFullInfo.cs b/MediaBrowser.Model/LiveTv/EpgFullInfo.cs deleted file mode 100644 index 8e48537b82..0000000000 --- a/MediaBrowser.Model/LiveTv/EpgFullInfo.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Collections.Generic; - -namespace MediaBrowser.Model.LiveTv -{ - public class EpgFullInfo - { - /// - /// ChannelId for the EPG. - /// - public string ChannelId { get; set; } - - /// - /// List of all the programs for a specific channel - /// - public List EpgInfos { get; set; } - } -} diff --git a/MediaBrowser.Model/LiveTv/EpgInfo.cs b/MediaBrowser.Model/LiveTv/EpgInfo.cs deleted file mode 100644 index c600648829..0000000000 --- a/MediaBrowser.Model/LiveTv/EpgInfo.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; - -namespace MediaBrowser.Model.LiveTv -{ - public class EpgInfo - { - /// - /// Id of the program. - /// - public string Id { get; set; } - - /// - /// Name of the program - /// - public string Name { get; set; } - - /// - /// Description of the progam. - /// - public string Description { get; set; } - - /// - /// The start date of the program, in UTC. - /// - public DateTime StartDate { get; set; } - - /// - /// The end date of the program, in UTC. - /// - public DateTime EndDate { get; set; } - - /// - /// Genre of the program. - /// - public string Genre { get; set; } - } -} \ No newline at end of file diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 48f2987785..6ff6fcf736 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -60,8 +60,9 @@ - - + + + diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 0b36c80239..05bac17c3b 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -40,13 +40,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv Name = info.Name, ServiceName = info.ServiceName, ChannelType = info.ChannelType, - Id = info.Id + Id = info.Id, + Number = info.Number }; } - - public RecordingInfo GetRecordingInfo(RecordingInfo info) - { - return info; - } } }