mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
update sat/ip
This commit is contained in:
parent
d5b7ed325e
commit
e13fcb3cd4
@ -31,20 +31,26 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
|||||||
_appHost = appHost;
|
_appHost = appHost;
|
||||||
_config = config;
|
_config = config;
|
||||||
_ssdp = ssdp;
|
_ssdp = ssdp;
|
||||||
|
|
||||||
|
_config.ConfigurationUpdated += _config_ConfigurationUpdated;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void _config_ConfigurationUpdated(object sender, EventArgs e)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
//NatUtility.Logger = new LogWriter(_logger);
|
Discover();
|
||||||
|
|
||||||
if (_config.Configuration.EnableUPnP)
|
|
||||||
{
|
|
||||||
Discover();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void Discover()
|
private async void Discover()
|
||||||
{
|
{
|
||||||
|
if (!_config.Configuration.EnableUPnP)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var discoverer = new NatDiscoverer();
|
var discoverer = new NatDiscoverer();
|
||||||
|
|
||||||
var cancellationTokenSource = new CancellationTokenSource(10000);
|
var cancellationTokenSource = new CancellationTokenSource(10000);
|
||||||
|
@ -15,6 +15,7 @@ using MediaBrowser.Model.LiveTv;
|
|||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using MediaBrowser.Model.Extensions;
|
using MediaBrowser.Model.Extensions;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
|
namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
|
||||||
{
|
{
|
||||||
@ -171,58 +172,87 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
|
|||||||
|
|
||||||
public async Task<SatIpTunerHostInfo> GetInfo(string url, CancellationToken cancellationToken)
|
public async Task<SatIpTunerHostInfo> GetInfo(string url, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var result = new SatIpTunerHostInfo
|
Uri locationUri = new Uri(url);
|
||||||
|
string devicetype = "";
|
||||||
|
string friendlyname = "";
|
||||||
|
string uniquedevicename = "";
|
||||||
|
string manufacturer = "";
|
||||||
|
string manufacturerurl = "";
|
||||||
|
string modelname = "";
|
||||||
|
string modeldescription = "";
|
||||||
|
string modelnumber = "";
|
||||||
|
string modelurl = "";
|
||||||
|
string serialnumber = "";
|
||||||
|
string presentationurl = "";
|
||||||
|
string capabilities = "";
|
||||||
|
string m3u = "";
|
||||||
|
var document = XDocument.Load(locationUri.AbsoluteUri);
|
||||||
|
var xnm = new XmlNamespaceManager(new NameTable());
|
||||||
|
XNamespace n1 = "urn:ses-com:satip";
|
||||||
|
XNamespace n0 = "urn:schemas-upnp-org:device-1-0";
|
||||||
|
xnm.AddNamespace("root", n0.NamespaceName);
|
||||||
|
xnm.AddNamespace("satip:", n1.NamespaceName);
|
||||||
|
if (document.Root != null)
|
||||||
{
|
{
|
||||||
Url = url,
|
var deviceElement = document.Root.Element(n0 + "device");
|
||||||
IsEnabled = true,
|
if (deviceElement != null)
|
||||||
Type = SatIpHost.DeviceType,
|
|
||||||
Tuners = 1,
|
|
||||||
TunersAvailable = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
using (var stream = await _httpClient.Get(url, cancellationToken).ConfigureAwait(false))
|
|
||||||
{
|
|
||||||
using (var streamReader = new StreamReader(stream))
|
|
||||||
{
|
{
|
||||||
// Use XmlReader for best performance
|
var devicetypeElement = deviceElement.Element(n0 + "deviceType");
|
||||||
using (var reader = XmlReader.Create(streamReader))
|
if (devicetypeElement != null)
|
||||||
{
|
devicetype = devicetypeElement.Value;
|
||||||
reader.MoveToContent();
|
var friendlynameElement = deviceElement.Element(n0 + "friendlyName");
|
||||||
|
if (friendlynameElement != null)
|
||||||
// Loop through each element
|
friendlyname = friendlynameElement.Value;
|
||||||
while (reader.Read())
|
var manufactureElement = deviceElement.Element(n0 + "manufacturer");
|
||||||
{
|
if (manufactureElement != null)
|
||||||
if (reader.NodeType == XmlNodeType.Element)
|
manufacturer = manufactureElement.Value;
|
||||||
{
|
var manufactureurlElement = deviceElement.Element(n0 + "manufacturerURL");
|
||||||
switch (reader.Name)
|
if (manufactureurlElement != null)
|
||||||
{
|
manufacturerurl = manufactureurlElement.Value;
|
||||||
case "device":
|
var modeldescriptionElement = deviceElement.Element(n0 + "modelDescription");
|
||||||
using (var subtree = reader.ReadSubtree())
|
if (modeldescriptionElement != null)
|
||||||
{
|
modeldescription = modeldescriptionElement.Value;
|
||||||
FillFromDeviceNode(result, subtree);
|
var modelnameElement = deviceElement.Element(n0 + "modelName");
|
||||||
}
|
if (modelnameElement != null)
|
||||||
break;
|
modelname = modelnameElement.Value;
|
||||||
default:
|
var modelnumberElement = deviceElement.Element(n0 + "modelNumber");
|
||||||
reader.Skip();
|
if (modelnumberElement != null)
|
||||||
break;
|
modelnumber = modelnumberElement.Value;
|
||||||
}
|
var modelurlElement = deviceElement.Element(n0 + "modelURL");
|
||||||
}
|
if (modelurlElement != null)
|
||||||
}
|
modelurl = modelurlElement.Value;
|
||||||
}
|
var serialnumberElement = deviceElement.Element(n0 + "serialNumber");
|
||||||
|
if (serialnumberElement != null)
|
||||||
|
serialnumber = serialnumberElement.Value;
|
||||||
|
var uniquedevicenameElement = deviceElement.Element(n0 + "UDN");
|
||||||
|
if (uniquedevicenameElement != null) uniquedevicename = uniquedevicenameElement.Value;
|
||||||
|
var presentationUrlElement = deviceElement.Element(n0 + "presentationURL");
|
||||||
|
if (presentationUrlElement != null) presentationurl = presentationUrlElement.Value;
|
||||||
|
var capabilitiesElement = deviceElement.Element(n1 + "X_SATIPCAP");
|
||||||
|
if (capabilitiesElement != null) capabilities = capabilitiesElement.Value;
|
||||||
|
var m3uElement = deviceElement.Element(n1 + "X_SATIPM3U");
|
||||||
|
if (m3uElement != null) m3u = m3uElement.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(result.DeviceId))
|
|
||||||
|
var result = new SatIpTunerHostInfo
|
||||||
|
{
|
||||||
|
Url = url,
|
||||||
|
Id = uniquedevicename,
|
||||||
|
IsEnabled = true,
|
||||||
|
Type = SatIpHost.DeviceType,
|
||||||
|
Tuners = 1,
|
||||||
|
TunersAvailable = 1,
|
||||||
|
M3UUrl = m3u
|
||||||
|
};
|
||||||
|
|
||||||
|
result.FriendlyName = friendlyname;
|
||||||
|
if (string.IsNullOrWhiteSpace(result.Id))
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Device hasn't implemented an m3u list
|
|
||||||
if (string.IsNullOrWhiteSpace(result.M3UUrl))
|
|
||||||
{
|
|
||||||
result.IsEnabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (!result.M3UUrl.StartsWith("http", StringComparison.OrdinalIgnoreCase))
|
else if (!result.M3UUrl.StartsWith("http", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var fullM3uUrl = url.Substring(0, url.LastIndexOf('/'));
|
var fullM3uUrl = url.Substring(0, url.LastIndexOf('/'));
|
||||||
@ -233,66 +263,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FillFromDeviceNode(SatIpTunerHostInfo info, XmlReader reader)
|
|
||||||
{
|
|
||||||
reader.MoveToContent();
|
|
||||||
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
if (reader.NodeType == XmlNodeType.Element)
|
|
||||||
{
|
|
||||||
switch (reader.LocalName)
|
|
||||||
{
|
|
||||||
case "UDN":
|
|
||||||
{
|
|
||||||
info.DeviceId = reader.ReadElementContentAsString();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "friendlyName":
|
|
||||||
{
|
|
||||||
info.FriendlyName = reader.ReadElementContentAsString();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "satip:X_SATIPCAP":
|
|
||||||
case "X_SATIPCAP":
|
|
||||||
{
|
|
||||||
// <satip:X_SATIPCAP xmlns:satip="urn:ses-com:satip">DVBS2-2</satip:X_SATIPCAP>
|
|
||||||
var value = reader.ReadElementContentAsString() ?? string.Empty;
|
|
||||||
var parts = value.Split(new[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
if (parts.Length == 2)
|
|
||||||
{
|
|
||||||
int intValue;
|
|
||||||
if (int.TryParse(parts[1], NumberStyles.Any, CultureInfo.InvariantCulture, out intValue))
|
|
||||||
{
|
|
||||||
info.TunersAvailable = intValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (int.TryParse(parts[0].Substring(parts[0].Length - 1), NumberStyles.Any, CultureInfo.InvariantCulture, out intValue))
|
|
||||||
{
|
|
||||||
info.Tuners = intValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "satip:X_SATIPM3U":
|
|
||||||
case "X_SATIPM3U":
|
|
||||||
{
|
|
||||||
// <satip:X_SATIPM3U xmlns:satip="urn:ses-com:satip">/channellist.lua?select=m3u</satip:X_SATIPM3U>
|
|
||||||
info.M3UUrl = reader.ReadElementContentAsString();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
reader.Skip();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SatIpTunerHostInfo : TunerHostInfo
|
public class SatIpTunerHostInfo : TunerHostInfo
|
||||||
|
@ -103,6 +103,7 @@
|
|||||||
<Reference Include="ServiceStack.Text">
|
<Reference Include="ServiceStack.Text">
|
||||||
<HintPath>..\ThirdParty\ServiceStack.Text\ServiceStack.Text.dll</HintPath>
|
<HintPath>..\ThirdParty\ServiceStack.Text\ServiceStack.Text.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="UniversalDetector">
|
<Reference Include="UniversalDetector">
|
||||||
<HintPath>..\ThirdParty\UniversalDetector\UniversalDetector.dll</HintPath>
|
<HintPath>..\ThirdParty\UniversalDetector\UniversalDetector.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user