updated nuget for live tv

This commit is contained in:
Luke Pulverenti 2013-11-25 11:15:31 -05:00
parent fe7b8a0d96
commit 4054846a6e
14 changed files with 124 additions and 61 deletions

View File

@ -80,8 +80,8 @@ namespace MediaBrowser.Api.Images
public string Id { get; set; }
}
[Route("/LiveTV/Channels/{Id}/Images/{Type}", "GET")]
[Route("/LiveTV/Channels/{Id}/Images/{Type}/{Index}", "GET")]
[Route("/LiveTv/Channels/{Id}/Images/{Type}", "GET")]
[Route("/LiveTv/Channels/{Id}/Images/{Type}/{Index}", "GET")]
[Api(Description = "Gets an item image")]
public class GetChannelImage : ImageRequest
{

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.LiveTv;
using System;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Model.LiveTv;
using ServiceStack.ServiceHost;
using System.Collections.Generic;
@ -50,9 +51,9 @@ namespace MediaBrowser.Api.LiveTv
public string ServiceName { get; set; }
}
[Route("/LiveTv/Guide", "GET")]
[Route("/LiveTv/Programs", "GET")]
[Api(Description = "Gets available live tv epgs..")]
public class GetGuide : IReturn<List<ChannelGuide>>
public class GetPrograms : IReturn<List<ProgramInfo>>
{
[ApiMember(Name = "ServiceName", Description = "Live tv service name", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
public string ServiceName { get; set; }
@ -143,21 +144,15 @@ namespace MediaBrowser.Api.LiveTv
return recordings.SelectMany(i => i);
}
public object Get(GetGuide request)
public object Get(GetPrograms request)
{
var result = GetGuideAsync(request).Result;
return ToOptimizedResult(result);
}
private async Task<IEnumerable<ChannelGuide>> GetGuideAsync(GetGuide request)
var result = _liveTvManager.GetPrograms(new ProgramQuery
{
var service = GetServices(request.ServiceName)
.First();
ServiceName = request.ServiceName,
ChannelIdList = (request.ChannelIds ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray()
});
var channels = request.ChannelIds.Split(',');
return await service.GetChannelGuidesAsync(channels, CancellationToken.None).ConfigureAwait(false);
return ToOptimizedResult(result.ToList());
}
}
}

View File

@ -40,5 +40,12 @@ namespace MediaBrowser.Controller.LiveTv
/// <param name="id">The identifier.</param>
/// <returns>Channel.</returns>
Channel GetChannel(string id);
/// <summary>
/// Gets the programs.
/// </summary>
/// <param name="query">The query.</param>
/// <returns>IEnumerable{ProgramInfo}.</returns>
IEnumerable<ProgramInfo> GetPrograms(ProgramQuery query);
}
}

View File

@ -61,11 +61,11 @@ namespace MediaBrowser.Controller.LiveTv
Task<IEnumerable<RecordingInfo>> GetRecordingsAsync(RecordingQuery query, CancellationToken cancellationToken);
/// <summary>
/// Gets the channel guides.
/// Gets the channel guide.
/// </summary>
/// <param name="channelIdList">The channel identifier list.</param>
/// <param name="channelId">The channel identifier.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{IEnumerable{ChannelGuide}}.</returns>
Task<IEnumerable<ChannelGuide>> GetChannelGuidesAsync(IEnumerable<string> channelIdList, CancellationToken cancellationToken);
/// <returns>Task{IEnumerable{ProgramInfo}}.</returns>
Task<IEnumerable<ProgramInfo>> GetChannelGuideAsync(string channelId, CancellationToken cancellationToken);
}
}

View File

@ -224,9 +224,6 @@
<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>
@ -242,6 +239,9 @@
<Compile Include="..\MediaBrowser.Model\LiveTv\ProgramInfo.cs">
<Link>LiveTv\ProgramInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\ProgramQuery.cs">
<Link>LiveTv\ProgramQuery.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\RecordingInfo.cs">
<Link>LiveTv\RecordingInfo.cs</Link>
</Compile>

View File

@ -211,9 +211,6 @@
<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>
@ -229,6 +226,9 @@
<Compile Include="..\MediaBrowser.Model\LiveTv\ProgramInfo.cs">
<Link>LiveTv\ProgramInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\ProgramQuery.cs">
<Link>LiveTv\ProgramQuery.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\LiveTv\RecordingInfo.cs">
<Link>LiveTv\RecordingInfo.cs</Link>
</Compile>

View File

@ -1,23 +0,0 @@
using System.Collections.Generic;
namespace MediaBrowser.Model.LiveTv
{
public class ChannelGuide
{
/// <summary>
/// Gets or sets the name of the service.
/// </summary>
/// <value>The name of the service.</value>
public string ServiceName { get; set; }
/// <summary>
/// ChannelId for the EPG.
/// </summary>
public string ChannelId { get; set; }
/// <summary>
/// List of all the programs for a specific channel
/// </summary>
public List<ProgramInfo> Programs { get; set; }
}
}

View File

@ -9,6 +9,24 @@ namespace MediaBrowser.Model.LiveTv
/// </summary>
public string Id { get; set; }
/// <summary>
/// Gets or sets the channel identifier.
/// </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; }
/// <summary>
/// Gets or sets the external channel identifier.
/// </summary>
/// <value>The external channel identifier.</value>
public string ExternalChannelId { get; set; }
/// <summary>
/// Name of the program
/// </summary>

View File

@ -0,0 +1,25 @@
namespace MediaBrowser.Model.LiveTv
{
/// <summary>
/// Class ProgramQuery.
/// </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>
/// <value>The channel identifier.</value>
public string[] ChannelIdList { get; set; }
public ProgramQuery()
{
ChannelIdList = new string[] { };
}
}
}

View File

@ -60,10 +60,10 @@
<Compile Include="Dto\ItemCounts.cs" />
<Compile Include="Dto\ItemIndex.cs" />
<Compile Include="Entities\PackageReviewInfo.cs" />
<Compile Include="LiveTv\ChannelGuide.cs" />
<Compile Include="LiveTv\ChannelInfoDto.cs" />
<Compile Include="LiveTv\ChannelQuery.cs" />
<Compile Include="LiveTv\ProgramInfo.cs" />
<Compile Include="LiveTv\ProgramQuery.cs" />
<Compile Include="LiveTv\RecordingQuery.cs" />
<Compile Include="Providers\ImageProviderInfo.cs" />
<Compile Include="Providers\RemoteImageInfo.cs" />

View File

@ -29,6 +29,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
private List<Channel> _channels = new List<Channel>();
private Dictionary<Guid, List<ProgramInfo>> _guide = new Dictionary<Guid, List<ProgramInfo>>();
private readonly List<ILiveTvService> _services = new List<ILiveTvService>();
public LiveTvManager(IServerApplicationPaths appPaths, IFileSystem fileSystem, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor)
@ -79,6 +81,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
};
}
private ILiveTvService GetService(ChannelInfo channel)
{
return _services.FirstOrDefault(i => string.Equals(channel.ServiceName, i.Name, StringComparison.OrdinalIgnoreCase));
}
private Guid? GetLogoImageTag(Channel info)
{
var path = info.PrimaryImagePath;
@ -137,16 +144,30 @@ namespace MediaBrowser.Server.Implementations.LiveTv
var allChannels = results.SelectMany(i => i).ToList();
var list = new List<Channel>();
var guide = new Dictionary<Guid, List<ProgramInfo>>();
var numComplete = 0;
foreach (var channel in allChannels)
foreach (var channelInfo in allChannels)
{
try
{
var item = await GetChannel(channel, cancellationToken).ConfigureAwait(false);
var item = await GetChannel(channelInfo, cancellationToken).ConfigureAwait(false);
var service = GetService(channelInfo);
var programs = await service.GetChannelGuideAsync(channelInfo.Id, cancellationToken).ConfigureAwait(false);
var programList = programs.ToList();
foreach (var program in programList)
{
program.ExternalChannelId = channelInfo.Id;
program.ChannelId = item.Id.ToString("N");
program.ServiceName = service.Name;
}
list.Add(item);
guide[item.Id] = programList;
}
catch (OperationCanceledException)
{
@ -154,7 +175,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
}
catch (Exception ex)
{
_logger.ErrorException("Error getting channel information for {0}", ex, channel.Name);
_logger.ErrorException("Error getting channel information for {0}", ex, channelInfo.Name);
}
numComplete++;
@ -164,6 +185,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
progress.Report(90 * percent + 10);
}
_guide = guide;
_channels = list;
}
@ -218,5 +240,24 @@ namespace MediaBrowser.Server.Implementations.LiveTv
return item;
}
public IEnumerable<ProgramInfo> GetPrograms(ProgramQuery query)
{
var programs = _guide.Values.SelectMany(i => i);
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();
programs = programs.Where(i => guids.Contains(new Guid(i.ChannelId)));
}
return programs;
}
}
}

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common.Internal</id>
<version>3.0.246</version>
<version>3.0.247</version>
<title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.246" />
<dependency id="MediaBrowser.Common" version="3.0.247" />
<dependency id="NLog" version="2.1.0" />
<dependency id="ServiceStack.Text" version="3.9.58" />
<dependency id="SimpleInjector" version="2.3.6" />

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common</id>
<version>3.0.246</version>
<version>3.0.247</version>
<title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Server.Core</id>
<version>3.0.246</version>
<version>3.0.247</version>
<title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Media Browser Server.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.246" />
<dependency id="MediaBrowser.Common" version="3.0.247" />
</dependencies>
</metadata>
<files>