MetadataOptions.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using MediaBrowser.Model.Entities;
  2. using MediaBrowser.Model.Extensions;
  3. using System.Collections.Generic;
  4. namespace MediaBrowser.Model.Configuration
  5. {
  6. /// <summary>
  7. /// Class MetadataOptions.
  8. /// </summary>
  9. public class MetadataOptions
  10. {
  11. public string ItemType { get; set; }
  12. public ImageOption[] ImageOptions { get; set; }
  13. public string[] DisabledMetadataSavers { get; set; }
  14. public string[] LocalMetadataReaderOrder { get; set; }
  15. public string[] DisabledMetadataFetchers { get; set; }
  16. public string[] MetadataFetcherOrder { get; set; }
  17. public string[] DisabledImageFetchers { get; set; }
  18. public string[] ImageFetcherOrder { get; set; }
  19. public MetadataOptions()
  20. : this(3, 1280)
  21. {
  22. }
  23. public MetadataOptions(int backdropLimit, int minBackdropWidth)
  24. {
  25. ImageOptions = new[]
  26. {
  27. new ImageOption
  28. {
  29. Limit = backdropLimit,
  30. MinWidth = minBackdropWidth,
  31. Type = ImageType.Backdrop
  32. }
  33. };
  34. DisabledMetadataSavers = new string[] { };
  35. LocalMetadataReaderOrder = new string[] { };
  36. DisabledMetadataFetchers = new string[] { };
  37. MetadataFetcherOrder = new string[] { };
  38. DisabledImageFetchers = new string[] { };
  39. ImageFetcherOrder = new string[] { };
  40. }
  41. public int GetLimit(ImageType type)
  42. {
  43. ImageOption option = null;
  44. foreach (ImageOption i in ImageOptions)
  45. {
  46. if (i.Type == type)
  47. {
  48. option = i;
  49. break;
  50. }
  51. }
  52. return option == null ? 1 : option.Limit;
  53. }
  54. public int GetMinWidth(ImageType type)
  55. {
  56. ImageOption option = null;
  57. foreach (ImageOption i in ImageOptions)
  58. {
  59. if (i.Type == type)
  60. {
  61. option = i;
  62. break;
  63. }
  64. }
  65. return option == null ? 0 : option.MinWidth;
  66. }
  67. public bool IsEnabled(ImageType type)
  68. {
  69. return GetLimit(type) > 0;
  70. }
  71. public bool IsMetadataSaverEnabled(string name)
  72. {
  73. return !ListHelper.ContainsIgnoreCase(DisabledMetadataSavers, name);
  74. }
  75. }
  76. }