Skip to content

Commit

Permalink
stubbed out channel mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
LukePulverenti committed Jun 6, 2016
1 parent 9e34f6c commit 170241f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
3 changes: 3 additions & 0 deletions MediaBrowser.Model/LiveTv/LiveTvOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using MediaBrowser.Model.Dto;

namespace MediaBrowser.Model.LiveTv
{
Expand Down Expand Up @@ -77,6 +78,7 @@ public class ListingsProviderInfo
public string[] SportsCategories { get; set; }
public string[] KidsCategories { get; set; }
public string[] MovieCategories { get; set; }
public NameValuePair[] ChannelMappings { get; set; }

public ListingsProviderInfo()
{
Expand All @@ -86,6 +88,7 @@ public ListingsProviderInfo()
MovieCategories = new string[] { "movie" };
EnabledTuners = new string[] { };
EnableAllTuners = true;
ChannelMappings = new NameValuePair[] {};
}
}
}
23 changes: 22 additions & 1 deletion MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,16 @@ private async Task<IEnumerable<ProgramInfo>> GetProgramsAsyncInternal(string cha

_logger.Debug("Getting programs for channel {0}-{1} from {2}-{3}", channel.Number, channel.Name, provider.Item1.Name, provider.Item2.ListingsId ?? string.Empty);

var programs = await provider.Item1.GetProgramsAsync(provider.Item2, channel.Number, channel.Name, startDateUtc, endDateUtc, cancellationToken)
var channelMappings = GetChannelMappings(provider.Item2);
var channelNumber = channel.Number;
string mappedChannelNumber;
if (channelMappings.TryGetValue(channelNumber, out mappedChannelNumber))
{
_logger.Debug("Found mapped channel on provider {0}. Tuner channel number: {1}, Mapped channel number: {2}", provider.Item1.Name, channelNumber, mappedChannelNumber);
channelNumber = mappedChannelNumber;
}

var programs = await provider.Item1.GetProgramsAsync(provider.Item2, channelNumber, channel.Name, startDateUtc, endDateUtc, cancellationToken)
.ConfigureAwait(false);

var list = programs.ToList();
Expand All @@ -647,6 +656,18 @@ private async Task<IEnumerable<ProgramInfo>> GetProgramsAsyncInternal(string cha
return new List<ProgramInfo>();
}

private Dictionary<string, string> GetChannelMappings(ListingsProviderInfo info)
{
var dict = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

foreach (var mapping in info.ChannelMappings)
{
dict[mapping.Name] = mapping.Value;
}

return dict;
}

private List<Tuple<IListingsProvider, ListingsProviderInfo>> GetListingProviders()
{
return GetConfiguration().ListingProviders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ public class XmlTvListingsProvider : IListingsProvider
{
private readonly IServerConfigurationManager _config;

private Dictionary<string, string> _channelMappings = new Dictionary<string, string>(){
{ "1", "UK_RT_2667" },
{ "2", "UK_RT_116" },
{ "3", "UK_RT_2118" },
{ "4", "UK_RT_2056" },
{ "5", "UK_RT_134" }
};

public XmlTvListingsProvider(IServerConfigurationManager config)
{
_config = config;
Expand All @@ -51,11 +43,6 @@ public Task<IEnumerable<ProgramInfo>> GetProgramsAsync(ListingsProviderInfo info
var reader = new XmlTvReader(info.Path, GetLanguage(), null);
string mappedChannel = channelNumber;

if (_channelMappings.ContainsKey(channelNumber))
{
mappedChannel = _channelMappings[channelNumber];
}

var results = reader.GetProgrammes(mappedChannel, startDateUtc, endDateUtc, cancellationToken);
return Task.FromResult(results.Select(p => new ProgramInfo()
{
Expand Down

0 comments on commit 170241f

Please sign in to comment.