mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-20 15:55:25 +03:00
rework tuner setup
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller;
|
||||
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 System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -52,16 +49,14 @@ namespace MediaBrowser.Api
|
||||
private readonly IServerApplicationHost _appHost;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IConnectManager _connectManager;
|
||||
private readonly ILiveTvManager _liveTvManager;
|
||||
private readonly IMediaEncoder _mediaEncoder;
|
||||
|
||||
public StartupWizardService(IServerConfigurationManager config, IServerApplicationHost appHost, IUserManager userManager, IConnectManager connectManager, ILiveTvManager liveTvManager, IMediaEncoder mediaEncoder)
|
||||
public StartupWizardService(IServerConfigurationManager config, IServerApplicationHost appHost, IUserManager userManager, IConnectManager connectManager, IMediaEncoder mediaEncoder)
|
||||
{
|
||||
_config = config;
|
||||
_appHost = appHost;
|
||||
_userManager = userManager;
|
||||
_connectManager = connectManager;
|
||||
_liveTvManager = liveTvManager;
|
||||
_mediaEncoder = mediaEncoder;
|
||||
}
|
||||
|
||||
@@ -92,20 +87,6 @@ namespace MediaBrowser.Api
|
||||
PreferredMetadataLanguage = _config.Configuration.PreferredMetadataLanguage
|
||||
};
|
||||
|
||||
var tvConfig = GetLiveTVConfiguration();
|
||||
|
||||
if (tvConfig.TunerHosts.Count > 0)
|
||||
{
|
||||
result.LiveTvTunerPath = tvConfig.TunerHosts[0].Url;
|
||||
result.LiveTvTunerType = tvConfig.TunerHosts[0].Type;
|
||||
}
|
||||
|
||||
if (tvConfig.ListingProviders.Count > 0)
|
||||
{
|
||||
result.LiveTvGuideProviderId = tvConfig.ListingProviders[0].Id;
|
||||
result.LiveTvGuideProviderType = tvConfig.ListingProviders[0].Type;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -129,9 +110,6 @@ 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)
|
||||
@@ -166,50 +144,6 @@ 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
|
||||
{
|
||||
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
|
||||
@@ -217,10 +151,6 @@ namespace MediaBrowser.Api
|
||||
public string UICulture { get; set; }
|
||||
public string MetadataCountryCode { get; set; }
|
||||
public string PreferredMetadataLanguage { get; set; }
|
||||
public string LiveTvTunerType { get; set; }
|
||||
public string LiveTvTunerPath { get; set; }
|
||||
public string LiveTvGuideProviderId { get; set; }
|
||||
public string LiveTvGuideProviderType { get; set; }
|
||||
}
|
||||
|
||||
public class StartupInfo
|
||||
|
||||
Reference in New Issue
Block a user