aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs4
-rw-r--r--Emby.Server.Implementations/Session/SessionManager.cs2
-rw-r--r--Jellyfin.Api/Controllers/ConfigurationController.cs180
-rw-r--r--Jellyfin.Api/Helpers/ConfigurationJsonTypeInfoModifier.cs48
-rw-r--r--Jellyfin.Api/Helpers/ConfigurationMapper.cs454
-rw-r--r--Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs7
-rw-r--r--Jellyfin.Server/Filters/AdditionalModelFilter.cs26
-rw-r--r--MediaBrowser.Common/Net/NetworkConfigurationDto.cs124
-rw-r--r--MediaBrowser.Model/Configuration/EncodingOptionsDto.cs257
-rw-r--r--MediaBrowser.Model/Configuration/MetadataConfigurationDto.cs12
-rw-r--r--MediaBrowser.Model/Configuration/ServerConfigurationDto.cs125
-rw-r--r--MediaBrowser.Model/Configuration/XbmcMetadataOptionsDto.cs32
-rw-r--r--MediaBrowser.Model/LiveTv/LiveTvOptionsDto.cs84
-rw-r--r--src/Jellyfin.LiveTv/Listings/SchedulesDirect.cs2
-rw-r--r--tests/Jellyfin.Server.Integration.Tests/Controllers/ConfigurationControllerTests.cs248
15 files changed, 1529 insertions, 76 deletions
diff --git a/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs b/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
index c4bda96371..27d9955b09 100644
--- a/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
+++ b/Emby.Server.Implementations/QuickConnect/QuickConnectManager.cs
@@ -219,10 +219,10 @@ namespace Emby.Server.Implementations.QuickConnect
{
if (expireAll || timestamp < minTime)
{
- _logger.LogDebug("Removing expired secret {Secret}", secret);
+ _logger.LogDebug("Removing expired secret.");
if (!_authorizedSecrets.TryRemove(secret, out _))
{
- _logger.LogWarning("Secret {Secret} already expired", secret);
+ _logger.LogWarning("Secret already expired.");
}
}
}
diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs
index dd71f843e8..91401eea6b 100644
--- a/Emby.Server.Implementations/Session/SessionManager.cs
+++ b/Emby.Server.Implementations/Session/SessionManager.cs
@@ -1837,7 +1837,7 @@ namespace Emby.Server.Implementations.Session
{
CheckDisposed();
- _logger.LogInformation("Logging out access token {0}", device.AccessToken);
+ _logger.LogInformation("Logging out {0} ({1}) for user {2}", device.DeviceName, device.DeviceId, device.UserId);
await _deviceManager.DeleteDevice(device).ConfigureAwait(false);
diff --git a/Jellyfin.Api/Controllers/ConfigurationController.cs b/Jellyfin.Api/Controllers/ConfigurationController.cs
index ecd667b2e8..e40bb8453c 100644
--- a/Jellyfin.Api/Controllers/ConfigurationController.cs
+++ b/Jellyfin.Api/Controllers/ConfigurationController.cs
@@ -1,14 +1,12 @@
-using System;
using System.ComponentModel.DataAnnotations;
-using System.Net.Mime;
-using System.Text.Json;
-using Jellyfin.Api.Attributes;
-using Jellyfin.Extensions.Json;
+using Jellyfin.Api.Helpers;
using MediaBrowser.Common.Api;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Model.Branding;
using MediaBrowser.Model.Configuration;
+using MediaBrowser.Model.LiveTv;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@@ -24,21 +22,14 @@ namespace Jellyfin.Api.Controllers;
public class ConfigurationController : BaseJellyfinApiController
{
private readonly IServerConfigurationManager _configurationManager;
- private readonly IMediaEncoder _mediaEncoder;
-
- private readonly JsonSerializerOptions _serializerOptions = JsonDefaults.Options;
/// <summary>
/// Initializes a new instance of the <see cref="ConfigurationController"/> class.
/// </summary>
/// <param name="configurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
- /// <param name="mediaEncoder">Instance of the <see cref="IMediaEncoder"/> interface.</param>
- public ConfigurationController(
- IServerConfigurationManager configurationManager,
- IMediaEncoder mediaEncoder)
+ public ConfigurationController(IServerConfigurationManager configurationManager)
{
_configurationManager = configurationManager;
- _mediaEncoder = mediaEncoder;
}
/// <summary>
@@ -48,9 +39,9 @@ public class ConfigurationController : BaseJellyfinApiController
/// <returns>Application configuration.</returns>
[HttpGet("Configuration")]
[ProducesResponseType(StatusCodes.Status200OK)]
- public ActionResult<ServerConfiguration> GetConfiguration()
+ public ActionResult<ServerConfigurationDto> GetConfiguration()
{
- return _configurationManager.Configuration;
+ return ConfigurationMapper.MapToDto(_configurationManager.Configuration);
}
/// <summary>
@@ -62,61 +53,158 @@ public class ConfigurationController : BaseJellyfinApiController
[HttpPost("Configuration")]
[Authorize(Policy = Policies.RequiresElevation)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
- public ActionResult UpdateConfiguration([FromBody, Required] ServerConfiguration configuration)
+ public ActionResult UpdateConfiguration([FromBody, Required] ServerConfigurationDto configuration)
{
- _configurationManager.ReplaceConfiguration(configuration);
+ _configurationManager.ReplaceConfiguration(ConfigurationMapper.MapToInternal(configuration));
return NoContent();
}
/// <summary>
- /// Gets a named configuration.
+ /// Gets a default MetadataOptions object.
/// </summary>
- /// <param name="key">Configuration key.</param>
- /// <response code="200">Configuration returned.</response>
- /// <returns>Configuration.</returns>
- [HttpGet("Configuration/{key}")]
+ /// <response code="200">Metadata options returned.</response>
+ /// <returns>Default MetadataOptions.</returns>
+ [HttpGet("Configuration/MetadataOptions/Default")]
+ [Authorize(Policy = Policies.RequiresElevation)]
[ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesFile(MediaTypeNames.Application.Json)]
- public ActionResult<object> GetNamedConfiguration([FromRoute, Required] string key)
+ public ActionResult<MetadataOptions> GetDefaultMetadataOptions()
{
- return _configurationManager.GetConfiguration(key);
+ return new MetadataOptions();
}
/// <summary>
- /// Updates named configuration.
+ /// Gets encoding configuration.
/// </summary>
- /// <param name="key">Configuration key.</param>
- /// <param name="configuration">Configuration.</param>
- /// <response code="204">Named configuration updated.</response>
+ /// <response code="200">Encoding configuration returned.</response>
+ /// <returns>Encoding configuration.</returns>
+ [HttpGet("Configuration/Encoding")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ public ActionResult<EncodingOptionsDto> GetEncodingConfiguration()
+ {
+ return ConfigurationMapper.MapToDto(_configurationManager.GetConfiguration<EncodingOptions>("encoding"));
+ }
+
+ /// <summary>
+ /// Updates encoding configuration.
+ /// </summary>
+ /// <param name="configuration">Encoding configuration.</param>
+ /// <response code="204">Encoding configuration updated.</response>
/// <returns>Update status.</returns>
- [HttpPost("Configuration/{key}")]
+ [HttpPost("Configuration/Encoding")]
[Authorize(Policy = Policies.RequiresElevation)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
- public ActionResult UpdateNamedConfiguration([FromRoute, Required] string key, [FromBody, Required] JsonDocument configuration)
+ public ActionResult UpdateEncodingConfiguration([FromBody, Required] EncodingOptionsDto configuration)
{
- var configurationType = _configurationManager.GetConfigurationType(key);
- var deserializedConfiguration = configuration.Deserialize(configurationType, _serializerOptions);
+ _configurationManager.SaveConfiguration("encoding", ConfigurationMapper.MapToInternal(configuration));
+ return NoContent();
+ }
- if (deserializedConfiguration is null)
- {
- throw new ArgumentException("Body doesn't contain a valid configuration");
- }
+ /// <summary>
+ /// Gets network configuration.
+ /// </summary>
+ /// <response code="200">Network configuration returned.</response>
+ /// <returns>Network configuration.</returns>
+ [HttpGet("Configuration/Network")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ public ActionResult<NetworkConfigurationDto> GetNetworkConfiguration()
+ {
+ return ConfigurationMapper.MapToDto(_configurationManager.GetConfiguration<NetworkConfiguration>("network"));
+ }
- _configurationManager.SaveConfiguration(key, deserializedConfiguration);
+ /// <summary>
+ /// Updates network configuration.
+ /// </summary>
+ /// <param name="configuration">Network configuration.</param>
+ /// <response code="204">Network configuration updated.</response>
+ /// <returns>Update status.</returns>
+ [HttpPost("Configuration/Network")]
+ [Authorize(Policy = Policies.RequiresElevation)]
+ [ProducesResponseType(StatusCodes.Status204NoContent)]
+ public ActionResult UpdateNetworkConfiguration([FromBody, Required] NetworkConfigurationDto configuration)
+ {
+ _configurationManager.SaveConfiguration("network", ConfigurationMapper.MapToInternal(configuration));
return NoContent();
}
/// <summary>
- /// Gets a default MetadataOptions object.
+ /// Gets metadata configuration.
/// </summary>
- /// <response code="200">Metadata options returned.</response>
- /// <returns>Default MetadataOptions.</returns>
- [HttpGet("Configuration/MetadataOptions/Default")]
+ /// <response code="200">Metadata configuration returned.</response>
+ /// <returns>Metadata configuration.</returns>
+ [HttpGet("Configuration/Metadata")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ public ActionResult<MetadataConfigurationDto> GetMetadataConfiguration()
+ {
+ return ConfigurationMapper.MapToDto(_configurationManager.GetConfiguration<MetadataConfiguration>("metadata"));
+ }
+
+ /// <summary>
+ /// Updates metadata configuration.
+ /// </summary>
+ /// <param name="configuration">Metadata configuration.</param>
+ /// <response code="204">Metadata configuration updated.</response>
+ /// <returns>Update status.</returns>
+ [HttpPost("Configuration/Metadata")]
[Authorize(Policy = Policies.RequiresElevation)]
+ [ProducesResponseType(StatusCodes.Status204NoContent)]
+ public ActionResult UpdateMetadataConfiguration([FromBody, Required] MetadataConfigurationDto configuration)
+ {
+ _configurationManager.SaveConfiguration("metadata", ConfigurationMapper.MapToInternal(configuration));
+ return NoContent();
+ }
+
+ /// <summary>
+ /// Gets XbmcMetadata configuration.
+ /// </summary>
+ /// <response code="200">XbmcMetadata configuration returned.</response>
+ /// <returns>XbmcMetadata configuration.</returns>
+ [HttpGet("Configuration/XbmcMetadata")]
[ProducesResponseType(StatusCodes.Status200OK)]
- public ActionResult<MetadataOptions> GetDefaultMetadataOptions()
+ public ActionResult<XbmcMetadataOptionsDto> GetXbmcMetadataConfiguration()
{
- return new MetadataOptions();
+ return ConfigurationMapper.MapToDto(_configurationManager.GetConfiguration<XbmcMetadataOptions>("xbmcmetadata"));
+ }
+
+ /// <summary>
+ /// Updates XbmcMetadata configuration.
+ /// </summary>
+ /// <param name="configuration">XbmcMetadata configuration.</param>
+ /// <response code="204">XbmcMetadata configuration updated.</response>
+ /// <returns>Update status.</returns>
+ [HttpPost("Configuration/XbmcMetadata")]
+ [Authorize(Policy = Policies.RequiresElevation)]
+ [ProducesResponseType(StatusCodes.Status204NoContent)]
+ public ActionResult UpdateXbmcMetadataConfiguration([FromBody, Required] XbmcMetadataOptionsDto configuration)
+ {
+ _configurationManager.SaveConfiguration("xbmcmetadata", ConfigurationMapper.MapToInternal(configuration));
+ return NoContent();
+ }
+
+ /// <summary>
+ /// Gets LiveTv configuration.
+ /// </summary>
+ /// <response code="200">LiveTv configuration returned.</response>
+ /// <returns>LiveTv configuration.</returns>
+ [HttpGet("Configuration/LiveTv")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ public ActionResult<LiveTvOptionsDto> GetLiveTvConfiguration()
+ {
+ return ConfigurationMapper.MapToDto(_configurationManager.GetConfiguration<LiveTvOptions>("livetv"));
+ }
+
+ /// <summary>
+ /// Updates LiveTv configuration.
+ /// </summary>
+ /// <param name="configuration">LiveTv configuration.</param>
+ /// <response code="204">LiveTv configuration updated.</response>
+ /// <returns>Update status.</returns>
+ [HttpPost("Configuration/LiveTv")]
+ [Authorize(Policy = Policies.RequiresElevation)]
+ [ProducesResponseType(StatusCodes.Status204NoContent)]
+ public ActionResult UpdateLiveTvConfiguration([FromBody, Required] LiveTvOptionsDto configuration)
+ {
+ _configurationManager.SaveConfiguration("livetv", ConfigurationMapper.MapToInternal(configuration));
+ return NoContent();
}
/// <summary>
@@ -131,7 +219,7 @@ public class ConfigurationController : BaseJellyfinApiController
public ActionResult UpdateBrandingConfiguration([FromBody, Required] BrandingOptionsDto configuration)
{
// Get the current branding configuration to preserve SplashscreenLocation
- var currentBranding = (BrandingOptions)_configurationManager.GetConfiguration("branding");
+ var currentBranding = _configurationManager.GetConfiguration<BrandingOptions>("branding");
// Update only the properties from BrandingOptionsDto
currentBranding.LoginDisclaimer = configuration.LoginDisclaimer;
diff --git a/Jellyfin.Api/Helpers/ConfigurationJsonTypeInfoModifier.cs b/Jellyfin.Api/Helpers/ConfigurationJsonTypeInfoModifier.cs
new file mode 100644
index 0000000000..83cccd0678
--- /dev/null
+++ b/Jellyfin.Api/Helpers/ConfigurationJsonTypeInfoModifier.cs
@@ -0,0 +1,48 @@
+using System.Text.Json.Serialization.Metadata;
+using MediaBrowser.Common.Net;
+using MediaBrowser.Model.Configuration;
+using MediaBrowser.Model.LiveTv;
+
+namespace Jellyfin.Api.Helpers;
+
+/// <summary>
+/// Keeps config defaults out of the DTOs.
+/// </summary>
+public static class ConfigurationJsonTypeInfoModifier
+{
+ /// <summary>
+ /// Fills in defaults from the internal config before reading the request.
+ /// </summary>
+ /// <remarks>
+ /// Missing fields keep their defaults. Values sent by the client, including null, replace them.
+ /// Use a new config each time so requests don't share arrays or other objects.
+ /// </remarks>
+ /// <param name="typeInfo">The JSON type information.</param>
+ public static void Modify(JsonTypeInfo typeInfo)
+ {
+ if (typeInfo.Type == typeof(ServerConfigurationDto))
+ {
+ typeInfo.CreateObject = static () => ConfigurationMapper.MapToDto(new ServerConfiguration());
+ }
+ else if (typeInfo.Type == typeof(EncodingOptionsDto))
+ {
+ typeInfo.CreateObject = static () => ConfigurationMapper.MapToDto(new EncodingOptions());
+ }
+ else if (typeInfo.Type == typeof(NetworkConfigurationDto))
+ {
+ typeInfo.CreateObject = static () => ConfigurationMapper.MapToDto(new NetworkConfiguration());
+ }
+ else if (typeInfo.Type == typeof(MetadataConfigurationDto))
+ {
+ typeInfo.CreateObject = static () => ConfigurationMapper.MapToDto(new MetadataConfiguration());
+ }
+ else if (typeInfo.Type == typeof(XbmcMetadataOptionsDto))
+ {
+ typeInfo.CreateObject = static () => ConfigurationMapper.MapToDto(new XbmcMetadataOptions());
+ }
+ else if (typeInfo.Type == typeof(LiveTvOptionsDto))
+ {
+ typeInfo.CreateObject = static () => ConfigurationMapper.MapToDto(new LiveTvOptions());
+ }
+ }
+}
diff --git a/Jellyfin.Api/Helpers/ConfigurationMapper.cs b/Jellyfin.Api/Helpers/ConfigurationMapper.cs
new file mode 100644
index 0000000000..8cfb847177
--- /dev/null
+++ b/Jellyfin.Api/Helpers/ConfigurationMapper.cs
@@ -0,0 +1,454 @@
+using MediaBrowser.Common.Net;
+using MediaBrowser.Model.Configuration;
+using MediaBrowser.Model.LiveTv;
+
+namespace Jellyfin.Api.Helpers;
+
+/// <summary>
+/// Helper for mapping between configuration DTOs and their internal counterparts.
+/// </summary>
+public static class ConfigurationMapper
+{
+ /// <summary>
+ /// Maps a <see cref="ServerConfiguration"/> to a <see cref="ServerConfigurationDto"/>.
+ /// </summary>
+ /// <param name="config">The <see cref="ServerConfiguration"/>.</param>
+ /// <returns>The <see cref="ServerConfigurationDto"/>.</returns>
+ public static ServerConfigurationDto MapToDto(ServerConfiguration config)
+ {
+ return new ServerConfigurationDto
+ {
+ LogFileRetentionDays = config.LogFileRetentionDays,
+ IsStartupWizardCompleted = config.IsStartupWizardCompleted,
+ CachePath = config.CachePath,
+ PreviousVersionStr = config.PreviousVersionStr,
+ EnableMetrics = config.EnableMetrics,
+ EnableNormalizedItemByNameIds = config.EnableNormalizedItemByNameIds,
+ IsPortAuthorized = config.IsPortAuthorized,
+ QuickConnectAvailable = config.QuickConnectAvailable,
+ EnableCaseSensitiveItemIds = config.EnableCaseSensitiveItemIds,
+ DisableLiveTvChannelUserDataName = config.DisableLiveTvChannelUserDataName,
+ MetadataPath = config.MetadataPath,
+ PreferredMetadataLanguage = config.PreferredMetadataLanguage,
+ MetadataCountryCode = config.MetadataCountryCode,
+ SortReplaceCharacters = config.SortReplaceCharacters,
+ SortRemoveCharacters = config.SortRemoveCharacters,
+ SortRemoveWords = config.SortRemoveWords,
+ MinResumePct = config.MinResumePct,
+ MaxResumePct = config.MaxResumePct,
+ MinResumeDurationSeconds = config.MinResumeDurationSeconds,
+ MinAudiobookResume = config.MinAudiobookResume,
+ MaxAudiobookResume = config.MaxAudiobookResume,
+ InactiveSessionThreshold = config.InactiveSessionThreshold,
+ LibraryMonitorDelay = config.LibraryMonitorDelay,
+ LibraryUpdateDuration = config.LibraryUpdateDuration,
+ CacheSize = config.CacheSize,
+ ImageSavingConvention = config.ImageSavingConvention,
+ MetadataOptions = config.MetadataOptions,
+ SkipDeserializationForBasicTypes = config.SkipDeserializationForBasicTypes,
+ ServerName = config.ServerName,
+ UICulture = config.UICulture,
+ SaveMetadataHidden = config.SaveMetadataHidden,
+ ContentTypes = config.ContentTypes,
+ RemoteClientBitrateLimit = config.RemoteClientBitrateLimit,
+ EnableFolderView = config.EnableFolderView,
+ EnableGroupingMoviesIntoCollections = config.EnableGroupingMoviesIntoCollections,
+ EnableGroupingShowsIntoCollections = config.EnableGroupingShowsIntoCollections,
+ DisplaySpecialsWithinSeasons = config.DisplaySpecialsWithinSeasons,
+ CodecsUsed = config.CodecsUsed,
+ PluginRepositories = config.PluginRepositories,
+ EnableExternalContentInSuggestions = config.EnableExternalContentInSuggestions,
+ ImageExtractionTimeoutMs = config.ImageExtractionTimeoutMs,
+ PathSubstitutions = config.PathSubstitutions,
+ EnableSlowResponseWarning = config.EnableSlowResponseWarning,
+ SlowResponseThresholdMs = config.SlowResponseThresholdMs,
+ CorsHosts = config.CorsHosts,
+ ActivityLogRetentionDays = config.ActivityLogRetentionDays,
+ LibraryScanFanoutConcurrency = config.LibraryScanFanoutConcurrency,
+ LibraryMetadataRefreshConcurrency = config.LibraryMetadataRefreshConcurrency,
+ AllowClientLogUpload = config.AllowClientLogUpload,
+ DummyChapterDuration = config.DummyChapterDuration,
+ ChapterImageResolution = config.ChapterImageResolution,
+ ParallelImageEncodingLimit = config.ParallelImageEncodingLimit,
+ CastReceiverApplications = config.CastReceiverApplications,
+ TrickplayOptions = config.TrickplayOptions,
+ EnableLegacyAuthorization = config.EnableLegacyAuthorization,
+ };
+ }
+
+ /// <summary>
+ /// Maps a <see cref="ServerConfigurationDto"/> to a <see cref="ServerConfiguration"/>.
+ /// </summary>
+ /// <param name="dto">The <see cref="ServerConfigurationDto"/>.</param>
+ /// <returns>The <see cref="ServerConfiguration"/>.</returns>
+ public static ServerConfiguration MapToInternal(ServerConfigurationDto dto)
+ {
+ return new ServerConfiguration
+ {
+ LogFileRetentionDays = dto.LogFileRetentionDays,
+ IsStartupWizardCompleted = dto.IsStartupWizardCompleted,
+ CachePath = dto.CachePath,
+ PreviousVersionStr = dto.PreviousVersionStr,
+ EnableMetrics = dto.EnableMetrics,
+ EnableNormalizedItemByNameIds = dto.EnableNormalizedItemByNameIds,
+ IsPortAuthorized = dto.IsPortAuthorized,
+ QuickConnectAvailable = dto.QuickConnectAvailable,
+ EnableCaseSensitiveItemIds = dto.EnableCaseSensitiveItemIds,
+ DisableLiveTvChannelUserDataName = dto.DisableLiveTvChannelUserDataName,
+ MetadataPath = dto.MetadataPath,
+ PreferredMetadataLanguage = dto.PreferredMetadataLanguage,
+ MetadataCountryCode = dto.MetadataCountryCode,
+ SortReplaceCharacters = dto.SortReplaceCharacters,
+ SortRemoveCharacters = dto.SortRemoveCharacters,
+ SortRemoveWords = dto.SortRemoveWords,
+ MinResumePct = dto.MinResumePct,
+ MaxResumePct = dto.MaxResumePct,
+ MinResumeDurationSeconds = dto.MinResumeDurationSeconds,
+ MinAudiobookResume = dto.MinAudiobookResume,
+ MaxAudiobookResume = dto.MaxAudiobookResume,
+ InactiveSessionThreshold = dto.InactiveSessionThreshold,
+ LibraryMonitorDelay = dto.LibraryMonitorDelay,
+ LibraryUpdateDuration = dto.LibraryUpdateDuration,
+ CacheSize = dto.CacheSize,
+ ImageSavingConvention = dto.ImageSavingConvention,
+ MetadataOptions = dto.MetadataOptions,
+ SkipDeserializationForBasicTypes = dto.SkipDeserializationForBasicTypes,
+ ServerName = dto.ServerName,
+ UICulture = dto.UICulture,
+ SaveMetadataHidden = dto.SaveMetadataHidden,
+ ContentTypes = dto.ContentTypes,
+ RemoteClientBitrateLimit = dto.RemoteClientBitrateLimit,
+ EnableFolderView = dto.EnableFolderView,
+ EnableGroupingMoviesIntoCollections = dto.EnableGroupingMoviesIntoCollections,
+ EnableGroupingShowsIntoCollections = dto.EnableGroupingShowsIntoCollections,
+ DisplaySpecialsWithinSeasons = dto.DisplaySpecialsWithinSeasons,
+ CodecsUsed = dto.CodecsUsed,
+ PluginRepositories = dto.PluginRepositories,
+ EnableExternalContentInSuggestions = dto.EnableExternalContentInSuggestions,
+ ImageExtractionTimeoutMs = dto.ImageExtractionTimeoutMs,
+ PathSubstitutions = dto.PathSubstitutions,
+ EnableSlowResponseWarning = dto.EnableSlowResponseWarning,
+ SlowResponseThresholdMs = dto.SlowResponseThresholdMs,
+ CorsHosts = dto.CorsHosts,
+ ActivityLogRetentionDays = dto.ActivityLogRetentionDays,
+ LibraryScanFanoutConcurrency = dto.LibraryScanFanoutConcurrency,
+ LibraryMetadataRefreshConcurrency = dto.LibraryMetadataRefreshConcurrency,
+ AllowClientLogUpload = dto.AllowClientLogUpload,
+ DummyChapterDuration = dto.DummyChapterDuration,
+ ChapterImageResolution = dto.ChapterImageResolution,
+ ParallelImageEncodingLimit = dto.ParallelImageEncodingLimit,
+ CastReceiverApplications = dto.CastReceiverApplications,
+ TrickplayOptions = dto.TrickplayOptions,
+ EnableLegacyAuthorization = dto.EnableLegacyAuthorization,
+ };
+ }
+
+ /// <summary>
+ /// Maps an <see cref="EncodingOptions"/> to an <see cref="EncodingOptionsDto"/>.
+ /// </summary>
+ /// <param name="options">The <see cref="EncodingOptions"/>.</param>
+ /// <returns>The <see cref="EncodingOptionsDto"/>.</returns>
+ public static EncodingOptionsDto MapToDto(EncodingOptions options)
+ {
+ return new EncodingOptionsDto
+ {
+ EncodingThreadCount = options.EncodingThreadCount,
+ TranscodingTempPath = options.TranscodingTempPath,
+ FallbackFontPath = options.FallbackFontPath,
+ EnableFallbackFont = options.EnableFallbackFont,
+ EnableAudioVbr = options.EnableAudioVbr,
+ DownMixAudioBoost = options.DownMixAudioBoost,
+ DownMixStereoAlgorithm = options.DownMixStereoAlgorithm,
+ MaxMuxingQueueSize = options.MaxMuxingQueueSize,
+ EnableThrottling = options.EnableThrottling,
+ ThrottleDelaySeconds = options.ThrottleDelaySeconds,
+ EnableSegmentDeletion = options.EnableSegmentDeletion,
+ SegmentKeepSeconds = options.SegmentKeepSeconds,
+ HardwareAccelerationType = options.HardwareAccelerationType,
+ EncoderAppPath = options.EncoderAppPath,
+ EncoderAppPathDisplay = options.EncoderAppPathDisplay,
+ VaapiDevice = options.VaapiDevice,
+ QsvDevice = options.QsvDevice,
+ EnableTonemapping = options.EnableTonemapping,
+ EnableVppTonemapping = options.EnableVppTonemapping,
+ EnableVideoToolboxTonemapping = options.EnableVideoToolboxTonemapping,
+ TonemappingAlgorithm = options.TonemappingAlgorithm,
+ TonemappingMode = options.TonemappingMode,
+ TonemappingRange = options.TonemappingRange,
+ TonemappingDesat = options.TonemappingDesat,
+ TonemappingPeak = options.TonemappingPeak,
+ TonemappingParam = options.TonemappingParam,
+ VppTonemappingBrightness = options.VppTonemappingBrightness,
+ VppTonemappingContrast = options.VppTonemappingContrast,
+ H264Crf = options.H264Crf,
+ H265Crf = options.H265Crf,
+ EncoderPreset = options.EncoderPreset,
+ DeinterlaceDoubleRate = options.DeinterlaceDoubleRate,
+ DeinterlaceMethod = options.DeinterlaceMethod,
+ EnableDecodingColorDepth10Hevc = options.EnableDecodingColorDepth10Hevc,
+ EnableDecodingColorDepth10Vp9 = options.EnableDecodingColorDepth10Vp9,
+ EnableDecodingColorDepth10HevcRext = options.EnableDecodingColorDepth10HevcRext,
+ EnableDecodingColorDepth12HevcRext = options.EnableDecodingColorDepth12HevcRext,
+ EnableEnhancedNvdecDecoder = options.EnableEnhancedNvdecDecoder,
+ PreferSystemNativeHwDecoder = options.PreferSystemNativeHwDecoder,
+ EnableIntelLowPowerH264HwEncoder = options.EnableIntelLowPowerH264HwEncoder,
+ EnableIntelLowPowerHevcHwEncoder = options.EnableIntelLowPowerHevcHwEncoder,
+ EnableHardwareEncoding = options.EnableHardwareEncoding,
+ AllowHevcEncoding = options.AllowHevcEncoding,
+ AllowAv1Encoding = options.AllowAv1Encoding,
+ EnableSubtitleExtraction = options.EnableSubtitleExtraction,
+ SubtitleExtractionTimeoutMinutes = options.SubtitleExtractionTimeoutMinutes,
+ HardwareDecodingCodecs = options.HardwareDecodingCodecs,
+ AllowOnDemandMetadataBasedKeyframeExtractionForExtensions = options.AllowOnDemandMetadataBasedKeyframeExtractionForExtensions,
+ HlsAudioSeekStrategy = options.HlsAudioSeekStrategy,
+ };
+ }
+
+ /// <summary>
+ /// Maps an <see cref="EncodingOptionsDto"/> to an <see cref="EncodingOptions"/>.
+ /// </summary>
+ /// <param name="dto">The <see cref="EncodingOptionsDto"/>.</param>
+ /// <returns>The <see cref="EncodingOptions"/>.</returns>
+ public static EncodingOptions MapToInternal(EncodingOptionsDto dto)
+ {
+ return new EncodingOptions
+ {
+ EncodingThreadCount = dto.EncodingThreadCount,
+ TranscodingTempPath = dto.TranscodingTempPath,
+ FallbackFontPath = dto.FallbackFontPath,
+ EnableFallbackFont = dto.EnableFallbackFont,
+ EnableAudioVbr = dto.EnableAudioVbr,
+ DownMixAudioBoost = dto.DownMixAudioBoost,
+ DownMixStereoAlgorithm = dto.DownMixStereoAlgorithm,
+ MaxMuxingQueueSize = dto.MaxMuxingQueueSize,
+ EnableThrottling = dto.EnableThrottling,
+ ThrottleDelaySeconds = dto.ThrottleDelaySeconds,
+ EnableSegmentDeletion = dto.EnableSegmentDeletion,
+ SegmentKeepSeconds = dto.SegmentKeepSeconds,
+ HardwareAccelerationType = dto.HardwareAccelerationType,
+ EncoderAppPath = dto.EncoderAppPath,
+ EncoderAppPathDisplay = dto.EncoderAppPathDisplay,
+ VaapiDevice = dto.VaapiDevice,
+ QsvDevice = dto.QsvDevice,
+ EnableTonemapping = dto.EnableTonemapping,
+ EnableVppTonemapping = dto.EnableVppTonemapping,
+ EnableVideoToolboxTonemapping = dto.EnableVideoToolboxTonemapping,
+ TonemappingAlgorithm = dto.TonemappingAlgorithm,
+ TonemappingMode = dto.TonemappingMode,
+ TonemappingRange = dto.TonemappingRange,
+ TonemappingDesat = dto.TonemappingDesat,
+ TonemappingPeak = dto.TonemappingPeak,
+ TonemappingParam = dto.TonemappingParam,
+ VppTonemappingBrightness = dto.VppTonemappingBrightness,
+ VppTonemappingContrast = dto.VppTonemappingContrast,
+ H264Crf = dto.H264Crf,
+ H265Crf = dto.H265Crf,
+ EncoderPreset = dto.EncoderPreset,
+ DeinterlaceDoubleRate = dto.DeinterlaceDoubleRate,
+ DeinterlaceMethod = dto.DeinterlaceMethod,
+ EnableDecodingColorDepth10Hevc = dto.EnableDecodingColorDepth10Hevc,
+ EnableDecodingColorDepth10Vp9 = dto.EnableDecodingColorDepth10Vp9,
+ EnableDecodingColorDepth10HevcRext = dto.EnableDecodingColorDepth10HevcRext,
+ EnableDecodingColorDepth12HevcRext = dto.EnableDecodingColorDepth12HevcRext,
+ EnableEnhancedNvdecDecoder = dto.EnableEnhancedNvdecDecoder,
+ PreferSystemNativeHwDecoder = dto.PreferSystemNativeHwDecoder,
+ EnableIntelLowPowerH264HwEncoder = dto.EnableIntelLowPowerH264HwEncoder,
+ EnableIntelLowPowerHevcHwEncoder = dto.EnableIntelLowPowerHevcHwEncoder,
+ EnableHardwareEncoding = dto.EnableHardwareEncoding,
+ AllowHevcEncoding = dto.AllowHevcEncoding,
+ AllowAv1Encoding = dto.AllowAv1Encoding,
+ EnableSubtitleExtraction = dto.EnableSubtitleExtraction,
+ SubtitleExtractionTimeoutMinutes = dto.SubtitleExtractionTimeoutMinutes,
+ HardwareDecodingCodecs = dto.HardwareDecodingCodecs,
+ AllowOnDemandMetadataBasedKeyframeExtractionForExtensions = dto.AllowOnDemandMetadataBasedKeyframeExtractionForExtensions,
+ HlsAudioSeekStrategy = dto.HlsAudioSeekStrategy,
+ };
+ }
+
+#pragma warning disable CS0618 // Type or member is obsolete
+ /// <summary>
+ /// Maps a <see cref="NetworkConfiguration"/> to a <see cref="NetworkConfigurationDto"/>.
+ /// </summary>
+ /// <param name="config">The <see cref="NetworkConfiguration"/>.</param>
+ /// <returns>The <see cref="NetworkConfigurationDto"/>.</returns>
+ public static NetworkConfigurationDto MapToDto(NetworkConfiguration config)
+ {
+ return new NetworkConfigurationDto
+ {
+ BaseUrl = config.BaseUrl,
+ EnableHttps = config.EnableHttps,
+ RequireHttps = config.RequireHttps,
+ CertificatePath = config.CertificatePath,
+ CertificatePassword = config.CertificatePassword,
+ InternalHttpPort = config.InternalHttpPort,
+ InternalHttpsPort = config.InternalHttpsPort,
+ PublicHttpPort = config.PublicHttpPort,
+ PublicHttpsPort = config.PublicHttpsPort,
+ AutoDiscovery = config.AutoDiscovery,
+ EnableUPnP = config.EnableUPnP,
+ EnableIPv4 = config.EnableIPv4,
+ EnableIPv6 = config.EnableIPv6,
+ EnableRemoteAccess = config.EnableRemoteAccess,
+ LocalNetworkSubnets = config.LocalNetworkSubnets,
+ LocalNetworkAddresses = config.LocalNetworkAddresses,
+ KnownProxies = config.KnownProxies,
+ IgnoreVirtualInterfaces = config.IgnoreVirtualInterfaces,
+ VirtualInterfaceNames = config.VirtualInterfaceNames,
+ EnablePublishedServerUriByRequest = config.EnablePublishedServerUriByRequest,
+ PublishedServerUriBySubnet = config.PublishedServerUriBySubnet,
+ RemoteIPFilter = config.RemoteIPFilter,
+ IsRemoteIPFilterBlacklist = config.IsRemoteIPFilterBlacklist,
+ };
+ }
+
+ /// <summary>
+ /// Maps a <see cref="NetworkConfigurationDto"/> to a <see cref="NetworkConfiguration"/>.
+ /// </summary>
+ /// <param name="dto">The <see cref="NetworkConfigurationDto"/>.</param>
+ /// <returns>The <see cref="NetworkConfiguration"/>.</returns>
+ public static NetworkConfiguration MapToInternal(NetworkConfigurationDto dto)
+ {
+ return new NetworkConfiguration
+ {
+ BaseUrl = dto.BaseUrl,
+ EnableHttps = dto.EnableHttps,
+ RequireHttps = dto.RequireHttps,
+ // The web client sends null for blank certificate fields.
+ CertificatePath = dto.CertificatePath!,
+ CertificatePassword = dto.CertificatePassword!,
+ InternalHttpPort = dto.InternalHttpPort,
+ InternalHttpsPort = dto.InternalHttpsPort,
+ PublicHttpPort = dto.PublicHttpPort,
+ PublicHttpsPort = dto.PublicHttpsPort,
+ AutoDiscovery = dto.AutoDiscovery,
+ EnableUPnP = dto.EnableUPnP,
+ EnableIPv4 = dto.EnableIPv4,
+ EnableIPv6 = dto.EnableIPv6,
+ EnableRemoteAccess = dto.EnableRemoteAccess,
+ LocalNetworkSubnets = dto.LocalNetworkSubnets,
+ LocalNetworkAddresses = dto.LocalNetworkAddresses,
+ KnownProxies = dto.KnownProxies,
+ IgnoreVirtualInterfaces = dto.IgnoreVirtualInterfaces,
+ VirtualInterfaceNames = dto.VirtualInterfaceNames,
+ EnablePublishedServerUriByRequest = dto.EnablePublishedServerUriByRequest,
+ PublishedServerUriBySubnet = dto.PublishedServerUriBySubnet,
+ RemoteIPFilter = dto.RemoteIPFilter,
+ IsRemoteIPFilterBlacklist = dto.IsRemoteIPFilterBlacklist,
+ };
+ }
+#pragma warning restore CS0618 // Type or member is obsolete
+
+ /// <summary>
+ /// Maps a <see cref="MetadataConfiguration"/> to a <see cref="MetadataConfigurationDto"/>.
+ /// </summary>
+ /// <param name="config">The <see cref="MetadataConfiguration"/>.</param>
+ /// <returns>The <see cref="MetadataConfigurationDto"/>.</returns>
+ public static MetadataConfigurationDto MapToDto(MetadataConfiguration config)
+ {
+ return new MetadataConfigurationDto
+ {
+ UseFileCreationTimeForDateAdded = config.UseFileCreationTimeForDateAdded,
+ };
+ }
+
+ /// <summary>
+ /// Maps a <see cref="MetadataConfigurationDto"/> to a <see cref="MetadataConfiguration"/>.
+ /// </summary>
+ /// <param name="dto">The <see cref="MetadataConfigurationDto"/>.</param>
+ /// <returns>The <see cref="MetadataConfiguration"/>.</returns>
+ public static MetadataConfiguration MapToInternal(MetadataConfigurationDto dto)
+ {
+ return new MetadataConfiguration
+ {
+ UseFileCreationTimeForDateAdded = dto.UseFileCreationTimeForDateAdded,
+ };
+ }
+
+ /// <summary>
+ /// Maps an <see cref="XbmcMetadataOptions"/> to an <see cref="XbmcMetadataOptionsDto"/>.
+ /// </summary>
+ /// <param name="config">The <see cref="XbmcMetadataOptions"/>.</param>
+ /// <returns>The <see cref="XbmcMetadataOptionsDto"/>.</returns>
+ public static XbmcMetadataOptionsDto MapToDto(XbmcMetadataOptions config)
+ {
+ return new XbmcMetadataOptionsDto
+ {
+ UserId = config.UserId,
+ ReleaseDateFormat = config.ReleaseDateFormat,
+ SaveImagePathsInNfo = config.SaveImagePathsInNfo,
+ EnablePathSubstitution = config.EnablePathSubstitution,
+ EnableExtraThumbsDuplication = config.EnableExtraThumbsDuplication,
+ };
+ }
+
+ /// <summary>
+ /// Maps an <see cref="XbmcMetadataOptionsDto"/> to an <see cref="XbmcMetadataOptions"/>.
+ /// </summary>
+ /// <param name="dto">The <see cref="XbmcMetadataOptionsDto"/>.</param>
+ /// <returns>The <see cref="XbmcMetadataOptions"/>.</returns>
+ public static XbmcMetadataOptions MapToInternal(XbmcMetadataOptionsDto dto)
+ {
+ return new XbmcMetadataOptions
+ {
+ UserId = dto.UserId,
+ ReleaseDateFormat = dto.ReleaseDateFormat,
+ SaveImagePathsInNfo = dto.SaveImagePathsInNfo,
+ EnablePathSubstitution = dto.EnablePathSubstitution,
+ EnableExtraThumbsDuplication = dto.EnableExtraThumbsDuplication,
+ };
+ }
+
+ /// <summary>
+ /// Maps a <see cref="LiveTvOptions"/> to a <see cref="LiveTvOptionsDto"/>.
+ /// </summary>
+ /// <param name="config">The <see cref="LiveTvOptions"/>.</param>
+ /// <returns>The <see cref="LiveTvOptionsDto"/>.</returns>
+ public static LiveTvOptionsDto MapToDto(LiveTvOptions config)
+ {
+ return new LiveTvOptionsDto
+ {
+ GuideDays = config.GuideDays,
+ RecordingPath = config.RecordingPath,
+ MovieRecordingPath = config.MovieRecordingPath,
+ SeriesRecordingPath = config.SeriesRecordingPath,
+ EnableRecordingSubfolders = config.EnableRecordingSubfolders,
+ EnableOriginalAudioWithEncodedRecordings = config.EnableOriginalAudioWithEncodedRecordings,
+ TunerHosts = config.TunerHosts,
+ ListingProviders = config.ListingProviders,
+ PrePaddingSeconds = config.PrePaddingSeconds,
+ PostPaddingSeconds = config.PostPaddingSeconds,
+ MediaLocationsCreated = config.MediaLocationsCreated,
+ RecordingPostProcessor = config.RecordingPostProcessor,
+ RecordingPostProcessorArguments = config.RecordingPostProcessorArguments,
+ SaveRecordingNFO = config.SaveRecordingNFO,
+ SaveRecordingImages = config.SaveRecordingImages,
+ };
+ }
+
+ /// <summary>
+ /// Maps a <see cref="LiveTvOptionsDto"/> to a <see cref="LiveTvOptions"/>.
+ /// </summary>
+ /// <param name="dto">The <see cref="LiveTvOptionsDto"/>.</param>
+ /// <returns>The <see cref="LiveTvOptions"/>.</returns>
+ public static LiveTvOptions MapToInternal(LiveTvOptionsDto dto)
+ {
+ return new LiveTvOptions
+ {
+ GuideDays = dto.GuideDays,
+ RecordingPath = dto.RecordingPath,
+ MovieRecordingPath = dto.MovieRecordingPath,
+ SeriesRecordingPath = dto.SeriesRecordingPath,
+ EnableRecordingSubfolders = dto.EnableRecordingSubfolders,
+ EnableOriginalAudioWithEncodedRecordings = dto.EnableOriginalAudioWithEncodedRecordings,
+ TunerHosts = dto.TunerHosts,
+ ListingProviders = dto.ListingProviders,
+ PrePaddingSeconds = dto.PrePaddingSeconds,
+ PostPaddingSeconds = dto.PostPaddingSeconds,
+ MediaLocationsCreated = dto.MediaLocationsCreated,
+ RecordingPostProcessor = dto.RecordingPostProcessor,
+ RecordingPostProcessorArguments = dto.RecordingPostProcessorArguments,
+ SaveRecordingNFO = dto.SaveRecordingNFO,
+ SaveRecordingImages = dto.SaveRecordingImages,
+ };
+ }
+}
diff --git a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
index a498901481..a767e7e5c7 100644
--- a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
+++ b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
@@ -6,6 +6,7 @@ using System.Net.Sockets;
using System.Reflection;
using System.Security.Claims;
using System.Text.Json.Nodes;
+using System.Text.Json.Serialization.Metadata;
using Emby.Server.Implementations;
using Jellyfin.Api.Auth;
using Jellyfin.Api.Auth.AnonymousLanAccessPolicy;
@@ -17,6 +18,7 @@ using Jellyfin.Api.Auth.UserPermissionPolicy;
using Jellyfin.Api.Constants;
using Jellyfin.Api.Controllers;
using Jellyfin.Api.Formatters;
+using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
using Jellyfin.Data.Enums;
using Jellyfin.Database.Implementations.Enums;
@@ -153,6 +155,11 @@ namespace Jellyfin.Server.Extensions
// From JsonDefaults.PascalCase
options.JsonSerializerOptions.PropertyNamingPolicy = jsonOptions.PropertyNamingPolicy;
+
+ options.JsonSerializerOptions.TypeInfoResolver = new DefaultJsonTypeInfoResolver
+ {
+ Modifiers = { ConfigurationJsonTypeInfoModifier.Modify }
+ };
});
foreach (Assembly pluginAssembly in pluginAssemblies)
diff --git a/Jellyfin.Server/Filters/AdditionalModelFilter.cs b/Jellyfin.Server/Filters/AdditionalModelFilter.cs
index efa2f4cca5..a32cb62d98 100644
--- a/Jellyfin.Server/Filters/AdditionalModelFilter.cs
+++ b/Jellyfin.Server/Filters/AdditionalModelFilter.cs
@@ -4,10 +4,7 @@ using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text.Json.Nodes;
-using Jellyfin.Extensions;
-using Jellyfin.Server.Migrations;
using MediaBrowser.Common.Plugins;
-using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Net.WebSocketMessages;
using MediaBrowser.Model.ApiClient;
@@ -23,19 +20,6 @@ namespace Jellyfin.Server.Filters
/// </summary>
public class AdditionalModelFilter : IDocumentFilter
{
- // Array of options that should not be visible in the api spec.
- private static readonly Type[] _ignoredConfigurations = [typeof(MigrationOptions), typeof(MediaBrowser.Model.Branding.BrandingOptions)];
- private readonly IServerConfigurationManager _serverConfigurationManager;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="AdditionalModelFilter"/> class.
- /// </summary>
- /// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
- public AdditionalModelFilter(IServerConfigurationManager serverConfigurationManager)
- {
- _serverConfigurationManager = serverConfigurationManager;
- }
-
/// <inheritdoc />
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
{
@@ -202,16 +186,6 @@ namespace Jellyfin.Server.Filters
context.SchemaRepository.Schemas[nameof(GroupUpdate<object>)] = groupUpdateSchema;
context.SchemaGenerator.GenerateSchema(typeof(ServerDiscoveryInfo), context.SchemaRepository);
-
- foreach (var configuration in _serverConfigurationManager.GetConfigurationStores())
- {
- if (_ignoredConfigurations.IndexOf(configuration.ConfigurationType) != -1)
- {
- continue;
- }
-
- context.SchemaGenerator.GenerateSchema(configuration.ConfigurationType, context.SchemaRepository);
- }
}
}
}
diff --git a/MediaBrowser.Common/Net/NetworkConfigurationDto.cs b/MediaBrowser.Common/Net/NetworkConfigurationDto.cs
new file mode 100644
index 0000000000..12be0d9fb8
--- /dev/null
+++ b/MediaBrowser.Common/Net/NetworkConfigurationDto.cs
@@ -0,0 +1,124 @@
+#pragma warning disable CA1819
+
+namespace MediaBrowser.Common.Net;
+
+/// <summary>
+/// The network configuration DTO for API use.
+/// </summary>
+public class NetworkConfigurationDto
+{
+ /// <summary>
+ /// Gets or sets a value used to specify the URL prefix that your Jellyfin instance can be accessed at.
+ /// </summary>
+ public string BaseUrl { get; set; } = null!;
+
+ /// <summary>
+ /// Gets or sets a value indicating whether to use HTTPS.
+ /// </summary>
+ public bool EnableHttps { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the server should force connections over HTTPS.
+ /// </summary>
+ public bool RequireHttps { get; set; }
+
+ /// <summary>
+ /// Gets or sets the filesystem path of an X.509 certificate to use for SSL.
+ /// </summary>
+ public string? CertificatePath { get; set; }
+
+ /// <summary>
+ /// Gets or sets the password required to access the X.509 certificate data in the file specified by <see cref="CertificatePath"/>.
+ /// </summary>
+ public string? CertificatePassword { get; set; }
+
+ /// <summary>
+ /// Gets or sets the internal HTTP server port.
+ /// </summary>
+ public int InternalHttpPort { get; set; }
+
+ /// <summary>
+ /// Gets or sets the internal HTTPS server port.
+ /// </summary>
+ public int InternalHttpsPort { get; set; }
+
+ /// <summary>
+ /// Gets or sets the public HTTP port.
+ /// </summary>
+ public int PublicHttpPort { get; set; }
+
+ /// <summary>
+ /// Gets or sets the public HTTPS port.
+ /// </summary>
+ public int PublicHttpsPort { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether Autodiscovery is enabled.
+ /// </summary>
+ public bool AutoDiscovery { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether to enable automatic port forwarding.
+ /// </summary>
+ public bool EnableUPnP { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether IPv4 is enabled.
+ /// </summary>
+ public bool EnableIPv4 { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether IPv6 is enabled.
+ /// </summary>
+ public bool EnableIPv6 { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether access from outside of the LAN is permitted.
+ /// </summary>
+ public bool EnableRemoteAccess { get; set; }
+
+ /// <summary>
+ /// Gets or sets the subnets that are deemed to make up the LAN.
+ /// </summary>
+ public string[] LocalNetworkSubnets { get; set; } = null!;
+
+ /// <summary>
+ /// Gets or sets the interface addresses which Jellyfin will bind to. If empty, all interfaces will be used.
+ /// </summary>
+ public string[] LocalNetworkAddresses { get; set; } = null!;
+
+ /// <summary>
+ /// Gets or sets the known proxies.
+ /// </summary>
+ public string[] KnownProxies { get; set; } = null!;
+
+ /// <summary>
+ /// Gets or sets a value indicating whether address names that match <see cref="VirtualInterfaceNames"/> should be ignored for the purposes of binding.
+ /// </summary>
+ public bool IgnoreVirtualInterfaces { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating the interface name prefixes that should be ignored.
+ /// </summary>
+ public string[] VirtualInterfaceNames { get; set; } = null!;
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the published server uri is based on information in HTTP requests.
+ /// </summary>
+ public bool EnablePublishedServerUriByRequest { get; set; }
+
+ /// <summary>
+ /// Gets or sets PublishedServerUri to advertise for specific subnets.
+ /// </summary>
+ public string[] PublishedServerUriBySubnet { get; set; } = null!;
+
+ /// <summary>
+ /// Gets or sets the filter for remote IP connectivity. Used in conjunction with <seealso cref="IsRemoteIPFilterBlacklist"/>.
+ /// </summary>
+ public string[] RemoteIPFilter { get; set; } = null!;
+
+ /// <summary>
+ /// Gets or sets a value indicating whether <seealso cref="RemoteIPFilter"/> contains a blacklist or a whitelist. Default is a whitelist.
+ /// </summary>
+ public bool IsRemoteIPFilterBlacklist { get; set; }
+}
diff --git a/MediaBrowser.Model/Configuration/EncodingOptionsDto.cs b/MediaBrowser.Model/Configuration/EncodingOptionsDto.cs
new file mode 100644
index 0000000000..0bc009f402
--- /dev/null
+++ b/MediaBrowser.Model/Configuration/EncodingOptionsDto.cs
@@ -0,0 +1,257 @@
+#pragma warning disable CA1819
+
+#nullable disable
+using MediaBrowser.Model.Entities;
+
+namespace MediaBrowser.Model.Configuration;
+
+/// <summary>
+/// The encoding options DTO for API use.
+/// </summary>
+public class EncodingOptionsDto
+{
+ /// <summary>
+ /// Gets or sets the thread count used for encoding.
+ /// </summary>
+ public int EncodingThreadCount { get; set; }
+
+ /// <summary>
+ /// Gets or sets the temporary transcoding path.
+ /// </summary>
+ public string TranscodingTempPath { get; set; }
+
+ /// <summary>
+ /// Gets or sets the path to the fallback font.
+ /// </summary>
+ public string FallbackFontPath { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether to use the fallback font.
+ /// </summary>
+ public bool EnableFallbackFont { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether audio VBR is enabled.
+ /// </summary>
+ public bool EnableAudioVbr { get; set; }
+
+ /// <summary>
+ /// Gets or sets the audio boost applied when downmixing audio.
+ /// </summary>
+ public double DownMixAudioBoost { get; set; }
+
+ /// <summary>
+ /// Gets or sets the algorithm used for downmixing audio to stereo.
+ /// </summary>
+ public DownMixStereoAlgorithms DownMixStereoAlgorithm { get; set; }
+
+ /// <summary>
+ /// Gets or sets the maximum size of the muxing queue.
+ /// </summary>
+ public int MaxMuxingQueueSize { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether throttling is enabled.
+ /// </summary>
+ public bool EnableThrottling { get; set; }
+
+ /// <summary>
+ /// Gets or sets the delay after which throttling happens.
+ /// </summary>
+ public int ThrottleDelaySeconds { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether segment deletion is enabled.
+ /// </summary>
+ public bool EnableSegmentDeletion { get; set; }
+
+ /// <summary>
+ /// Gets or sets seconds for which segments should be kept before being deleted.
+ /// </summary>
+ public int SegmentKeepSeconds { get; set; }
+
+ /// <summary>
+ /// Gets or sets the hardware acceleration type.
+ /// </summary>
+ public HardwareAccelerationType HardwareAccelerationType { get; set; }
+
+ /// <summary>
+ /// Gets or sets the FFmpeg path as set by the user via the UI.
+ /// </summary>
+ public string EncoderAppPath { get; set; }
+
+ /// <summary>
+ /// Gets or sets the current FFmpeg path being used by the system and displayed on the transcode page.
+ /// </summary>
+ public string EncoderAppPathDisplay { get; set; }
+
+ /// <summary>
+ /// Gets or sets the VA-API device.
+ /// </summary>
+ public string VaapiDevice { get; set; }
+
+ /// <summary>
+ /// Gets or sets the QSV device.
+ /// </summary>
+ public string QsvDevice { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether tonemapping is enabled.
+ /// </summary>
+ public bool EnableTonemapping { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether VPP tonemapping is enabled.
+ /// </summary>
+ public bool EnableVppTonemapping { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether videotoolbox tonemapping is enabled.
+ /// </summary>
+ public bool EnableVideoToolboxTonemapping { get; set; }
+
+ /// <summary>
+ /// Gets or sets the tone-mapping algorithm.
+ /// </summary>
+ public TonemappingAlgorithm TonemappingAlgorithm { get; set; }
+
+ /// <summary>
+ /// Gets or sets the tone-mapping mode.
+ /// </summary>
+ public TonemappingMode TonemappingMode { get; set; }
+
+ /// <summary>
+ /// Gets or sets the tone-mapping range.
+ /// </summary>
+ public TonemappingRange TonemappingRange { get; set; }
+
+ /// <summary>
+ /// Gets or sets the tone-mapping desaturation.
+ /// </summary>
+ public double TonemappingDesat { get; set; }
+
+ /// <summary>
+ /// Gets or sets the tone-mapping peak.
+ /// </summary>
+ public double TonemappingPeak { get; set; }
+
+ /// <summary>
+ /// Gets or sets the tone-mapping parameters.
+ /// </summary>
+ public double TonemappingParam { get; set; }
+
+ /// <summary>
+ /// Gets or sets the VPP tone-mapping brightness.
+ /// </summary>
+ public double VppTonemappingBrightness { get; set; }
+
+ /// <summary>
+ /// Gets or sets the VPP tone-mapping contrast.
+ /// </summary>
+ public double VppTonemappingContrast { get; set; }
+
+ /// <summary>
+ /// Gets or sets the H264 CRF.
+ /// </summary>
+ public int H264Crf { get; set; }
+
+ /// <summary>
+ /// Gets or sets the H265 CRF.
+ /// </summary>
+ public int H265Crf { get; set; }
+
+ /// <summary>
+ /// Gets or sets the encoder preset.
+ /// </summary>
+ public EncoderPreset EncoderPreset { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the framerate is doubled when deinterlacing.
+ /// </summary>
+ public bool DeinterlaceDoubleRate { get; set; }
+
+ /// <summary>
+ /// Gets or sets the deinterlace method.
+ /// </summary>
+ public DeinterlaceMethod DeinterlaceMethod { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether 10bit HEVC decoding is enabled.
+ /// </summary>
+ public bool EnableDecodingColorDepth10Hevc { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether 10bit VP9 decoding is enabled.
+ /// </summary>
+ public bool EnableDecodingColorDepth10Vp9 { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether 8/10bit HEVC RExt decoding is enabled.
+ /// </summary>
+ public bool EnableDecodingColorDepth10HevcRext { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether 12bit HEVC RExt decoding is enabled.
+ /// </summary>
+ public bool EnableDecodingColorDepth12HevcRext { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the enhanced NVDEC is enabled.
+ /// </summary>
+ public bool EnableEnhancedNvdecDecoder { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the system native hardware decoder should be used.
+ /// </summary>
+ public bool PreferSystemNativeHwDecoder { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the Intel H264 low-power hardware encoder should be used.
+ /// </summary>
+ public bool EnableIntelLowPowerH264HwEncoder { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the Intel HEVC low-power hardware encoder should be used.
+ /// </summary>
+ public bool EnableIntelLowPowerHevcHwEncoder { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether hardware encoding is enabled.
+ /// </summary>
+ public bool EnableHardwareEncoding { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether HEVC encoding is enabled.
+ /// </summary>
+ public bool AllowHevcEncoding { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether AV1 encoding is enabled.
+ /// </summary>
+ public bool AllowAv1Encoding { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether subtitle extraction is enabled.
+ /// </summary>
+ public bool EnableSubtitleExtraction { get; set; }
+
+ /// <summary>
+ /// Gets or sets the timeout for subtitle extraction in minutes.
+ /// </summary>
+ public int SubtitleExtractionTimeoutMinutes { get; set; }
+
+ /// <summary>
+ /// Gets or sets the codecs hardware encoding is used for.
+ /// </summary>
+ public string[] HardwareDecodingCodecs { get; set; }
+
+ /// <summary>
+ /// Gets or sets the file extensions on-demand metadata based keyframe extraction is enabled for.
+ /// </summary>
+ public string[] AllowOnDemandMetadataBasedKeyframeExtractionForExtensions { get; set; }
+
+ /// <summary>
+ /// Gets or sets the method used for audio seeking in HLS.
+ /// </summary>
+ public HlsAudioSeekStrategy HlsAudioSeekStrategy { get; set; }
+}
diff --git a/MediaBrowser.Model/Configuration/MetadataConfigurationDto.cs b/MediaBrowser.Model/Configuration/MetadataConfigurationDto.cs
new file mode 100644
index 0000000000..e07f9e34de
--- /dev/null
+++ b/MediaBrowser.Model/Configuration/MetadataConfigurationDto.cs
@@ -0,0 +1,12 @@
+namespace MediaBrowser.Model.Configuration;
+
+/// <summary>
+/// The metadata configuration DTO for API use.
+/// </summary>
+public class MetadataConfigurationDto
+{
+ /// <summary>
+ /// Gets or sets a value indicating whether to use file creation time for date added.
+ /// </summary>
+ public bool UseFileCreationTimeForDateAdded { get; set; }
+}
diff --git a/MediaBrowser.Model/Configuration/ServerConfigurationDto.cs b/MediaBrowser.Model/Configuration/ServerConfigurationDto.cs
new file mode 100644
index 0000000000..3f2bfe04f0
--- /dev/null
+++ b/MediaBrowser.Model/Configuration/ServerConfigurationDto.cs
@@ -0,0 +1,125 @@
+#pragma warning disable CS1591
+#pragma warning disable CA1819
+
+using MediaBrowser.Model.Drawing;
+using MediaBrowser.Model.Dto;
+using MediaBrowser.Model.System;
+using MediaBrowser.Model.Updates;
+
+namespace MediaBrowser.Model.Configuration;
+
+/// <summary>
+/// The server configuration DTO for API use.
+/// </summary>
+public class ServerConfigurationDto
+{
+ public int LogFileRetentionDays { get; set; }
+
+ public bool IsStartupWizardCompleted { get; set; }
+
+ public string? CachePath { get; set; }
+
+ public string? PreviousVersionStr { get; set; }
+
+ public bool EnableMetrics { get; set; }
+
+ public bool EnableNormalizedItemByNameIds { get; set; }
+
+ public bool IsPortAuthorized { get; set; }
+
+ public bool QuickConnectAvailable { get; set; }
+
+ public bool EnableCaseSensitiveItemIds { get; set; }
+
+ public bool DisableLiveTvChannelUserDataName { get; set; }
+
+ public string MetadataPath { get; set; } = null!;
+
+ public string PreferredMetadataLanguage { get; set; } = null!;
+
+ public string MetadataCountryCode { get; set; } = null!;
+
+ public string[] SortReplaceCharacters { get; set; } = null!;
+
+ public string[] SortRemoveCharacters { get; set; } = null!;
+
+ public string[] SortRemoveWords { get; set; } = null!;
+
+ public int MinResumePct { get; set; }
+
+ public int MaxResumePct { get; set; }
+
+ public int MinResumeDurationSeconds { get; set; }
+
+ public int MinAudiobookResume { get; set; }
+
+ public int MaxAudiobookResume { get; set; }
+
+ public int InactiveSessionThreshold { get; set; }
+
+ public int LibraryMonitorDelay { get; set; }
+
+ public int LibraryUpdateDuration { get; set; }
+
+ public int CacheSize { get; set; }
+
+ public ImageSavingConvention ImageSavingConvention { get; set; }
+
+ public MetadataOptions[] MetadataOptions { get; set; } = null!;
+
+ public bool SkipDeserializationForBasicTypes { get; set; }
+
+ public string ServerName { get; set; } = null!;
+
+ public string UICulture { get; set; } = null!;
+
+ public bool SaveMetadataHidden { get; set; }
+
+ public NameValuePair[] ContentTypes { get; set; } = null!;
+
+ public int RemoteClientBitrateLimit { get; set; }
+
+ public bool EnableFolderView { get; set; }
+
+ public bool EnableGroupingMoviesIntoCollections { get; set; }
+
+ public bool EnableGroupingShowsIntoCollections { get; set; }
+
+ public bool DisplaySpecialsWithinSeasons { get; set; }
+
+ public string[] CodecsUsed { get; set; } = null!;
+
+ public RepositoryInfo[] PluginRepositories { get; set; } = null!;
+
+ public bool EnableExternalContentInSuggestions { get; set; }
+
+ public int ImageExtractionTimeoutMs { get; set; }
+
+ public PathSubstitution[] PathSubstitutions { get; set; } = null!;
+
+ public bool EnableSlowResponseWarning { get; set; }
+
+ public long SlowResponseThresholdMs { get; set; }
+
+ public string[] CorsHosts { get; set; } = null!;
+
+ public int? ActivityLogRetentionDays { get; set; }
+
+ public int LibraryScanFanoutConcurrency { get; set; }
+
+ public int LibraryMetadataRefreshConcurrency { get; set; }
+
+ public bool AllowClientLogUpload { get; set; }
+
+ public int DummyChapterDuration { get; set; }
+
+ public ImageResolution ChapterImageResolution { get; set; }
+
+ public int ParallelImageEncodingLimit { get; set; }
+
+ public CastReceiverApplication[] CastReceiverApplications { get; set; } = null!;
+
+ public TrickplayOptions TrickplayOptions { get; set; } = null!;
+
+ public bool EnableLegacyAuthorization { get; set; }
+}
diff --git a/MediaBrowser.Model/Configuration/XbmcMetadataOptionsDto.cs b/MediaBrowser.Model/Configuration/XbmcMetadataOptionsDto.cs
new file mode 100644
index 0000000000..e2c118ddbe
--- /dev/null
+++ b/MediaBrowser.Model/Configuration/XbmcMetadataOptionsDto.cs
@@ -0,0 +1,32 @@
+namespace MediaBrowser.Model.Configuration;
+
+/// <summary>
+/// The XBMC metadata options DTO for API use.
+/// </summary>
+public class XbmcMetadataOptionsDto
+{
+ /// <summary>
+ /// Gets or sets the user id.
+ /// </summary>
+ public string? UserId { get; set; }
+
+ /// <summary>
+ /// Gets or sets the release date format.
+ /// </summary>
+ public string ReleaseDateFormat { get; set; } = null!;
+
+ /// <summary>
+ /// Gets or sets a value indicating whether to save image paths in NFO.
+ /// </summary>
+ public bool SaveImagePathsInNfo { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether to enable path substitution.
+ /// </summary>
+ public bool EnablePathSubstitution { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether to enable extra thumbs duplication.
+ /// </summary>
+ public bool EnableExtraThumbsDuplication { get; set; }
+}
diff --git a/MediaBrowser.Model/LiveTv/LiveTvOptionsDto.cs b/MediaBrowser.Model/LiveTv/LiveTvOptionsDto.cs
new file mode 100644
index 0000000000..3ed7d5b2e5
--- /dev/null
+++ b/MediaBrowser.Model/LiveTv/LiveTvOptionsDto.cs
@@ -0,0 +1,84 @@
+#pragma warning disable CA1819
+
+namespace MediaBrowser.Model.LiveTv;
+
+/// <summary>
+/// The LiveTV options DTO for API use.
+/// </summary>
+public class LiveTvOptionsDto
+{
+ /// <summary>
+ /// Gets or sets the guide days.
+ /// </summary>
+ public int? GuideDays { get; set; }
+
+ /// <summary>
+ /// Gets or sets the recording path.
+ /// </summary>
+ public string? RecordingPath { get; set; }
+
+ /// <summary>
+ /// Gets or sets the movie recording path.
+ /// </summary>
+ public string? MovieRecordingPath { get; set; }
+
+ /// <summary>
+ /// Gets or sets the series recording path.
+ /// </summary>
+ public string? SeriesRecordingPath { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether to enable recording subfolders.
+ /// </summary>
+ public bool EnableRecordingSubfolders { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether to enable original audio with encoded recordings.
+ /// </summary>
+ public bool EnableOriginalAudioWithEncodedRecordings { get; set; }
+
+ /// <summary>
+ /// Gets or sets the tuner hosts.
+ /// </summary>
+ public TunerHostInfo[] TunerHosts { get; set; } = null!;
+
+ /// <summary>
+ /// Gets or sets the listing providers.
+ /// </summary>
+ public ListingsProviderInfo[] ListingProviders { get; set; } = null!;
+
+ /// <summary>
+ /// Gets or sets the pre-padding seconds.
+ /// </summary>
+ public int PrePaddingSeconds { get; set; }
+
+ /// <summary>
+ /// Gets or sets the post-padding seconds.
+ /// </summary>
+ public int PostPaddingSeconds { get; set; }
+
+ /// <summary>
+ /// Gets or sets the media locations created.
+ /// </summary>
+ public string[] MediaLocationsCreated { get; set; } = null!;
+
+ /// <summary>
+ /// Gets or sets the recording post processor.
+ /// </summary>
+ public string? RecordingPostProcessor { get; set; }
+
+ /// <summary>
+ /// Gets or sets the recording post processor arguments.
+ /// </summary>
+ public string RecordingPostProcessorArguments { get; set; } = null!;
+
+ /// <summary>
+ /// Gets or sets a value indicating whether to save recording NFO.
+ /// </summary>
+ public bool SaveRecordingNFO { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether to save recording images.
+ /// </summary>
+ public bool SaveRecordingImages { get; set; }
+}
diff --git a/src/Jellyfin.LiveTv/Listings/SchedulesDirect.cs b/src/Jellyfin.LiveTv/Listings/SchedulesDirect.cs
index 40ec99e9a5..d2076767b8 100644
--- a/src/Jellyfin.LiveTv/Listings/SchedulesDirect.cs
+++ b/src/Jellyfin.LiveTv/Listings/SchedulesDirect.cs
@@ -782,7 +782,7 @@ namespace Jellyfin.LiveTv.Listings
var root = await Request<TokenDto>(options, false, null, cancellationToken).ConfigureAwait(false);
if (string.Equals(root?.Message, "OK", StringComparison.Ordinal))
{
- _logger.LogInformation("Authenticated with Schedules Direct token: {Token}", root.Token);
+ _logger.LogInformation("Authenticated with Schedules Direct. Token expires at {TokenTimestamp}", root.TokenTimestamp);
return root.Token;
}
diff --git a/tests/Jellyfin.Server.Integration.Tests/Controllers/ConfigurationControllerTests.cs b/tests/Jellyfin.Server.Integration.Tests/Controllers/ConfigurationControllerTests.cs
new file mode 100644
index 0000000000..94672d5c7b
--- /dev/null
+++ b/tests/Jellyfin.Server.Integration.Tests/Controllers/ConfigurationControllerTests.cs
@@ -0,0 +1,248 @@
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Net.Http;
+using System.Net.Mime;
+using System.Reflection;
+using System.Security.Claims;
+using System.Text;
+using System.Text.Json;
+using System.Text.Json.Nodes;
+using System.Threading.Tasks;
+using Jellyfin.Extensions.Json;
+using Jellyfin.Server.Extensions;
+using MediaBrowser.Common.Api;
+using MediaBrowser.Common.Net;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Model.Configuration;
+using MediaBrowser.Model.LiveTv;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.TestHost;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Moq;
+using Xunit;
+
+namespace Jellyfin.Server.Integration.Tests.Controllers;
+
+public sealed class ConfigurationControllerTests : IDisposable
+{
+ private readonly Dictionary<string, object> _configurations = new()
+ {
+ [string.Empty] = new ServerConfiguration(),
+ ["encoding"] = new EncodingOptions(),
+ ["network"] = new NetworkConfiguration(),
+ ["metadata"] = new MetadataConfiguration(),
+ ["xbmcmetadata"] = new XbmcMetadataOptions(),
+ ["livetv"] = new LiveTvOptions()
+ };
+
+ private readonly Mock<IServerConfigurationManager> _configurationManager = new();
+ private readonly IHost _host;
+ private readonly HttpClient _client;
+
+ public ConfigurationControllerTests()
+ {
+ _configurationManager.Setup(manager => manager.Configuration)
+ .Returns(() => (ServerConfiguration)_configurations[string.Empty]);
+ _configurationManager.Setup(manager => manager.ReplaceConfiguration(It.IsAny<BaseApplicationConfiguration>()))
+ .Callback<BaseApplicationConfiguration>(configuration => _configurations[string.Empty] = configuration);
+ _configurationManager.Setup(manager => manager.GetConfiguration(It.IsAny<string>()))
+ .Returns((string key) => _configurations[key]);
+ _configurationManager.Setup(manager => manager.SaveConfiguration(It.IsAny<string>(), It.IsAny<object>()))
+ .Callback<string, object>((key, configuration) => _configurations[key] = configuration);
+
+ // Use the real API setup, but keep config in memory for these tests.
+ _host = new HostBuilder().ConfigureWebHost(webHost => webHost
+ .UseTestServer()
+ .ConfigureServices(services =>
+ {
+ services.AddSingleton(_configurationManager.Object);
+ services.AddAuthentication();
+ services.AddAuthorization(options =>
+ {
+ options.AddPolicy(Policies.RequiresElevation, policy => policy.RequireAuthenticatedUser());
+ });
+ services.AddJellyfinApi(Array.Empty<Assembly>(), new NetworkConfiguration());
+ })
+ .Configure(app =>
+ {
+ app.UseRouting();
+ app.Use((context, next) =>
+ {
+ context.User = new ClaimsPrincipal(new ClaimsIdentity("Test"));
+ return next(context);
+ });
+ app.UseAuthorization();
+ app.UseEndpoints(endpoints => endpoints.MapControllers());
+ })).Start();
+ _client = _host.GetTestClient();
+ }
+
+ [Theory]
+ [InlineData("")]
+ [InlineData("encoding")]
+ [InlineData("network")]
+ [InlineData("metadata")]
+ [InlineData("xbmcmetadata")]
+ [InlineData("livetv")]
+ public async Task UpdateConfiguration_EmptyRequest_UsesInternalDefaults(string key)
+ {
+ await AssertMatchesLegacyDeserialization(key, "{}");
+ }
+
+ [Theory]
+ [InlineData("", """
+ {"ActivityLogRetentionDays":null,"QuickConnectAvailable":false,"MinResumePct":0,
+ "SortRemoveWords":[],"TrickplayOptions":{"EnableHwAcceleration":true}}
+ """)]
+ [InlineData("encoding", """
+ {"EnableHardwareEncoding":false,"EncodingThreadCount":0,"HardwareDecodingCodecs":[],
+ "H264Crf":"19","EncoderPreset":"slow","VaapiDevice":null,"UnknownOption":true}
+ """)]
+ [InlineData("network", """
+ {"CertificatePath":null,"CertificatePassword":null,"InternalHttpPort":"8097",
+ "EnableRemoteAccess":false,"BaseUrl":"jellyfin/","KnownProxies":[]}
+ """)]
+ [InlineData("network", """
+ {"BaseUrl":"","LocalNetworkSubnets":[],"LocalNetworkAddresses":[],"KnownProxies":[],
+ "VirtualInterfaceNames":[],"PublishedServerUriBySubnet":[],"RemoteIPFilter":[]}
+ """)]
+ [InlineData("metadata", """{"UseFileCreationTimeForDateAdded":false}""")]
+ [InlineData("xbmcmetadata", """{"UserId":"","ReleaseDateFormat":"yyyy-MM-dd","SaveImagePathsInNfo":false}""")]
+ [InlineData("livetv", """
+ {"GuideDays":"","RecordingPath":null,"SaveRecordingNFO":false,
+ "TunerHosts":[{"Url":"http://tuner"}],"ListingProviders":[{"Type":"XmlTv"}]}
+ """)]
+ [InlineData("livetv", """{"TunerHosts":[],"ListingProviders":[],"MediaLocationsCreated":[]}""")]
+ public async Task UpdateConfiguration_SuppliedProperties_MatchLegacyDeserialization(string key, string json)
+ {
+ await AssertMatchesLegacyDeserialization(key, json);
+ }
+
+ [Theory]
+ [InlineData("", "ServerName", "\"My server\"")]
+ [InlineData("encoding", "H264Crf", "18")]
+ [InlineData("network", "InternalHttpPort", "8097")]
+ [InlineData("metadata", "UseFileCreationTimeForDateAdded", "false")]
+ [InlineData("xbmcmetadata", "SaveImagePathsInNfo", "false")]
+ [InlineData("livetv", "GuideDays", "7")]
+ public async Task GetAndUpdateConfiguration_LowercaseRoute_RoundTripsConfiguration(string key, string property, string value)
+ {
+ using var response = await _client.GetAsync(GetUrl(key), TestContext.Current.CancellationToken);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
+
+ var body = JsonNode.Parse(await response.Content.ReadAsStringAsync(TestContext.Current.CancellationToken))!.AsObject();
+ var expected = JsonSerializer.SerializeToNode(_configurations[key], JsonDefaults.Options)!.AsObject();
+ Assert.True(JsonNode.DeepEquals(expected, body));
+
+ body[property] = JsonNode.Parse(value);
+ expected[property] = JsonNode.Parse(value);
+ await PostConfiguration(key, body.ToJsonString());
+
+ Assert.True(JsonNode.DeepEquals(expected, JsonSerializer.SerializeToNode(_configurations[key], JsonDefaults.Options)));
+ }
+
+ [Fact]
+ public async Task UpdateConfiguration_CamelCaseProperties_AreApplied()
+ {
+ await PostConfiguration("encoding", """{"h264Crf":18,"enableHardwareEncoding":false}""");
+
+ var configuration = Assert.IsType<EncodingOptions>(_configurations["encoding"]);
+ Assert.Equal(18, configuration.H264Crf);
+ Assert.False(configuration.EnableHardwareEncoding);
+ Assert.Equal(new EncodingOptions().H265Crf, configuration.H265Crf);
+
+ using var request = new HttpRequestMessage(HttpMethod.Get, GetUrl("encoding"));
+ request.Headers.Accept.ParseAdd(JsonDefaults.CamelCaseMediaType);
+ using var response = await _client.SendAsync(request, TestContext.Current.CancellationToken);
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ var body = JsonNode.Parse(await response.Content.ReadAsStringAsync(TestContext.Current.CancellationToken));
+ Assert.Equal(18, body!["h264Crf"]!.GetValue<int>());
+ }
+
+ [Fact]
+ public async Task UpdateConfiguration_OmittedProperties_ResetToDefaultsRatherThanCurrentValues()
+ {
+ await PostConfiguration("encoding", """{"H264Crf":18,"EnableHardwareEncoding":false}""");
+ await AssertMatchesLegacyDeserialization("encoding", "{}");
+ }
+
+ [Fact]
+ public async Task UpdateConfiguration_DefaultObjects_AreNotSharedBetweenRequests()
+ {
+ await PostConfiguration(string.Empty, "{}");
+ var first = Assert.IsType<ServerConfiguration>(_configurations[string.Empty]);
+ first.MetadataOptions[0].ItemType = "Changed";
+ first.TrickplayOptions.WidthResolutions[0] = 123;
+
+ await AssertMatchesLegacyDeserialization(string.Empty, "{}");
+ var second = Assert.IsType<ServerConfiguration>(_configurations[string.Empty]);
+ Assert.NotSame(first.MetadataOptions, second.MetadataOptions);
+ Assert.NotSame(first.TrickplayOptions, second.TrickplayOptions);
+ }
+
+ [Theory]
+ [InlineData("encoding", "null")]
+ [InlineData("encoding", """{"H264Crf":null}""")]
+ [InlineData("network", """{"InternalHttpPort":"invalid"}""")]
+ [InlineData("network", """{"BaseUrl":null}""")]
+ [InlineData("network", """{"LocalNetworkSubnets":null}""")]
+ [InlineData("network", """{"LocalNetworkAddresses":null}""")]
+ [InlineData("network", """{"KnownProxies":null}""")]
+ [InlineData("network", """{"VirtualInterfaceNames":null}""")]
+ [InlineData("network", """{"PublishedServerUriBySubnet":null}""")]
+ [InlineData("network", """{"RemoteIPFilter":null}""")]
+ [InlineData("livetv", """{"TunerHosts":null}""")]
+ [InlineData("livetv", """{"ListingProviders":null}""")]
+ [InlineData("livetv", """{"MediaLocationsCreated":null}""")]
+ [InlineData("livetv", """{"RecordingPostProcessorArguments":null}""")]
+ [InlineData("xbmcmetadata", """{"ReleaseDateFormat":null}""")]
+ [InlineData("", """{"ServerName":null}""")]
+ public async Task UpdateConfiguration_InvalidRequest_DoesNotSave(string key, string json)
+ {
+ using var content = new StringContent(json, Encoding.UTF8, MediaTypeNames.Application.Json);
+ using var response = await _client.PostAsync(GetUrl(key), content, TestContext.Current.CancellationToken);
+
+ Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
+ _configurationManager.Verify(manager => manager.SaveConfiguration(It.IsAny<string>(), It.IsAny<object>()), Times.Never);
+ _configurationManager.Verify(manager => manager.ReplaceConfiguration(It.IsAny<BaseApplicationConfiguration>()), Times.Never);
+ }
+
+ public void Dispose()
+ {
+ _client.Dispose();
+ _host.Dispose();
+ }
+
+ private static string GetUrl(string key)
+ {
+ return string.IsNullOrEmpty(key) ? "/System/Configuration" : "/System/Configuration/" + key;
+ }
+
+ private async Task AssertMatchesLegacyDeserialization(string key, string json)
+ {
+ // Compare with how the old endpoint read the same JSON.
+ var type = _configurations[key].GetType();
+ var expected = JsonSerializer.Deserialize(json, type, JsonDefaults.Options);
+
+ await PostConfiguration(key, json);
+
+ var actual = _configurations[key];
+ Assert.IsType(type, actual);
+ Assert.True(JsonNode.DeepEquals(
+ JsonSerializer.SerializeToNode(expected, type, JsonDefaults.Options),
+ JsonSerializer.SerializeToNode(actual, type, JsonDefaults.Options)));
+ }
+
+ private async Task PostConfiguration(string key, string json)
+ {
+ using var content = new StringContent(json, Encoding.UTF8, MediaTypeNames.Application.Json);
+ using var response = await _client.PostAsync(GetUrl(key), content, TestContext.Current.CancellationToken);
+ Assert.True(
+ response.StatusCode == HttpStatusCode.NoContent,
+ $"{response.StatusCode}: {await response.Content.ReadAsStringAsync(TestContext.Current.CancellationToken)}");
+ }
+}