| | | 1 | | using System; |
| | | 2 | | using Jellyfin.Extensions; |
| | | 3 | | using MediaBrowser.Controller.Channels; |
| | | 4 | | using MediaBrowser.Controller.Configuration; |
| | | 5 | | using MediaBrowser.Controller.Entities; |
| | | 6 | | using MediaBrowser.Controller.Library; |
| | | 7 | | using MediaBrowser.Model.Configuration; |
| | | 8 | | |
| | | 9 | | namespace MediaBrowser.Controller.BaseItemManager |
| | | 10 | | { |
| | | 11 | | /// <inheritdoc /> |
| | | 12 | | public class BaseItemManager : IBaseItemManager |
| | | 13 | | { |
| | | 14 | | private readonly IServerConfigurationManager _serverConfigurationManager; |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Initializes a new instance of the <see cref="BaseItemManager"/> class. |
| | | 18 | | /// </summary> |
| | | 19 | | /// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface |
| | | 20 | | public BaseItemManager(IServerConfigurationManager serverConfigurationManager) |
| | | 21 | | { |
| | 29 | 22 | | _serverConfigurationManager = serverConfigurationManager; |
| | 29 | 23 | | } |
| | | 24 | | |
| | | 25 | | /// <inheritdoc /> |
| | | 26 | | public bool IsMetadataFetcherEnabled(BaseItem baseItem, TypeOptions? libraryTypeOptions, string name) |
| | | 27 | | { |
| | 4 | 28 | | if (baseItem is Channel) |
| | | 29 | | { |
| | | 30 | | // Hack alert. |
| | 0 | 31 | | return true; |
| | | 32 | | } |
| | | 33 | | |
| | 4 | 34 | | if (baseItem.SourceType == SourceType.Channel) |
| | | 35 | | { |
| | | 36 | | // Hack alert. |
| | 0 | 37 | | return !baseItem.EnableMediaSourceDisplay; |
| | | 38 | | } |
| | | 39 | | |
| | 4 | 40 | | if (libraryTypeOptions is not null) |
| | | 41 | | { |
| | 2 | 42 | | return libraryTypeOptions.MetadataFetchers.Contains(name, StringComparison.OrdinalIgnoreCase); |
| | | 43 | | } |
| | | 44 | | |
| | 2 | 45 | | var itemConfig = _serverConfigurationManager.GetMetadataOptionsForType(baseItem.GetType().Name); |
| | 2 | 46 | | return itemConfig is null || !itemConfig.DisabledMetadataFetchers.Contains(name, StringComparison.OrdinalIgn |
| | | 47 | | } |
| | | 48 | | |
| | | 49 | | /// <inheritdoc /> |
| | | 50 | | public bool IsImageFetcherEnabled(BaseItem baseItem, TypeOptions? libraryTypeOptions, string name) |
| | | 51 | | { |
| | 4 | 52 | | if (baseItem is Channel) |
| | | 53 | | { |
| | | 54 | | // Hack alert. |
| | 0 | 55 | | return true; |
| | | 56 | | } |
| | | 57 | | |
| | 4 | 58 | | if (baseItem.SourceType == SourceType.Channel) |
| | | 59 | | { |
| | | 60 | | // Hack alert. |
| | 0 | 61 | | return !baseItem.EnableMediaSourceDisplay; |
| | | 62 | | } |
| | | 63 | | |
| | 4 | 64 | | if (libraryTypeOptions is not null) |
| | | 65 | | { |
| | 2 | 66 | | return libraryTypeOptions.ImageFetchers.Contains(name, StringComparison.OrdinalIgnoreCase); |
| | | 67 | | } |
| | | 68 | | |
| | 2 | 69 | | var itemConfig = _serverConfigurationManager.GetMetadataOptionsForType(baseItem.GetType().Name); |
| | 2 | 70 | | return itemConfig is null || !itemConfig.DisabledImageFetchers.Contains(name, StringComparison.OrdinalIgnore |
| | | 71 | | } |
| | | 72 | | } |
| | | 73 | | } |