update sat/ip discovery
This commit is contained in:
parent
dd6a4eefe5
commit
749037eb4a
|
@ -42,11 +42,6 @@ namespace MediaBrowser.Model.ApiClient
|
||||||
existing.DateLastAccessed = server.DateLastAccessed;
|
existing.DateLastAccessed = server.DateLastAccessed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server.DateLastLocalConnection > existing.DateLastLocalConnection)
|
|
||||||
{
|
|
||||||
existing.DateLastLocalConnection = server.DateLastLocalConnection;
|
|
||||||
}
|
|
||||||
|
|
||||||
existing.UserLinkType = server.UserLinkType;
|
existing.UserLinkType = server.UserLinkType;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(server.AccessToken))
|
if (!string.IsNullOrEmpty(server.AccessToken))
|
||||||
|
|
|
@ -19,7 +19,6 @@ namespace MediaBrowser.Model.ApiClient
|
||||||
public String AccessToken { get; set; }
|
public String AccessToken { get; set; }
|
||||||
public List<WakeOnLanInfo> WakeOnLanInfos { get; set; }
|
public List<WakeOnLanInfo> WakeOnLanInfos { get; set; }
|
||||||
public DateTime DateLastAccessed { get; set; }
|
public DateTime DateLastAccessed { get; set; }
|
||||||
public DateTime DateLastLocalConnection { get; set; }
|
|
||||||
public String ExchangeToken { get; set; }
|
public String ExchangeToken { get; set; }
|
||||||
public UserLinkType? UserLinkType { get; set; }
|
public UserLinkType? UserLinkType { get; set; }
|
||||||
public ConnectionMode? LastConnectionMode { get; set; }
|
public ConnectionMode? LastConnectionMode { get; set; }
|
||||||
|
|
|
@ -32,6 +32,9 @@ namespace MediaBrowser.Model.LiveTv
|
||||||
public string DeviceId { get; set; }
|
public string DeviceId { get; set; }
|
||||||
public bool ImportFavoritesOnly { get; set; }
|
public bool ImportFavoritesOnly { get; set; }
|
||||||
public bool IsEnabled { get; set; }
|
public bool IsEnabled { get; set; }
|
||||||
|
public string M3UUrl { get; set; }
|
||||||
|
public string FriendlyName { get; set; }
|
||||||
|
public int Tuners { get; set; }
|
||||||
|
|
||||||
public int DataVersion { get; set; }
|
public int DataVersion { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -1008,6 +1008,19 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
|
|
||||||
private IEnumerable<TimerInfo> GetTimersForSeries(SeriesTimerInfo seriesTimer, IEnumerable<ProgramInfo> allPrograms, IReadOnlyList<RecordingInfo> currentRecordings)
|
private IEnumerable<TimerInfo> GetTimersForSeries(SeriesTimerInfo seriesTimer, IEnumerable<ProgramInfo> allPrograms, IReadOnlyList<RecordingInfo> currentRecordings)
|
||||||
{
|
{
|
||||||
|
if (seriesTimer == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("seriesTimer");
|
||||||
|
}
|
||||||
|
if (allPrograms == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("allPrograms");
|
||||||
|
}
|
||||||
|
if (currentRecordings == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("currentRecordings");
|
||||||
|
}
|
||||||
|
|
||||||
// Exclude programs that have already ended
|
// Exclude programs that have already ended
|
||||||
allPrograms = allPrograms.Where(i => i.EndDate > DateTime.UtcNow && i.StartDate > DateTime.UtcNow);
|
allPrograms = allPrograms.Where(i => i.EndDate > DateTime.UtcNow && i.StartDate > DateTime.UtcNow);
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using CommonIO;
|
using CommonIO;
|
||||||
using MediaBrowser.Common.IO;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
{
|
{
|
||||||
|
@ -35,9 +34,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
{
|
{
|
||||||
if (_items == null)
|
if (_items == null)
|
||||||
{
|
{
|
||||||
|
Logger.Info("Loading live tv data from {0}", _dataPath);
|
||||||
_items = GetItemsFromFile(_dataPath);
|
_items = GetItemsFromFile(_dataPath);
|
||||||
}
|
}
|
||||||
return _items;
|
return _items.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
Logger.ErrorException("Error deserializing {0}", ex, jsonFile);
|
Logger.ErrorException("Error deserializing {0}", ex, jsonFile);
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,15 +22,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
||||||
private readonly ILiveTvManager _liveTvManager;
|
private readonly ILiveTvManager _liveTvManager;
|
||||||
private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);
|
private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);
|
||||||
private readonly IHttpClient _httpClient;
|
private readonly IHttpClient _httpClient;
|
||||||
private IJsonSerializer _json;
|
private readonly IJsonSerializer _json;
|
||||||
|
|
||||||
public HdHomerunDiscovery(IDeviceDiscovery deviceDiscovery, IServerConfigurationManager config, ILogger logger, ILiveTvManager liveTvManager, IHttpClient httpClient)
|
public HdHomerunDiscovery(IDeviceDiscovery deviceDiscovery, IServerConfigurationManager config, ILogger logger, ILiveTvManager liveTvManager, IHttpClient httpClient, IJsonSerializer json)
|
||||||
{
|
{
|
||||||
_deviceDiscovery = deviceDiscovery;
|
_deviceDiscovery = deviceDiscovery;
|
||||||
_config = config;
|
_config = config;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_liveTvManager = liveTvManager;
|
_liveTvManager = liveTvManager;
|
||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
|
_json = json;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
|
|
|
@ -14,7 +14,6 @@ using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Dlna;
|
using MediaBrowser.Controller.Dlna;
|
||||||
using MediaBrowser.Controller.LiveTv;
|
using MediaBrowser.Controller.LiveTv;
|
||||||
using MediaBrowser.Controller.Plugins;
|
using MediaBrowser.Controller.Plugins;
|
||||||
using MediaBrowser.Model.Extensions;
|
|
||||||
using MediaBrowser.Model.LiveTv;
|
using MediaBrowser.Model.LiveTv;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
|
@ -33,13 +32,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
|
||||||
|
|
||||||
public static SatIpDiscovery Current;
|
public static SatIpDiscovery Current;
|
||||||
|
|
||||||
private readonly List<TunerHostInfo> _discoveredHosts = new List<TunerHostInfo>();
|
|
||||||
|
|
||||||
public List<TunerHostInfo> DiscoveredHosts
|
|
||||||
{
|
|
||||||
get { return _discoveredHosts.ToList(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public SatIpDiscovery(IDeviceDiscovery deviceDiscovery, IServerConfigurationManager config, ILogger logger, ILiveTvManager liveTvManager, IHttpClient httpClient, IJsonSerializer json)
|
public SatIpDiscovery(IDeviceDiscovery deviceDiscovery, IServerConfigurationManager config, ILogger logger, ILiveTvManager liveTvManager, IHttpClient httpClient, IJsonSerializer json)
|
||||||
{
|
{
|
||||||
_deviceDiscovery = deviceDiscovery;
|
_deviceDiscovery = deviceDiscovery;
|
||||||
|
@ -83,7 +75,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_discoveredHosts.Any(i => string.Equals(i.Type, SatIpHost.DeviceType, StringComparison.OrdinalIgnoreCase) && string.Equals(location, i.Url, StringComparison.OrdinalIgnoreCase)))
|
var options = GetConfiguration();
|
||||||
|
|
||||||
|
if (options.TunerHosts.Any(i => string.Equals(i.Type, SatIpHost.DeviceType, StringComparison.OrdinalIgnoreCase) && UriEquals(i.Url, location)))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +85,33 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
|
||||||
_logger.Debug("Will attempt to add SAT device {0}", location);
|
_logger.Debug("Will attempt to add SAT device {0}", location);
|
||||||
var info = await GetInfo(location, CancellationToken.None).ConfigureAwait(false);
|
var info = await GetInfo(location, CancellationToken.None).ConfigureAwait(false);
|
||||||
|
|
||||||
_discoveredHosts.Add(info);
|
var existing = GetConfiguration().TunerHosts
|
||||||
|
.FirstOrDefault(i => string.Equals(i.Type, SatIpHost.DeviceType, StringComparison.OrdinalIgnoreCase) && string.Equals(i.DeviceId, info.DeviceId, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
if (existing == null)
|
||||||
|
{
|
||||||
|
await _liveTvManager.SaveTunerHost(new TunerHostInfo
|
||||||
|
{
|
||||||
|
Type = SatIpHost.DeviceType,
|
||||||
|
Url = location,
|
||||||
|
DataVersion = 1,
|
||||||
|
DeviceId = info.DeviceId,
|
||||||
|
FriendlyName = info.FriendlyName,
|
||||||
|
Tuners = info.Tuners
|
||||||
|
|
||||||
|
}).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!string.Equals(existing.Url, location, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
existing.Url = location;
|
||||||
|
existing.M3UUrl = info.M3UUrl;
|
||||||
|
existing.FriendlyName = info.FriendlyName;
|
||||||
|
existing.Tuners = info.Tuners;
|
||||||
|
await _liveTvManager.SaveTunerHost(existing).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
|
@ -111,6 +131,29 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool UriEquals(string savedUri, string location)
|
||||||
|
{
|
||||||
|
return string.Equals(NormalizeUrl(location), NormalizeUrl(savedUri), StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string NormalizeUrl(string url)
|
||||||
|
{
|
||||||
|
if (!url.StartsWith("http", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
url = "http://" + url;
|
||||||
|
}
|
||||||
|
|
||||||
|
url = url.TrimEnd('/');
|
||||||
|
|
||||||
|
// Strip off the port
|
||||||
|
return new Uri(url).GetComponents(UriComponents.AbsoluteUri & ~UriComponents.Port, UriFormat.UriEscaped);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LiveTvOptions GetConfiguration()
|
||||||
|
{
|
||||||
|
return _config.GetConfiguration<LiveTvOptions>("livetv");
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -158,7 +201,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(result.Id))
|
if (string.IsNullOrWhiteSpace(result.DeviceId))
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
@ -192,7 +235,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
|
||||||
{
|
{
|
||||||
case "UDN":
|
case "UDN":
|
||||||
{
|
{
|
||||||
info.Id = reader.ReadElementContentAsString();
|
info.DeviceId = reader.ReadElementContentAsString();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,9 +286,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
|
||||||
|
|
||||||
public class SatIpTunerHostInfo : TunerHostInfo
|
public class SatIpTunerHostInfo : TunerHostInfo
|
||||||
{
|
{
|
||||||
public int Tuners { get; set; }
|
|
||||||
public int TunersAvailable { get; set; }
|
public int TunersAvailable { get; set; }
|
||||||
public string M3UUrl { get; set; }
|
|
||||||
public string FriendlyName { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
|
||||||
|
|
||||||
protected override async Task<IEnumerable<ChannelInfo>> GetChannelsInternal(TunerHostInfo tuner, CancellationToken cancellationToken)
|
protected override async Task<IEnumerable<ChannelInfo>> GetChannelsInternal(TunerHostInfo tuner, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var satInfo = (SatIpTunerHostInfo)tuner;
|
return await new M3uParser(Logger, _fileSystem, _httpClient).Parse(tuner.M3UUrl, ChannelIdPrefix, tuner.Id, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
return await new M3uParser(Logger, _fileSystem, _httpClient).Parse(satInfo.M3UUrl, ChannelIdPrefix, tuner.Id, cancellationToken).ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string DeviceType
|
public static string DeviceType
|
||||||
|
@ -128,11 +126,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
|
||||||
return channelId.StartsWith(ChannelIdPrefix, StringComparison.OrdinalIgnoreCase);
|
return channelId.StartsWith(ChannelIdPrefix, StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override List<TunerHostInfo> GetTunerHosts()
|
|
||||||
{
|
|
||||||
return SatIpDiscovery.Current.DiscoveredHosts;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return "Sat IP"; }
|
get { return "Sat IP"; }
|
||||||
|
@ -149,15 +142,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
|
||||||
|
|
||||||
public List<LiveTvTunerInfo> GetTunerInfos(TunerHostInfo info, CancellationToken cancellationToken)
|
public List<LiveTvTunerInfo> GetTunerInfos(TunerHostInfo info, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var satInfo = (SatIpTunerHostInfo)info;
|
|
||||||
|
|
||||||
var list = new List<LiveTvTunerInfo>();
|
var list = new List<LiveTvTunerInfo>();
|
||||||
|
|
||||||
for (var i = 0; i < satInfo.Tuners; i++)
|
for (var i = 0; i < info.Tuners; i++)
|
||||||
{
|
{
|
||||||
list.Add(new LiveTvTunerInfo
|
list.Add(new LiveTvTunerInfo
|
||||||
{
|
{
|
||||||
Name = satInfo.FriendlyName ?? Name,
|
Name = info.FriendlyName ?? Name,
|
||||||
SourceType = Type,
|
SourceType = Type,
|
||||||
Status = LiveTvTunerStatus.Available,
|
Status = LiveTvTunerStatus.Available,
|
||||||
Id = info.Url.GetMD5().ToString("N") + i.ToString(CultureInfo.InvariantCulture),
|
Id = info.Url.GetMD5().ToString("N") + i.ToString(CultureInfo.InvariantCulture),
|
||||||
|
|
|
@ -272,6 +272,9 @@
|
||||||
<Content Include="dashboard-ui\livetvtunerprovider-m3u.html">
|
<Content Include="dashboard-ui\livetvtunerprovider-m3u.html">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="dashboard-ui\livetvtunerprovider-satip.html">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="dashboard-ui\mypreferenceshome.html">
|
<Content Include="dashboard-ui\mypreferenceshome.html">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
@ -302,6 +305,9 @@
|
||||||
<Content Include="dashboard-ui\scripts\livetvtunerprovider-m3u.js">
|
<Content Include="dashboard-ui\scripts\livetvtunerprovider-m3u.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="dashboard-ui\scripts\livetvtunerprovider-satip.js">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="dashboard-ui\scripts\localsync.js">
|
<Content Include="dashboard-ui\scripts\localsync.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user