update m3u parsing

This commit is contained in:
Luke Pulverenti 2017-01-25 15:14:47 -05:00
parent cf470529b1
commit 8f780269cb
5 changed files with 11 additions and 10 deletions

View File

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

View File

@ -33,14 +33,14 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
_appHost = appHost;
}
public async Task<List<M3UChannel>> Parse(string url, string channelIdPrefix, string tunerHostId, CancellationToken cancellationToken)
public async Task<List<M3UChannel>> Parse(string url, string channelIdPrefix, string tunerHostId, bool enableStreamUrlAsIdentifier, CancellationToken cancellationToken)
{
var urlHash = url.GetMD5().ToString("N");
// Read the file and display it line by line.
using (var reader = new StreamReader(await GetListingsStream(url, cancellationToken).ConfigureAwait(false)))
{
return GetChannels(reader, urlHash, channelIdPrefix, tunerHostId);
return GetChannels(reader, urlHash, channelIdPrefix, tunerHostId, enableStreamUrlAsIdentifier);
}
}
@ -51,7 +51,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
// Read the file and display it line by line.
using (var reader = new StringReader(text))
{
return GetChannels(reader, urlHash, channelIdPrefix, tunerHostId);
return GetChannels(reader, urlHash, channelIdPrefix, tunerHostId, false);
}
}
@ -71,7 +71,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
}
const string ExtInfPrefix = "#EXTINF:";
private List<M3UChannel> GetChannels(TextReader reader, string urlHash, string channelIdPrefix, string tunerHostId)
private List<M3UChannel> GetChannels(TextReader reader, string urlHash, string channelIdPrefix, string tunerHostId, bool enableStreamUrlAsIdentifier)
{
var channels = new List<M3UChannel>();
string line;
@ -97,7 +97,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
else if (!string.IsNullOrWhiteSpace(extInf) && !line.StartsWith("#", StringComparison.OrdinalIgnoreCase))
{
var channel = GetChannelnfo(extInf, tunerHostId, line);
if (string.IsNullOrWhiteSpace(channel.Id))
if (string.IsNullOrWhiteSpace(channel.Id) || enableStreamUrlAsIdentifier)
{
channel.Id = channelIdPrefix + urlHash + line.GetMD5().ToString("N");
}

View File

@ -27,7 +27,7 @@ namespace Emby.Server.Implementations.Migrations
public async Task Run()
{
var name = "GuideRefresh1";
var name = "GuideRefresh2";
if (!_config.Configuration.Migrations.Contains(name, StringComparer.OrdinalIgnoreCase))
{

View File

@ -57,6 +57,7 @@ namespace MediaBrowser.Model.LiveTv
public string SourceB { get; set; }
public string SourceC { get; set; }
public string SourceD { get; set; }
public bool EnableTvgId { get; set; }
public TunerHostInfo()
{

View File

@ -44,7 +44,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
{
if (!string.IsNullOrWhiteSpace(tuner.M3UUrl))
{
return await new M3uParser(Logger, _fileSystem, _httpClient, _appHost).Parse(tuner.M3UUrl, ChannelIdPrefix, tuner.Id, cancellationToken).ConfigureAwait(false);
return await new M3uParser(Logger, _fileSystem, _httpClient, _appHost).Parse(tuner.M3UUrl, ChannelIdPrefix, tuner.Id, false, cancellationToken).ConfigureAwait(false);
}
var channels = await new ChannelScan(Logger).Scan(tuner, cancellationToken).ConfigureAwait(false);
@ -181,4 +181,4 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
return streamPath;
}
}
}
}