MetadataOptions.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using MediaBrowser.Model.Entities;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace MediaBrowser.Model.Configuration
  6. {
  7. /// <summary>
  8. /// Class MetadataOptions.
  9. /// </summary>
  10. public class MetadataOptions
  11. {
  12. public string ItemType { get; set; }
  13. public ImageOption[] ImageOptions { get; set; }
  14. public string[] DisabledMetadataSavers { get; set; }
  15. public MetadataOptions()
  16. : this(3, 1280)
  17. {
  18. }
  19. public MetadataOptions(int backdropLimit, int minBackdropWidth)
  20. {
  21. var imageOptions = new List<ImageOption>
  22. {
  23. new ImageOption
  24. {
  25. Limit = backdropLimit,
  26. MinWidth = minBackdropWidth,
  27. Type = ImageType.Backdrop
  28. }
  29. };
  30. ImageOptions = imageOptions.ToArray();
  31. DisabledMetadataSavers = new string[] { };
  32. }
  33. public int GetLimit(ImageType type)
  34. {
  35. var option = ImageOptions.FirstOrDefault(i => i.Type == type);
  36. return option == null ? 1 : option.Limit;
  37. }
  38. public int GetMinWidth(ImageType type)
  39. {
  40. var option = ImageOptions.FirstOrDefault(i => i.Type == type);
  41. return option == null ? 0 : option.MinWidth;
  42. }
  43. public bool IsEnabled(ImageType type)
  44. {
  45. return GetLimit(type) > 0;
  46. }
  47. public bool IsMetadataSaverEnabled(string name)
  48. {
  49. return !DisabledMetadataSavers.Contains(name, StringComparer.OrdinalIgnoreCase);
  50. }
  51. }
  52. public class ImageOption
  53. {
  54. /// <summary>
  55. /// Gets or sets the type.
  56. /// </summary>
  57. /// <value>The type.</value>
  58. public ImageType Type { get; set; }
  59. /// <summary>
  60. /// Gets or sets the limit.
  61. /// </summary>
  62. /// <value>The limit.</value>
  63. public int Limit { get; set; }
  64. /// <summary>
  65. /// Gets or sets the minimum width.
  66. /// </summary>
  67. /// <value>The minimum width.</value>
  68. public int MinWidth { get; set; }
  69. public ImageOption()
  70. {
  71. Limit = 1;
  72. }
  73. }
  74. }