diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs index 277e02bf90..3cd6843b75 100644 --- a/MediaBrowser.Api/StartupWizardService.cs +++ b/MediaBrowser.Api/StartupWizardService.cs @@ -3,8 +3,10 @@ using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Connect; using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.LiveTv; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Configuration; +using MediaBrowser.Model.LiveTv; using ServiceStack; using System; using System.Linq; @@ -49,6 +51,7 @@ namespace MediaBrowser.Api private readonly IServerApplicationHost _appHost; private readonly IUserManager _userManager; private readonly IConnectManager _connectManager; + private ILiveTvManager _liveTvManager; public StartupWizardService(IServerConfigurationManager config, IServerApplicationHost appHost, IUserManager userManager, IConnectManager connectManager) { @@ -101,6 +104,9 @@ namespace MediaBrowser.Api _config.Configuration.MetadataCountryCode = request.MetadataCountryCode; _config.Configuration.PreferredMetadataLanguage = request.PreferredMetadataLanguage; _config.SaveConfiguration(); + + var task = UpdateTuners(request); + Task.WaitAll(task); } public object Get(GetStartupUser request) @@ -141,6 +147,51 @@ namespace MediaBrowser.Api return result; } + + private async Task UpdateTuners(UpdateStartupConfiguration request) + { + var config = GetLiveTVConfiguration(); + var save = false; + + if (string.IsNullOrWhiteSpace(request.LiveTvTunerPath) || + string.IsNullOrWhiteSpace(request.LiveTvTunerType)) + { + if (config.TunerHosts.Count > 0) + { + config.TunerHosts.Clear(); + save = true; + } + } + else + { + if (!config.TunerHosts.Any(i => string.Equals(i.Type, request.LiveTvTunerType, StringComparison.OrdinalIgnoreCase) && string.Equals(i.Url, request.LiveTvTunerPath, StringComparison.OrdinalIgnoreCase))) + { + // Add tuner + await _liveTvManager.SaveTunerHost(new TunerHostInfo + { + IsEnabled = true, + Type = request.LiveTvTunerType, + Url = request.LiveTvTunerPath + + }).ConfigureAwait(false); + } + } + + if (save) + { + SaveLiveTVConfiguration(config); + } + } + + private void SaveLiveTVConfiguration(LiveTvOptions config) + { + _config.SaveConfiguration("livetv", config); + } + + private LiveTvOptions GetLiveTVConfiguration() + { + return _config.GetConfiguration("livetv"); + } } public class StartupConfiguration @@ -150,6 +201,8 @@ namespace MediaBrowser.Api public bool SaveLocalMeta { get; set; } public string MetadataCountryCode { get; set; } public string PreferredMetadataLanguage { get; set; } + public string LiveTvTunerType { get; set; } + public string LiveTvTunerPath { get; set; } } public class StartupInfo diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 7fbff31b23..355597fcf1 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -322,8 +322,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV { var defaults = new SeriesTimerInfo() { - PostPaddingSeconds = 60, - PrePaddingSeconds = 60, + PostPaddingSeconds = 0, + PrePaddingSeconds = 0, RecordAnyChannel = false, RecordAnyTime = false, RecordNewOnly = false diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index a05cd1b63e..5ee76bbd15 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -261,6 +261,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -1780,6 +1783,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest