update listing providers

This commit is contained in:
Luke Pulverenti 2016-02-24 14:06:26 -05:00
parent 10d4ad98d9
commit ae859fd56f
7 changed files with 45 additions and 13 deletions

View File

@ -25,6 +25,12 @@ namespace MediaBrowser.Controller.LiveTv
/// <value>The id of the channel.</value> /// <value>The id of the channel.</value>
public string Id { get; set; } public string Id { get; set; }
/// <summary>
/// Gets or sets the tuner host identifier.
/// </summary>
/// <value>The tuner host identifier.</value>
public string TunerHostId { get; set; }
/// <summary> /// <summary>
/// Gets or sets the type of the channel. /// Gets or sets the type of the channel.
/// </summary> /// </summary>

View File

@ -15,7 +15,7 @@ namespace MediaBrowser.Model.LiveTv
public int PrePaddingSeconds { get; set; } public int PrePaddingSeconds { get; set; }
public int PostPaddingSeconds { get; set; } public int PostPaddingSeconds { get; set; }
public LiveTvOptions() public LiveTvOptions()
{ {
EnableMovieProviders = true; EnableMovieProviders = true;
@ -48,5 +48,14 @@ namespace MediaBrowser.Model.LiveTv
public string ZipCode { get; set; } public string ZipCode { get; set; }
public string Country { get; set; } public string Country { get; set; }
public string Path { get; set; } public string Path { get; set; }
public string[] EnabledTuners { get; set; }
public bool EnableAllTuners { get; set; }
public ListingsProviderInfo()
{
EnabledTuners = new string[] { };
EnableAllTuners = true;
}
} }
} }

View File

@ -210,9 +210,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
} }
} }
if (list.Count > 0) foreach (var provider in GetListingProviders())
{ {
foreach (var provider in GetListingProviders()) var enabledChannels = list
.Where(i => IsListingProviderEnabledForTuner(provider.Item2, i.TunerHostId))
.ToList();
if (enabledChannels.Count > 0)
{ {
try try
{ {
@ -228,6 +232,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
} }
} }
} }
_channelCache = list; _channelCache = list;
return list; return list;
} }
@ -489,6 +494,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
} }
} }
private bool IsListingProviderEnabledForTuner(ListingsProviderInfo info, string tunerHostId)
{
return info.EnableAllTuners || info.EnabledTuners.Contains(tunerHostId ?? string.Empty, StringComparer.OrdinalIgnoreCase);
}
private async Task<IEnumerable<ProgramInfo>> GetProgramsAsyncInternal(string channelId, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken) private async Task<IEnumerable<ProgramInfo>> GetProgramsAsyncInternal(string channelId, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken)
{ {
var channels = await GetChannelsAsync(true, cancellationToken).ConfigureAwait(false); var channels = await GetChannelsAsync(true, cancellationToken).ConfigureAwait(false);
@ -496,6 +506,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
foreach (var provider in GetListingProviders()) foreach (var provider in GetListingProviders())
{ {
if (!IsListingProviderEnabledForTuner(provider.Item2, channel.TunerHostId))
{
continue;
}
var programs = await provider.Item1.GetProgramsAsync(provider.Item2, channel.Number, channel.Name, startDateUtc, endDateUtc, cancellationToken) var programs = await provider.Item1.GetProgramsAsync(provider.Item2, channel.Number, channel.Name, startDateUtc, endDateUtc, cancellationToken)
.ConfigureAwait(false); .ConfigureAwait(false);

View File

@ -66,7 +66,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun
Name = i.GuideName, Name = i.GuideName,
Number = i.GuideNumber.ToString(CultureInfo.InvariantCulture), Number = i.GuideNumber.ToString(CultureInfo.InvariantCulture),
Id = ChannelIdPrefix + i.GuideNumber.ToString(CultureInfo.InvariantCulture) + '_' + (i.GuideName ?? string.Empty).GetMD5().ToString("N"), Id = ChannelIdPrefix + i.GuideNumber.ToString(CultureInfo.InvariantCulture) + '_' + (i.GuideName ?? string.Empty).GetMD5().ToString("N"),
IsFavorite = i.Favorite IsFavorite = i.Favorite,
TunerHostId = info.Id
}); });

View File

@ -44,7 +44,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts
protected override async Task<IEnumerable<ChannelInfo>> GetChannelsInternal(TunerHostInfo info, CancellationToken cancellationToken) protected override async Task<IEnumerable<ChannelInfo>> GetChannelsInternal(TunerHostInfo info, CancellationToken cancellationToken)
{ {
return await new M3uParser(Logger, _fileSystem, _httpClient).Parse(info.Url, ChannelIdPrefix, cancellationToken).ConfigureAwait(false); return await new M3uParser(Logger, _fileSystem, _httpClient).Parse(info.Url, ChannelIdPrefix, info.Id, cancellationToken).ConfigureAwait(false);
} }
public Task<List<LiveTvTunerInfo>> GetTunerInfos(CancellationToken cancellationToken) public Task<List<LiveTvTunerInfo>> GetTunerInfos(CancellationToken cancellationToken)

View File

@ -25,14 +25,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts
_httpClient = httpClient; _httpClient = httpClient;
} }
public async Task<List<M3UChannel>> Parse(string url, string channelIdPrefix, CancellationToken cancellationToken) public async Task<List<M3UChannel>> Parse(string url, string channelIdPrefix, string tunerHostId, CancellationToken cancellationToken)
{ {
var urlHash = url.GetMD5().ToString("N"); var urlHash = url.GetMD5().ToString("N");
// Read the file and display it line by line. // Read the file and display it line by line.
using (var reader = new StreamReader(await GetListingsStream(url, cancellationToken).ConfigureAwait(false))) using (var reader = new StreamReader(await GetListingsStream(url, cancellationToken).ConfigureAwait(false)))
{ {
return GetChannels(reader, urlHash, channelIdPrefix); return GetChannels(reader, urlHash, channelIdPrefix, tunerHostId);
} }
} }
@ -45,7 +45,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts
return Task.FromResult(_fileSystem.OpenRead(url)); return Task.FromResult(_fileSystem.OpenRead(url));
} }
private List<M3UChannel> GetChannels(StreamReader reader, string urlHash, string channelIdPrefix) private List<M3UChannel> GetChannels(StreamReader reader, string urlHash, string channelIdPrefix, string tunerHostId)
{ {
var channels = new List<M3UChannel>(); var channels = new List<M3UChannel>();
string line; string line;
@ -69,8 +69,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts
_logger.Info("Found m3u channel: {0}", extInf); _logger.Info("Found m3u channel: {0}", extInf);
} }
else if (!string.IsNullOrWhiteSpace(extInf)) else if (!string.IsNullOrWhiteSpace(extInf))
{ {
var channel = GetChannelnfo(extInf); var channel = GetChannelnfo(extInf, tunerHostId);
channel.Id = channelIdPrefix + urlHash + line.GetMD5().ToString("N"); channel.Id = channelIdPrefix + urlHash + line.GetMD5().ToString("N");
channel.Path = line; channel.Path = line;
channels.Add(channel); channels.Add(channel);
@ -79,10 +79,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts
} }
return channels; return channels;
} }
public M3UChannel GetChannelnfo(string extInf) private M3UChannel GetChannelnfo(string extInf, string tunerHostId)
{ {
var titleIndex = extInf.LastIndexOf(','); var titleIndex = extInf.LastIndexOf(',');
var channel = new M3UChannel(); var channel = new M3UChannel();
channel.TunerHostId = tunerHostId;
channel.Number = extInf.Trim().Split(' ')[0] ?? "0"; channel.Number = extInf.Trim().Split(' ')[0] ?? "0";
channel.Name = extInf.Substring(titleIndex + 1); channel.Name = extInf.Substring(titleIndex + 1);
@ -108,7 +109,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts
return channel; return channel;
} }
public string FindProperty(string property, string properties, string defaultResult = "") private string FindProperty(string property, string properties, string defaultResult = "")
{ {
var reg = new Regex(@"([a-z0-9\-_]+)=\""([^""]+)\""", RegexOptions.IgnoreCase); var reg = new Regex(@"([a-z0-9\-_]+)=\""([^""]+)\""", RegexOptions.IgnoreCase);
var matches = reg.Matches(properties); var matches = reg.Matches(properties);

View File

@ -37,7 +37,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
{ {
var satInfo = (SatIpTunerHostInfo) tuner; var satInfo = (SatIpTunerHostInfo) tuner;
return await new M3uParser(Logger, _fileSystem, _httpClient).Parse(satInfo.M3UUrl, ChannelIdPrefix, cancellationToken).ConfigureAwait(false); return await new M3uParser(Logger, _fileSystem, _httpClient).Parse(satInfo.M3UUrl, ChannelIdPrefix, tuner.Id, cancellationToken).ConfigureAwait(false);
} }
public static string DeviceType public static string DeviceType