using System; using Microsoft.Extensions.Configuration; namespace MediaBrowser.Controller.Extensions { /// /// Configuration extensions for MediaBrowser.Controller. /// public static class ConfigurationExtensions { /// /// The key for a setting that specifies the default redirect path /// to use for requests where the URL base prefix is invalid or missing.. /// public const string DefaultRedirectKey = "DefaultRedirectPath"; /// /// The key for the address override option. /// public const string AddressOverrideKey = "PublishedServerUrl"; /// /// The key for a setting that indicates whether the application should host web client content. /// public const string HostWebClientKey = "hostwebclient"; /// /// The key for the FFmpeg probe size option. /// public const string FfmpegProbeSizeKey = "FFmpeg:probesize"; /// /// The key for the FFmpeg analyze duration option. /// public const string FfmpegAnalyzeDurationKey = "FFmpeg:analyzeduration"; /// /// The key for the FFmpeg path option. /// public const string FfmpegPathKey = "ffmpeg"; /// /// The key for a setting that indicates whether playlists should allow duplicate entries. /// public const string PlaylistsAllowDuplicatesKey = "playlists:allowDuplicates"; /// /// The key for a setting that indicates whether kestrel should bind to a unix socket. /// public const string BindToUnixSocketKey = "kestrel:socket"; /// /// The key for the unix socket path. /// public const string UnixSocketPathKey = "kestrel:socketPath"; /// /// The permissions for the unix socket. /// public const string UnixSocketPermissionsKey = "kestrel:socketPermissions"; /// /// The cache size of the SQL database, see cache_size. /// public const string SqliteCacheSizeKey = "sqlite:cacheSize"; /// /// Disable WAL journaling of sqlite. /// public const string SqliteDisableWalKey = "sqlite:disableWal"; /// /// Gets a value indicating whether the application should host static web content from the . /// /// The configuration to retrieve the value from. /// The parsed config value. /// The config value is not a valid bool string. See . public static bool HostWebClient(this IConfiguration configuration) => configuration.GetValue(HostWebClientKey); /// /// Gets the FFmpeg probe size from the . /// /// The configuration to read the setting from. /// The FFmpeg probe size option. public static string? GetFFmpegProbeSize(this IConfiguration configuration) => configuration[FfmpegProbeSizeKey]; /// /// Gets the FFmpeg analyze duration from the . /// /// The configuration to read the setting from. /// The FFmpeg analyze duration option. public static string? GetFFmpegAnalyzeDuration(this IConfiguration configuration) => configuration[FfmpegAnalyzeDurationKey]; /// /// Gets a value indicating whether playlists should allow duplicate entries from the . /// /// The configuration to read the setting from. /// True if playlists should allow duplicates, otherwise false. public static bool DoPlaylistsAllowDuplicates(this IConfiguration configuration) => configuration.GetValue(PlaylistsAllowDuplicatesKey); /// /// Gets a value indicating whether kestrel should bind to a unix socket from the . /// /// The configuration to read the setting from. /// true if kestrel should bind to a unix socket, otherwise false. public static bool UseUnixSocket(this IConfiguration configuration) => configuration.GetValue(BindToUnixSocketKey); /// /// Gets the path for the unix socket from the . /// /// The configuration to read the setting from. /// The unix socket path. public static string? GetUnixSocketPath(this IConfiguration configuration) => configuration[UnixSocketPathKey]; /// /// Gets the permissions for the unix socket from the . /// /// The configuration to read the setting from. /// The unix socket permissions. public static string? GetUnixSocketPermissions(this IConfiguration configuration) => configuration[UnixSocketPermissionsKey]; /// /// Gets the cache_size from the . /// /// The configuration to read the setting from. /// The sqlite cache size. public static int? GetSqliteCacheSize(this IConfiguration configuration) => configuration.GetValue(SqliteCacheSizeKey); /// /// Gets whether WAL journaling disabled from the . /// /// The configuration to read the setting from. /// Whether WAL journaling disabled. public static bool GetSqliteWalDisabled(this IConfiguration configuration) { var disableSqliteWal = configuration.GetValue(SqliteDisableWalKey); var disableWal = false; if (disableSqliteWal is not null) { disableWal = disableSqliteWal.ToUpperInvariant() switch { "FALSE" or "NO" or "0" => false, _ => true }; } return disableWal; } } }