mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-24 14:40:39 +02:00
fix m3u tuner host only finding one channel
This commit is contained in:
parent
c135bb17f2
commit
c7684178ce
|
@ -46,55 +46,61 @@ 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)
|
||||||
{
|
{
|
||||||
var url = info.Url;
|
var urlHash = info.Url.GetMD5().ToString("N");
|
||||||
var urlHash = url.GetMD5().ToString("N");
|
|
||||||
|
|
||||||
string line;
|
|
||||||
// Read the file and display it line by line.
|
// Read the file and display it line by line.
|
||||||
using (var file = new StreamReader(await GetListingsStream(info, cancellationToken).ConfigureAwait(false)))
|
using (var reader = new StreamReader(await GetListingsStream(info, cancellationToken).ConfigureAwait(false)))
|
||||||
{
|
{
|
||||||
var channels = new List<M3UChannel>();
|
return GetChannels(reader, urlHash);
|
||||||
|
|
||||||
string channnelName = null;
|
|
||||||
string channelNumber = null;
|
|
||||||
|
|
||||||
while ((line = file.ReadLine()) != null)
|
|
||||||
{
|
|
||||||
line = line.Trim();
|
|
||||||
if (string.IsNullOrWhiteSpace(line))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (line.StartsWith("#EXTM3U", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (line.StartsWith("#EXTINF:", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
var parts = line.Split(new[] { ':' }, 2).Last().Split(new[] { ',' }, 2);
|
|
||||||
channelNumber = parts[0];
|
|
||||||
channnelName = parts[1];
|
|
||||||
}
|
|
||||||
else if (!string.IsNullOrWhiteSpace(channelNumber))
|
|
||||||
{
|
|
||||||
channels.Add(new M3UChannel
|
|
||||||
{
|
|
||||||
Name = channnelName,
|
|
||||||
Number = channelNumber,
|
|
||||||
Id = ChannelIdPrefix + urlHash + channelNumber,
|
|
||||||
Path = line
|
|
||||||
});
|
|
||||||
|
|
||||||
channelNumber = null;
|
|
||||||
channnelName = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return channels;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<M3UChannel> GetChannels(StreamReader reader, string urlHash)
|
||||||
|
{
|
||||||
|
var channels = new List<M3UChannel>();
|
||||||
|
|
||||||
|
string channnelName = null;
|
||||||
|
string channelNumber = null;
|
||||||
|
string line;
|
||||||
|
|
||||||
|
while ((line = reader.ReadLine()) != null)
|
||||||
|
{
|
||||||
|
line = line.Trim();
|
||||||
|
if (string.IsNullOrWhiteSpace(line))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line.StartsWith("#EXTM3U", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line.StartsWith("#EXTINF:", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
line = line.Substring(8);
|
||||||
|
Logger.Info("Found m3u channel: {0}", line);
|
||||||
|
var parts = line.Split(new[] { ',' }, 2);
|
||||||
|
channelNumber = parts[0];
|
||||||
|
channnelName = parts[1];
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrWhiteSpace(channelNumber))
|
||||||
|
{
|
||||||
|
channels.Add(new M3UChannel
|
||||||
|
{
|
||||||
|
Name = channnelName,
|
||||||
|
Number = channelNumber,
|
||||||
|
Id = ChannelIdPrefix + urlHash + line.GetMD5().ToString("N"),
|
||||||
|
Path = line
|
||||||
|
});
|
||||||
|
|
||||||
|
channelNumber = null;
|
||||||
|
channnelName = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return channels;
|
||||||
|
}
|
||||||
|
|
||||||
public Task<List<LiveTvTunerInfo>> GetTunerInfos(CancellationToken cancellationToken)
|
public Task<List<LiveTvTunerInfo>> GetTunerInfos(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var list = GetConfiguration().TunerHosts
|
var list = GetConfiguration().TunerHosts
|
||||||
|
@ -159,8 +165,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//channelId = channelId.Substring(prefix.Length);
|
|
||||||
|
|
||||||
var channels = await GetChannels(info, true, cancellationToken).ConfigureAwait(false);
|
var channels = await GetChannels(info, true, cancellationToken).ConfigureAwait(false);
|
||||||
var m3uchannels = channels.Cast<M3UChannel>();
|
var m3uchannels = channels.Cast<M3UChannel>();
|
||||||
var channel = m3uchannels.FirstOrDefault(c => string.Equals(c.Id, channelId, StringComparison.OrdinalIgnoreCase));
|
var channel = m3uchannels.FirstOrDefault(c => string.Equals(c.Id, channelId, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
Loading…
Reference in a new issue