Updated live tv api

This commit is contained in:
Luke Pulverenti 2013-11-15 16:31:44 -05:00
parent a09e330d4e
commit 83d70c54ec
11 changed files with 63 additions and 94 deletions

View file

@ -32,17 +32,17 @@ namespace MediaBrowser.Api.LiveTv
public string ServiceName { get; set; } public string ServiceName { get; set; }
} }
[Route("/LiveTv/EPG", "GET")] [Route("/LiveTv/Guide", "GET")]
[Api(Description = "Gets available live tv epgs..")] [Api(Description = "Gets available live tv epgs..")]
public class GetEpg : IReturn<EpgFullInfo> public class GetGuide : IReturn<List<ChannelGuide>>
{ {
[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; } public string ServiceName { get; set; }
[ApiMember(Name = "ChannelId", Description = "The channel id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")] [ApiMember(Name = "ChannelIds", Description = "The channels to return guide information for.", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
public string ChannelId { get; set; } public string ChannelIds { get; set; }
} }
public class LiveTvService : BaseApiService public class LiveTvService : BaseApiService
{ {
private readonly ILiveTvManager _liveTvManager; private readonly ILiveTvManager _liveTvManager;
@ -112,28 +112,33 @@ namespace MediaBrowser.Api.LiveTv
{ {
var services = GetServices(request.ServiceName); 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); 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); return ToOptimizedResult(result);
} }
private async Task<EpgFullInfo> GetEpgAsync(GetEpg request) private async Task<IEnumerable<ChannelGuide>> GetGuideAsync(GetGuide request)
{ {
var service = GetServices(request.ServiceName) var service = GetServices(request.ServiceName)
.First(); .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);
} }
} }
} }

View file

@ -13,6 +13,12 @@ namespace MediaBrowser.Controller.LiveTv
/// <value>The name.</value> /// <value>The name.</value>
public string Name { get; set; } public string Name { get; set; }
/// <summary>
/// Gets or sets the number.
/// </summary>
/// <value>The number.</value>
public string Number { get; set; }
/// <summary> /// <summary>
/// Get or sets the Id. /// Get or sets the Id.
/// </summary> /// </summary>

View file

@ -27,7 +27,5 @@ namespace MediaBrowser.Controller.LiveTv
/// <param name="info">The info.</param> /// <param name="info">The info.</param>
/// <returns>ChannelInfoDto.</returns> /// <returns>ChannelInfoDto.</returns>
ChannelInfoDto GetChannelInfoDto(ChannelInfo info); ChannelInfoDto GetChannelInfoDto(ChannelInfo info);
RecordingInfo GetRecordingInfo(RecordingInfo info);
} }
} }

View file

@ -26,16 +26,17 @@ namespace MediaBrowser.Controller.LiveTv
/// <summary> /// <summary>
/// Gets the recordings asynchronous. /// Gets the recordings asynchronous.
/// </summary> /// </summary>
/// <param name="query">The query.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{IEnumerable{RecordingInfo}}.</returns> /// <returns>Task{IEnumerable{RecordingInfo}}.</returns>
Task<IEnumerable<RecordingInfo>> GetRecordingsAsync(CancellationToken cancellationToken); Task<IEnumerable<RecordingInfo>> GetRecordingsAsync(RecordingQuery query, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Gets the epg asynchronous. /// Gets the channel guides.
/// </summary> /// </summary>
/// <param name="channelId">The channel identifier.</param> /// <param name="channelIdList">The channel identifier list.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{EpgFullInfo}.</returns> /// <returns>Task{IEnumerable{ChannelGuide}}.</returns>
Task<EpgFullInfo> GetEpgAsync(string channelId, CancellationToken cancellationToken); Task<IEnumerable<ChannelGuide>> GetChannelGuidesAsync(IEnumerable<string> channelIdList, CancellationToken cancellationToken);
} }
} }

View file

@ -224,24 +224,27 @@
<Compile Include="..\MediaBrowser.Model\IO\IZipClient.cs"> <Compile Include="..\MediaBrowser.Model\IO\IZipClient.cs">
<Link>IO\IZipClient.cs</Link> <Link>IO\IZipClient.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\ChannelGuide.cs">
<Link>LiveTv\ChannelGuide.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\ChannelInfoDto.cs"> <Compile Include="..\MediaBrowser.Model\LiveTv\ChannelInfoDto.cs">
<Link>LiveTv\ChannelInfoDto.cs</Link> <Link>LiveTv\ChannelInfoDto.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\ChannelType.cs"> <Compile Include="..\MediaBrowser.Model\LiveTv\ChannelType.cs">
<Link>LiveTv\ChannelType.cs</Link> <Link>LiveTv\ChannelType.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\EpgFullInfo.cs">
<Link>LiveTv\EpgFullInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\EpgInfo.cs">
<Link>LiveTv\EpgInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\LiveTvServiceInfo.cs"> <Compile Include="..\MediaBrowser.Model\LiveTv\LiveTvServiceInfo.cs">
<Link>LiveTv\LiveTvServiceInfo.cs</Link> <Link>LiveTv\LiveTvServiceInfo.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\ProgramInfo.cs">
<Link>LiveTv\ProgramInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\RecordingInfo.cs"> <Compile Include="..\MediaBrowser.Model\LiveTv\RecordingInfo.cs">
<Link>LiveTv\RecordingInfo.cs</Link> <Link>LiveTv\RecordingInfo.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\RecordingQuery.cs">
<Link>LiveTv\RecordingQuery.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Logging\ILogger.cs"> <Compile Include="..\MediaBrowser.Model\Logging\ILogger.cs">
<Link>Logging\ILogger.cs</Link> <Link>Logging\ILogger.cs</Link>
</Compile> </Compile>

View file

@ -211,24 +211,27 @@
<Compile Include="..\MediaBrowser.Model\IO\IZipClient.cs"> <Compile Include="..\MediaBrowser.Model\IO\IZipClient.cs">
<Link>IO\IZipClient.cs</Link> <Link>IO\IZipClient.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\ChannelGuide.cs">
<Link>LiveTv\ChannelGuide.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\ChannelInfoDto.cs"> <Compile Include="..\MediaBrowser.Model\LiveTv\ChannelInfoDto.cs">
<Link>LiveTv\ChannelInfoDto.cs</Link> <Link>LiveTv\ChannelInfoDto.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\ChannelType.cs"> <Compile Include="..\MediaBrowser.Model\LiveTv\ChannelType.cs">
<Link>LiveTv\ChannelType.cs</Link> <Link>LiveTv\ChannelType.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\EpgFullInfo.cs">
<Link>LiveTv\EpgFullInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\EpgInfo.cs">
<Link>LiveTv\EpgInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\LiveTvServiceInfo.cs"> <Compile Include="..\MediaBrowser.Model\LiveTv\LiveTvServiceInfo.cs">
<Link>LiveTv\LiveTvServiceInfo.cs</Link> <Link>LiveTv\LiveTvServiceInfo.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\ProgramInfo.cs">
<Link>LiveTv\ProgramInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\RecordingInfo.cs"> <Compile Include="..\MediaBrowser.Model\LiveTv\RecordingInfo.cs">
<Link>LiveTv\RecordingInfo.cs</Link> <Link>LiveTv\RecordingInfo.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\RecordingQuery.cs">
<Link>LiveTv\RecordingQuery.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Logging\ILogger.cs"> <Compile Include="..\MediaBrowser.Model\Logging\ILogger.cs">
<Link>Logging\ILogger.cs</Link> <Link>Logging\ILogger.cs</Link>
</Compile> </Compile>

View file

@ -12,7 +12,17 @@ namespace MediaBrowser.Model.LiveTv
/// <value>The name.</value> /// <value>The name.</value>
public string Name { get; set; } public string Name { get; set; }
/// <summary>
/// Gets or sets the identifier.
/// </summary>
/// <value>The identifier.</value>
public string Id { get; set; } public string Id { get; set; }
/// <summary>
/// Gets or sets the number.
/// </summary>
/// <value>The number.</value>
public string Number { get; set; }
/// <summary> /// <summary>
/// Gets or sets the name of the service. /// Gets or sets the name of the service.

View file

@ -1,17 +0,0 @@
using System.Collections.Generic;
namespace MediaBrowser.Model.LiveTv
{
public class EpgFullInfo
{
/// <summary>
/// ChannelId for the EPG.
/// </summary>
public string ChannelId { get; set; }
/// <summary>
/// List of all the programs for a specific channel
/// </summary>
public List<EpgInfo> EpgInfos { get; set; }
}
}

View file

@ -1,37 +0,0 @@
using System;
namespace MediaBrowser.Model.LiveTv
{
public class EpgInfo
{
/// <summary>
/// Id of the program.
/// </summary>
public string Id { get; set; }
/// <summary>
/// Name of the program
/// </summary>
public string Name { get; set; }
/// <summary>
/// Description of the progam.
/// </summary>
public string Description { get; set; }
/// <summary>
/// The start date of the program, in UTC.
/// </summary>
public DateTime StartDate { get; set; }
/// <summary>
/// The end date of the program, in UTC.
/// </summary>
public DateTime EndDate { get; set; }
/// <summary>
/// Genre of the program.
/// </summary>
public string Genre { get; set; }
}
}

View file

@ -60,8 +60,9 @@
<Compile Include="Dto\ItemCounts.cs" /> <Compile Include="Dto\ItemCounts.cs" />
<Compile Include="Dto\ItemIndex.cs" /> <Compile Include="Dto\ItemIndex.cs" />
<Compile Include="Entities\PackageReviewInfo.cs" /> <Compile Include="Entities\PackageReviewInfo.cs" />
<Compile Include="LiveTv\EpgFullInfo.cs" /> <Compile Include="LiveTv\ChannelGuide.cs" />
<Compile Include="LiveTv\EpgInfo.cs" /> <Compile Include="LiveTv\ProgramInfo.cs" />
<Compile Include="LiveTv\RecordingQuery.cs" />
<Compile Include="Providers\ImageProviderInfo.cs" /> <Compile Include="Providers\ImageProviderInfo.cs" />
<Compile Include="Providers\RemoteImageInfo.cs" /> <Compile Include="Providers\RemoteImageInfo.cs" />
<Compile Include="Dto\StudioDto.cs" /> <Compile Include="Dto\StudioDto.cs" />

View file

@ -40,13 +40,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv
Name = info.Name, Name = info.Name,
ServiceName = info.ServiceName, ServiceName = info.ServiceName,
ChannelType = info.ChannelType, ChannelType = info.ChannelType,
Id = info.Id Id = info.Id,
Number = info.Number
}; };
} }
public RecordingInfo GetRecordingInfo(RecordingInfo info)
{
return info;
}
} }
} }