From 24fcde7d917d3991bcdf51dde8fb4437bc378888 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 12 Mar 2016 15:16:42 -0500 Subject: [PATCH 1/4] update fonts --- .../MediaBrowser.WebDashboard.csproj | 75 ------------------- 1 file changed, 75 deletions(-) diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index be8dbaeae..5b8e2932a 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -1609,84 +1609,9 @@ - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - PreserveNewest - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - PreserveNewest From 146547b02e80b9224fa414238cd0e737c2a482d6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 12 Mar 2016 22:30:23 -0500 Subject: [PATCH 2/4] add error handling to recording parsing --- MediaBrowser.Api/TvShowsService.cs | 2 +- .../LiveTv/EmbyTV/ItemDataProvider.cs | 17 ++++++++++++++++- .../MediaBrowser.WebDashboard.csproj | 3 --- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.cs index 2dad9533f..2873dd8b4 100644 --- a/MediaBrowser.Api/TvShowsService.cs +++ b/MediaBrowser.Api/TvShowsService.cs @@ -273,7 +273,7 @@ namespace MediaBrowser.Api { var user = _userManager.GetUserById(request.UserId); - var minPremiereDate = DateTime.Now.Date.AddDays(-1).ToUniversalTime(); + var minPremiereDate = DateTime.Now.Date.ToUniversalTime(); var parentIds = string.IsNullOrWhiteSpace(request.ParentId) ? new string[] { } : new[] { request.ParentId }; diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs index 68b3f1f71..a4eb23d99 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs @@ -47,7 +47,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV try { - return _jsonSerializer.DeserializeFromFile>(jsonFile); + return _jsonSerializer.DeserializeFromFile>(jsonFile) ?? new List(); } catch (FileNotFoundException) { @@ -69,6 +69,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV private void UpdateList(List newList) { + if (newList == null) + { + throw new ArgumentNullException("newList"); + } + var file = _dataPath + ".json"; _fileSystem.CreateDirectory(Path.GetDirectoryName(file)); @@ -81,6 +86,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV public virtual void Update(T item) { + if (item == null) + { + throw new ArgumentNullException("item"); + } + var list = GetAll().ToList(); var index = list.FindIndex(i => EqualityComparer(i, item)); @@ -97,6 +107,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV public virtual void Add(T item) { + if (item == null) + { + throw new ArgumentNullException("item"); + } + var list = GetAll().ToList(); if (list.Any(i => EqualityComparer(i, item))) diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 5b8e2932a..74bc05fe8 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -341,9 +341,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest From dd6a4eefe5b1ea65b284d07f2f5aed3527b66f24 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 12 Mar 2016 22:30:42 -0500 Subject: [PATCH 3/4] support single tmdb urls in nfo --- MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index 30243ff57..7362ee58f 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -195,8 +195,20 @@ namespace MediaBrowser.XbmcMetadata.Parsers item.SetProviderId(MetadataProviders.Imdb, m.Value); } - // TODO: Support Tmdb + // Support Tmdb // http://www.themoviedb.org/movie/36557 + var srch = "themoviedb.org/movie/"; + var index = xml.IndexOf(srch, StringComparison.OrdinalIgnoreCase); + + if (index != -1) + { + var tmdbId = xml.Substring(index + srch.Length).TrimEnd('/'); + int value; + if (!string.IsNullOrWhiteSpace(tmdbId) && int.TryParse(tmdbId, NumberStyles.Any, CultureInfo.InvariantCulture, out value)) + { + item.SetProviderId(MetadataProviders.Tmdb, tmdbId); + } + } } protected virtual void FetchDataFromXmlNode(XmlReader reader, MetadataResult itemResult) From 749037eb4a73c9ae4b66c787a381737427dd6eca Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 13 Mar 2016 03:34:17 -0400 Subject: [PATCH 4/4] update sat/ip discovery --- .../ApiClient/ServerCredentials.cs | 5 -- MediaBrowser.Model/ApiClient/ServerInfo.cs | 1 - MediaBrowser.Model/LiveTv/LiveTvOptions.cs | 3 + .../LiveTv/EmbyTV/EmbyTV.cs | 13 ++++ .../LiveTv/EmbyTV/ItemDataProvider.cs | 5 +- .../HdHomerun/HdHomerunDiscovery.cs | 5 +- .../LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs | 72 ++++++++++++++----- .../LiveTv/TunerHosts/SatIp/SatIpHost.cs | 15 +--- .../MediaBrowser.WebDashboard.csproj | 6 ++ 9 files changed, 86 insertions(+), 39 deletions(-) diff --git a/MediaBrowser.Model/ApiClient/ServerCredentials.cs b/MediaBrowser.Model/ApiClient/ServerCredentials.cs index f9af0fa4e..0f0ab65d4 100644 --- a/MediaBrowser.Model/ApiClient/ServerCredentials.cs +++ b/MediaBrowser.Model/ApiClient/ServerCredentials.cs @@ -41,11 +41,6 @@ namespace MediaBrowser.Model.ApiClient { existing.DateLastAccessed = server.DateLastAccessed; } - - if (server.DateLastLocalConnection > existing.DateLastLocalConnection) - { - existing.DateLastLocalConnection = server.DateLastLocalConnection; - } existing.UserLinkType = server.UserLinkType; diff --git a/MediaBrowser.Model/ApiClient/ServerInfo.cs b/MediaBrowser.Model/ApiClient/ServerInfo.cs index 53ae5be52..e1fa581d7 100644 --- a/MediaBrowser.Model/ApiClient/ServerInfo.cs +++ b/MediaBrowser.Model/ApiClient/ServerInfo.cs @@ -19,7 +19,6 @@ namespace MediaBrowser.Model.ApiClient public String AccessToken { get; set; } public List WakeOnLanInfos { get; set; } public DateTime DateLastAccessed { get; set; } - public DateTime DateLastLocalConnection { get; set; } public String ExchangeToken { get; set; } public UserLinkType? UserLinkType { get; set; } public ConnectionMode? LastConnectionMode { get; set; } diff --git a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs index c6b8385b0..78c683064 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs +++ b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs @@ -32,6 +32,9 @@ namespace MediaBrowser.Model.LiveTv public string DeviceId { get; set; } public bool ImportFavoritesOnly { 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; } diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index aa4583ef8..e00a68e32 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -1008,6 +1008,19 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV private IEnumerable GetTimersForSeries(SeriesTimerInfo seriesTimer, IEnumerable allPrograms, IReadOnlyList 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 allPrograms = allPrograms.Where(i => i.EndDate > DateTime.UtcNow && i.StartDate > DateTime.UtcNow); diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs index a4eb23d99..79b26468e 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using CommonIO; -using MediaBrowser.Common.IO; namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV { @@ -35,9 +34,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV { if (_items == null) { + Logger.Info("Loading live tv data from {0}", _dataPath); _items = GetItemsFromFile(_dataPath); } - return _items; + return _items.ToList(); } } @@ -58,7 +58,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV catch (IOException ex) { Logger.ErrorException("Error deserializing {0}", ex, jsonFile); - throw; } catch (Exception ex) { diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs index aa4030b81..9ba1c60cc 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs @@ -22,15 +22,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun private readonly ILiveTvManager _liveTvManager; private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1); 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; _config = config; _logger = logger; _liveTvManager = liveTvManager; _httpClient = httpClient; + _json = json; } public void Run() diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs index 6781e498a..9a02413cd 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpDiscovery.cs @@ -14,7 +14,6 @@ using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.LiveTv; using MediaBrowser.Controller.Plugins; -using MediaBrowser.Model.Extensions; using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Serialization; @@ -33,13 +32,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp public static SatIpDiscovery Current; - private readonly List _discoveredHosts = new List(); - - public List DiscoveredHosts - { - get { return _discoveredHosts.ToList(); } - } - public SatIpDiscovery(IDeviceDiscovery deviceDiscovery, IServerConfigurationManager config, ILogger logger, ILiveTvManager liveTvManager, IHttpClient httpClient, IJsonSerializer json) { _deviceDiscovery = deviceDiscovery; @@ -83,15 +75,43 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp 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; } - + _logger.Debug("Will attempt to add SAT device {0}", location); 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) { @@ -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("livetv"); + } + 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(); } @@ -192,7 +235,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp { case "UDN": { - info.Id = reader.ReadElementContentAsString(); + info.DeviceId = reader.ReadElementContentAsString(); break; } @@ -243,9 +286,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp public class SatIpTunerHostInfo : TunerHostInfo { - public int Tuners { get; set; } public int TunersAvailable { get; set; } - public string M3UUrl { get; set; } - public string FriendlyName { get; set; } } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpHost.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpHost.cs index d305a886a..4bbb7e85c 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpHost.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/SatIpHost.cs @@ -35,9 +35,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp protected override async Task> GetChannelsInternal(TunerHostInfo tuner, CancellationToken cancellationToken) { - var satInfo = (SatIpTunerHostInfo)tuner; - - return await new M3uParser(Logger, _fileSystem, _httpClient).Parse(satInfo.M3UUrl, ChannelIdPrefix, tuner.Id, cancellationToken).ConfigureAwait(false); + return await new M3uParser(Logger, _fileSystem, _httpClient).Parse(tuner.M3UUrl, ChannelIdPrefix, tuner.Id, cancellationToken).ConfigureAwait(false); } public static string DeviceType @@ -128,11 +126,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp return channelId.StartsWith(ChannelIdPrefix, StringComparison.OrdinalIgnoreCase); } - protected override List GetTunerHosts() - { - return SatIpDiscovery.Current.DiscoveredHosts; - } - public string Name { get { return "Sat IP"; } @@ -149,15 +142,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp public List GetTunerInfos(TunerHostInfo info, CancellationToken cancellationToken) { - var satInfo = (SatIpTunerHostInfo)info; - var list = new List(); - for (var i = 0; i < satInfo.Tuners; i++) + for (var i = 0; i < info.Tuners; i++) { list.Add(new LiveTvTunerInfo { - Name = satInfo.FriendlyName ?? Name, + Name = info.FriendlyName ?? Name, SourceType = Type, Status = LiveTvTunerStatus.Available, Id = info.Url.GetMD5().ToString("N") + i.ToString(CultureInfo.InvariantCulture), diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 74bc05fe8..fb52b58b7 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -272,6 +272,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -302,6 +305,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest