|
|
@ -41,29 +41,21 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
|
|
|
|
|
|
|
|
|
|
|
|
void _deviceDiscovery_DeviceDiscovered(object sender, SsdpMessageEventArgs e)
|
|
|
|
void _deviceDiscovery_DeviceDiscovered(object sender, SsdpMessageEventArgs e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//string server = null;
|
|
|
|
string st = null;
|
|
|
|
//if (e.Headers.TryGetValue("SERVER", out server) && server.IndexOf("HDHomeRun", StringComparison.OrdinalIgnoreCase) != -1)
|
|
|
|
if (e.Headers.TryGetValue("ST", out st) && string.Equals(st, "urn:ses-com:device:SatIPServer:1", StringComparison.OrdinalIgnoreCase))
|
|
|
|
//{
|
|
|
|
{
|
|
|
|
// string location;
|
|
|
|
string location;
|
|
|
|
// if (e.Headers.TryGetValue("Location", out location))
|
|
|
|
if (e.Headers.TryGetValue("Location", out location) && !string.IsNullOrWhiteSpace(location))
|
|
|
|
// {
|
|
|
|
{
|
|
|
|
// //_logger.Debug("HdHomerun found at {0}", location);
|
|
|
|
_logger.Debug("SAT IP found at {0}", location);
|
|
|
|
|
|
|
|
|
|
|
|
// // Just get the beginning of the url
|
|
|
|
|
|
|
|
// Uri uri;
|
|
|
|
|
|
|
|
// if (Uri.TryCreate(location, UriKind.Absolute, out uri))
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// var apiUrl = location.Replace(uri.LocalPath, String.Empty, StringComparison.OrdinalIgnoreCase)
|
|
|
|
|
|
|
|
// .TrimEnd('/');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //_logger.Debug("HdHomerun api url: {0}", apiUrl);
|
|
|
|
// Just get the beginning of the url
|
|
|
|
// AddDevice(apiUrl);
|
|
|
|
AddDevice(location);
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async void AddDevice(string url)
|
|
|
|
private async void AddDevice(string location)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await _semaphore.WaitAsync().ConfigureAwait(false);
|
|
|
|
await _semaphore.WaitAsync().ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
@ -71,24 +63,24 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var options = GetConfiguration();
|
|
|
|
var options = GetConfiguration();
|
|
|
|
|
|
|
|
|
|
|
|
if (options.TunerHosts.Any(i =>
|
|
|
|
//if (options.TunerHosts.Any(i =>
|
|
|
|
string.Equals(i.Type, SatIpHost.DeviceType, StringComparison.OrdinalIgnoreCase) &&
|
|
|
|
// string.Equals(i.Type, SatIpHost.DeviceType, StringComparison.OrdinalIgnoreCase) &&
|
|
|
|
UriEquals(i.Url, url)))
|
|
|
|
// UriEquals(i.Url, url)))
|
|
|
|
{
|
|
|
|
//{
|
|
|
|
return;
|
|
|
|
// return;
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
// Strip off the port
|
|
|
|
//// Strip off the port
|
|
|
|
url = new Uri(url).GetComponents(UriComponents.AbsoluteUri & ~UriComponents.Port, UriFormat.UriEscaped).TrimEnd('/');
|
|
|
|
//url = new Uri(url).GetComponents(UriComponents.AbsoluteUri & ~UriComponents.Port, UriFormat.UriEscaped).TrimEnd('/');
|
|
|
|
|
|
|
|
|
|
|
|
await TestUrl(url).ConfigureAwait(false);
|
|
|
|
//await TestUrl(url).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
|
await _liveTvManager.SaveTunerHost(new TunerHostInfo
|
|
|
|
//await _liveTvManager.SaveTunerHost(new TunerHostInfo
|
|
|
|
{
|
|
|
|
//{
|
|
|
|
Type = SatIpHost.DeviceType,
|
|
|
|
// Type = SatIpHost.DeviceType,
|
|
|
|
Url = url
|
|
|
|
// Url = url
|
|
|
|
|
|
|
|
|
|
|
|
}).ConfigureAwait(false);
|
|
|
|
//}).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|