update m3u channel mapping

This commit is contained in:
Luke Pulverenti
2017-02-23 14:13:26 -05:00
parent e391ee1b17
commit c33b12ba7d
6 changed files with 49 additions and 41 deletions

View File

@@ -136,11 +136,26 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
channel.Name = GetChannelName(extInf, attributes);
channel.Number = GetChannelNumber(extInf, attributes, mediaUrl);
var channelId = GetTunerChannelId(attributes);
string tvgId;
attributes.TryGetValue("tvg-id", out tvgId);
string channelId;
attributes.TryGetValue("channel-id", out channelId);
channel.TunerChannelId = string.IsNullOrWhiteSpace(tvgId) ? channelId : tvgId;
var channelIdValues = new List<string>();
if (!string.IsNullOrWhiteSpace(channelId))
{
channel.Id = channelId;
channel.TunerChannelId = channelId;
channelIdValues.Add(channelId);
}
if (!string.IsNullOrWhiteSpace(tvgId))
{
channelIdValues.Add(tvgId);
}
if (channelIdValues.Count > 0)
{
channel.Id = string.Join("_", channelIdValues.ToArray());
}
return channel;
@@ -296,24 +311,6 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
return name;
}
private string GetTunerChannelId(Dictionary<string, string> attributes)
{
var values = new List<string>();
string result;
if (attributes.TryGetValue("tvg-id", out result))
{
values.Add(result);
}
if (attributes.TryGetValue("channel-id", out result))
{
values.Add(result);
}
return values.Count == 0 ? null : string.Join("-", values.ToArray());
}
private Dictionary<string, string> ParseExtInf(string line, out string remaining)
{
var dict = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);