diff --git a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs index 33f63e3eb2..0e44980df2 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs +++ b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using MediaBrowser.Model.Dto; namespace MediaBrowser.Model.LiveTv { @@ -77,6 +78,7 @@ namespace MediaBrowser.Model.LiveTv public string[] SportsCategories { get; set; } public string[] KidsCategories { get; set; } public string[] MovieCategories { get; set; } + public NameValuePair[] ChannelMappings { get; set; } public ListingsProviderInfo() { @@ -86,6 +88,7 @@ namespace MediaBrowser.Model.LiveTv MovieCategories = new string[] { "movie" }; EnabledTuners = new string[] { }; EnableAllTuners = true; + ChannelMappings = new NameValuePair[] {}; } } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 6e5e8298f9..41c137c295 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -625,7 +625,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV _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(); @@ -647,6 +656,18 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV return new List(); } + private Dictionary GetChannelMappings(ListingsProviderInfo info) + { + var dict = new Dictionary(StringComparer.OrdinalIgnoreCase); + + foreach (var mapping in info.ChannelMappings) + { + dict[mapping.Name] = mapping.Value; + } + + return dict; + } + private List> GetListingProviders() { return GetConfiguration().ListingProviders diff --git a/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs index 4f43d93b70..5b0b2ad84b 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs @@ -17,14 +17,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings { private readonly IServerConfigurationManager _config; - private Dictionary _channelMappings = new Dictionary(){ - { "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; @@ -51,11 +43,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings 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() {