mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
support additional m3u fields
This commit is contained in:
parent
ad8b43cc3d
commit
fd3c6f7ecc
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CommonIO;
|
using CommonIO;
|
||||||
@ -51,7 +52,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts
|
|||||||
string channnelName = null;
|
string channnelName = null;
|
||||||
string channelNumber = null;
|
string channelNumber = null;
|
||||||
string line;
|
string line;
|
||||||
|
string imageUrl = null;
|
||||||
while ((line = reader.ReadLine()) != null)
|
while ((line = reader.ReadLine()) != null)
|
||||||
{
|
{
|
||||||
line = line.Trim();
|
line = line.Trim();
|
||||||
@ -70,8 +71,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts
|
|||||||
line = line.Substring(8);
|
line = line.Substring(8);
|
||||||
_logger.Info("Found m3u channel: {0}", line);
|
_logger.Info("Found m3u channel: {0}", line);
|
||||||
var parts = line.Split(new[] { ',' }, 2);
|
var parts = line.Split(new[] { ',' }, 2);
|
||||||
channelNumber = parts[0];
|
channelNumber = parts[0].Trim().Split(' ')[0] ?? "0";
|
||||||
channnelName = parts[1];
|
channnelName = FindProperty("tvg-name", line, parts[1]);
|
||||||
|
imageUrl = FindProperty("tvg-logo", line, null);
|
||||||
}
|
}
|
||||||
else if (!string.IsNullOrWhiteSpace(channelNumber))
|
else if (!string.IsNullOrWhiteSpace(channelNumber))
|
||||||
{
|
{
|
||||||
@ -80,23 +82,34 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts
|
|||||||
Name = channnelName,
|
Name = channnelName,
|
||||||
Number = channelNumber,
|
Number = channelNumber,
|
||||||
Id = channelIdPrefix + urlHash + line.GetMD5().ToString("N"),
|
Id = channelIdPrefix + urlHash + line.GetMD5().ToString("N"),
|
||||||
Path = line
|
ImageUrl = imageUrl
|
||||||
});
|
});
|
||||||
|
|
||||||
|
imageUrl = null;
|
||||||
channelNumber = null;
|
channelNumber = null;
|
||||||
channnelName = null;
|
channnelName = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return channels;
|
return channels;
|
||||||
}
|
}
|
||||||
|
public string FindProperty(string property, string properties, string defaultResult = "")
|
||||||
|
{
|
||||||
|
var reg = new Regex(@"([a-z0-9\-_]+)=\""([^""]+)\""", RegexOptions.IgnoreCase);
|
||||||
|
var matches = reg.Matches(properties);
|
||||||
|
foreach (Match match in matches)
|
||||||
|
{
|
||||||
|
if (match.Groups[1].Value == property)
|
||||||
|
{
|
||||||
|
return match.Groups[2].Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultResult;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class M3UChannel : ChannelInfo
|
public class M3UChannel : ChannelInfo
|
||||||
{
|
{
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
|
|
||||||
public M3UChannel()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user