add tuner setup to startup wizard

pull/702/head
Luke Pulverenti 9 years ago
parent 8128a9c611
commit 6dba423c2c

@ -3,8 +3,10 @@ using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Connect; using MediaBrowser.Controller.Connect;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.LiveTv;
using ServiceStack; using ServiceStack;
using System; using System;
using System.Linq; using System.Linq;
@ -49,6 +51,7 @@ namespace MediaBrowser.Api
private readonly IServerApplicationHost _appHost; private readonly IServerApplicationHost _appHost;
private readonly IUserManager _userManager; private readonly IUserManager _userManager;
private readonly IConnectManager _connectManager; private readonly IConnectManager _connectManager;
private ILiveTvManager _liveTvManager;
public StartupWizardService(IServerConfigurationManager config, IServerApplicationHost appHost, IUserManager userManager, IConnectManager connectManager) public StartupWizardService(IServerConfigurationManager config, IServerApplicationHost appHost, IUserManager userManager, IConnectManager connectManager)
{ {
@ -101,6 +104,9 @@ namespace MediaBrowser.Api
_config.Configuration.MetadataCountryCode = request.MetadataCountryCode; _config.Configuration.MetadataCountryCode = request.MetadataCountryCode;
_config.Configuration.PreferredMetadataLanguage = request.PreferredMetadataLanguage; _config.Configuration.PreferredMetadataLanguage = request.PreferredMetadataLanguage;
_config.SaveConfiguration(); _config.SaveConfiguration();
var task = UpdateTuners(request);
Task.WaitAll(task);
} }
public object Get(GetStartupUser request) public object Get(GetStartupUser request)
@ -141,6 +147,51 @@ namespace MediaBrowser.Api
return result; 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<LiveTvOptions>("livetv");
}
} }
public class StartupConfiguration public class StartupConfiguration
@ -150,6 +201,8 @@ namespace MediaBrowser.Api
public bool SaveLocalMeta { get; set; } public bool SaveLocalMeta { get; set; }
public string MetadataCountryCode { get; set; } public string MetadataCountryCode { get; set; }
public string PreferredMetadataLanguage { get; set; } public string PreferredMetadataLanguage { get; set; }
public string LiveTvTunerType { get; set; }
public string LiveTvTunerPath { get; set; }
} }
public class StartupInfo public class StartupInfo

@ -322,8 +322,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
{ {
var defaults = new SeriesTimerInfo() var defaults = new SeriesTimerInfo()
{ {
PostPaddingSeconds = 60, PostPaddingSeconds = 0,
PrePaddingSeconds = 60, PrePaddingSeconds = 0,
RecordAnyChannel = false, RecordAnyChannel = false,
RecordAnyTime = false, RecordAnyTime = false,
RecordNewOnly = false RecordNewOnly = false

@ -261,6 +261,9 @@
<Content Include="dashboard-ui\scripts\sharingwidget.js"> <Content Include="dashboard-ui\scripts\sharingwidget.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="dashboard-ui\scripts\wizardlivetvtuner.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\secondaryitems.html"> <Content Include="dashboard-ui\secondaryitems.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@ -1780,6 +1783,9 @@
<Content Include="dashboard-ui\wizardagreement.html"> <Content Include="dashboard-ui\wizardagreement.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="dashboard-ui\wizardlivetvtuner.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\wizardservice.html"> <Content Include="dashboard-ui\wizardservice.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>

Loading…
Cancel
Save