Updated live tv api

pull/702/head
Luke Pulverenti 11 years ago
parent a09e330d4e
commit 83d70c54ec

@ -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<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; }
[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<EpgFullInfo> GetEpgAsync(GetEpg request)
private async Task<IEnumerable<ChannelGuide>> 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);
}
}
}

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

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

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

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

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

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

@ -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; }
}
}

@ -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; }
}
}

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

Loading…
Cancel
Save