MetadataOptions.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. List<ImageOption> imageOptions = new List<ImageOption>
  26. {
  27. new ImageOption
  28. {
  29. Limit = backdropLimit,
  30. MinWidth = minBackdropWidth,
  31. Type = ImageType.Backdrop
  32. }
  33. };
  34. ImageOptions = imageOptions.ToArray();
  35. DisabledMetadataSavers = new string[] { };
  36. LocalMetadataReaderOrder = new string[] { };
  37. DisabledMetadataFetchers = new string[] { };
  38. MetadataFetcherOrder = new string[] { };
  39. DisabledImageFetchers = new string[] { };
  40. ImageFetcherOrder = new string[] { };
  41. }
  42. public int GetLimit(ImageType type)
  43. {
  44. ImageOption option = null;
  45. foreach (ImageOption i in ImageOptions)
  46. {
  47. if (i.Type == type)
  48. {
  49. option = i;
  50. break;
  51. }
  52. }
  53. return option == null ? 1 : option.Limit;
  54. }
  55. public int GetMinWidth(ImageType type)
  56. {
  57. ImageOption option = null;
  58. foreach (ImageOption i in ImageOptions)
  59. {
  60. if (i.Type == type)
  61. {
  62. option = i;
  63. break;
  64. }
  65. }
  66. return option == null ? 0 : option.MinWidth;
  67. }
  68. public bool IsEnabled(ImageType type)
  69. {
  70. return GetLimit(type) > 0;
  71. }
  72. public bool IsMetadataSaverEnabled(string name)
  73. {
  74. return !ListHelper.ContainsIgnoreCase(DisabledMetadataSavers, name);
  75. }
  76. }
  77. }