From b19451284351d5b753067522e9ef82b873c08770 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 25 Jul 2015 14:11:46 -0400 Subject: [PATCH] update tuners --- MediaBrowser.Api/LiveTv/LiveTvService.cs | 8 ++++---- MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 2 +- MediaBrowser.Model/LiveTv/LiveTvOptions.cs | 1 + .../LiveTv/LiveTvManager.cs | 4 +++- .../TunerHosts/HdHomerun/HdHomerunDiscovery.cs | 2 +- .../LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs | 9 ++++++++- .../Localization/Server/server.json | 6 ++++-- .../MediaBrowser.WebDashboard.csproj | 12 ++++++++++++ 8 files changed, 34 insertions(+), 10 deletions(-) diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index 6c61ef66ff..b0359194c7 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -334,7 +334,7 @@ namespace MediaBrowser.Api.LiveTv [Route("/LiveTv/TunerHosts", "POST", Summary = "Adds a tuner host")] [Authenticated] - public class AddTunerHost : TunerHostInfo, IReturnVoid + public class AddTunerHost : TunerHostInfo, IReturn { } @@ -419,10 +419,10 @@ namespace MediaBrowser.Api.LiveTv _config.SaveConfiguration("livetv", config); } - public void Post(AddTunerHost request) + public async Task Post(AddTunerHost request) { - var task = _liveTvManager.SaveTunerHost(request); - Task.WaitAll(task); + var result = await _liveTvManager.SaveTunerHost(request).ConfigureAwait(false); + return ToOptimizedResult(result); } public void Delete(DeleteTunerHost request) diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 259f6925b2..53ad6dbdc7 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -344,7 +344,7 @@ namespace MediaBrowser.Controller.LiveTv /// /// The information. /// Task. - Task SaveTunerHost(TunerHostInfo info); + Task SaveTunerHost(TunerHostInfo info); /// /// Saves the listing provider. /// diff --git a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs index 3fc8416455..004ee2ce6a 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs +++ b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs @@ -24,6 +24,7 @@ namespace MediaBrowser.Model.LiveTv public string Id { get; set; } public string Url { get; set; } public string Type { get; set; } + public bool ImportFavoritesOnly { get; set; } } public class ListingsProviderInfo diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index d539562b8f..b7091ee097 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -2172,7 +2172,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv return await _libraryManager.GetNamedView(user, name, "livetv", "zz_" + name, cancellationToken).ConfigureAwait(false); } - public async Task SaveTunerHost(TunerHostInfo info) + public async Task SaveTunerHost(TunerHostInfo info) { info = (TunerHostInfo)_jsonSerializer.DeserializeFromString(_jsonSerializer.SerializeToString(info), typeof(TunerHostInfo)); @@ -2202,6 +2202,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv _config.SaveConfiguration("livetv", config); _taskManager.CancelIfRunningAndQueue(); + + return info; } public async Task SaveListingProvider(ListingsProviderInfo info, bool validateLogin, bool validateListings) diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs index cc2bb2d521..10baffea61 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs @@ -73,7 +73,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun } // Strip off the port - url = new Uri(url).GetComponents(UriComponents.AbsoluteUri & ~UriComponents.Port, UriFormat.UriEscaped); + url = new Uri(url).GetComponents(UriComponents.AbsoluteUri & ~UriComponents.Port, UriFormat.UriEscaped).TrimEnd('/'); await _liveTvManager.SaveTunerHost(new TunerHostInfo { diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index 1e30a4fd8d..682abd20f4 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -60,7 +60,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun if (root != null) { - return root.Select(i => new ChannelInfo + var result = root.Select(i => new ChannelInfo { Name = i.GuideName, Number = i.GuideNumber.ToString(CultureInfo.InvariantCulture), @@ -68,6 +68,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun IsFavorite = i.Favorite }); + + if (info.ImportFavoritesOnly) + { + result = result.Where(i => (i.IsFavorite ?? true)).ToList(); + } + + return result; } return new List(); } diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 2c2fd76a73..e5a36b12ff 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -1480,7 +1480,7 @@ "ButtonAddDevice": "Add Device", "HeaderAddDevice": "Add Device", "HeaderExternalServices": "External Services", - "LabelIpAddressPath": "IP Address / Path:", + "LabelTunerIpAddress": "Tuner IP Address:", "TabExternalServices": "External Services", "TabTuners": "Tuners", "HeaderGuideProviders": "Guide Providers", @@ -1489,5 +1489,7 @@ "GuideProviderListingsStep": "Step 2: Select Listings", "GuideProviderLoginStep": "Step 1: Login", "LabelLineup": "Lineup:", - "MessageTunerDeviceNotListed": "Is your tuner device not listed? Try installing an external service provider for more Live TV options." + "MessageTunerDeviceNotListed": "Is your tuner device not listed? Try installing an external service provider for more Live TV options.", + "LabelImportOnlyFavoriteChannels": "Restrict to channels marked as favorite", + "ImportFavoriteChannelsHelp": "If enabled, only channels that are marked as favorite on the tuner device will be imported." } diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index bc2b8eb7a1..982d68461e 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -195,6 +195,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -210,6 +216,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest