ConfigurationExtensions.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using Microsoft.Extensions.Configuration;
  2. namespace MediaBrowser.Controller.Extensions
  3. {
  4. /// <summary>
  5. /// Configuration extensions for <c>MediaBrowser.Controller</c>.
  6. /// </summary>
  7. public static class ConfigurationExtensions
  8. {
  9. /// <summary>
  10. /// The key for the FFmpeg probe size option.
  11. /// </summary>
  12. public const string FfmpegProbeSizeKey = "FFmpeg:probesize";
  13. /// <summary>
  14. /// The key for the FFmpeg analyze duration option.
  15. /// </summary>
  16. public const string FfmpegAnalyzeDurationKey = "FFmpeg:analyzeduration";
  17. /// <summary>
  18. /// The key for a setting that indicates whether playlists should allow duplicate entries.
  19. /// </summary>
  20. public const string PlaylistsAllowDuplicatesKey = "playlists:allowDuplicates";
  21. /// <summary>
  22. /// Gets the FFmpeg probe size from the <see cref="IConfiguration" />.
  23. /// </summary>
  24. /// <param name="configuration">The configuration to read the setting from.</param>
  25. /// <returns>The FFmpeg probe size option.</returns>
  26. public static string GetFFmpegProbeSize(this IConfiguration configuration)
  27. => configuration[FfmpegProbeSizeKey];
  28. /// <summary>
  29. /// Gets the FFmpeg analyze duration from the <see cref="IConfiguration" />.
  30. /// </summary>
  31. /// <param name="configuration">The configuration to read the setting from.</param>
  32. /// <returns>The FFmpeg analyze duration option.</returns>
  33. public static string GetFFmpegAnalyzeDuration(this IConfiguration configuration)
  34. => configuration[FfmpegAnalyzeDurationKey];
  35. /// <summary>
  36. /// Gets a value indicating whether playlists should allow duplicate entries from the <see cref="IConfiguration"/>.
  37. /// </summary>
  38. /// <param name="configuration">The configuration to read the setting from.</param>
  39. /// <returns>True if playlists should allow duplicates, otherwise false.</returns>
  40. public static bool DoPlaylistsAllowDuplicates(this IConfiguration configuration)
  41. => configuration.GetValue<bool>(PlaylistsAllowDuplicatesKey);
  42. }
  43. }