jellyfin/MediaBrowser.Controller/BaseItemManager/BaseItemManager.cs

74 lines
2.6 KiB
C#
Raw Permalink Normal View History

using System;
using Jellyfin.Extensions;
2020-10-27 23:57:52 +00:00
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
2023-06-22 03:01:47 +00:00
using MediaBrowser.Controller.Library;
2020-10-27 23:57:52 +00:00
using MediaBrowser.Model.Configuration;
namespace MediaBrowser.Controller.BaseItemManager
{
/// <inheritdoc />
public class BaseItemManager : IBaseItemManager
{
private readonly IServerConfigurationManager _serverConfigurationManager;
/// <summary>
/// Initializes a new instance of the <see cref="BaseItemManager"/> class.
/// </summary>
/// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
public BaseItemManager(IServerConfigurationManager serverConfigurationManager)
{
_serverConfigurationManager = serverConfigurationManager;
}
/// <inheritdoc />
public bool IsMetadataFetcherEnabled(BaseItem baseItem, TypeOptions? libraryTypeOptions, string name)
2020-10-27 23:57:52 +00:00
{
if (baseItem is Channel)
{
// Hack alert.
2020-10-27 23:57:52 +00:00
return true;
}
if (baseItem.SourceType == SourceType.Channel)
{
// Hack alert.
2020-10-27 23:57:52 +00:00
return !baseItem.EnableMediaSourceDisplay;
}
2022-12-05 14:01:13 +00:00
if (libraryTypeOptions is not null)
2020-10-27 23:57:52 +00:00
{
2023-06-22 03:01:47 +00:00
return libraryTypeOptions.MetadataFetchers.Contains(name, StringComparison.OrdinalIgnoreCase);
2020-10-27 23:57:52 +00:00
}
2023-06-22 03:01:47 +00:00
var itemConfig = _serverConfigurationManager.GetMetadataOptionsForType(baseItem.GetType().Name);
return itemConfig is null || !itemConfig.DisabledMetadataFetchers.Contains(name, StringComparison.OrdinalIgnoreCase);
2020-10-27 23:57:52 +00:00
}
/// <inheritdoc />
public bool IsImageFetcherEnabled(BaseItem baseItem, TypeOptions? libraryTypeOptions, string name)
2020-10-27 23:57:52 +00:00
{
if (baseItem is Channel)
{
// Hack alert.
2020-10-27 23:57:52 +00:00
return true;
}
if (baseItem.SourceType == SourceType.Channel)
{
// Hack alert.
2020-10-27 23:57:52 +00:00
return !baseItem.EnableMediaSourceDisplay;
}
2022-12-05 14:01:13 +00:00
if (libraryTypeOptions is not null)
2020-10-27 23:57:52 +00:00
{
2023-06-22 03:01:47 +00:00
return libraryTypeOptions.ImageFetchers.Contains(name, StringComparison.OrdinalIgnoreCase);
2020-12-03 07:07:51 +00:00
}
2023-06-22 03:01:47 +00:00
var itemConfig = _serverConfigurationManager.GetMetadataOptionsForType(baseItem.GetType().Name);
return itemConfig is null || !itemConfig.DisabledImageFetchers.Contains(name, StringComparison.OrdinalIgnoreCase);
2020-12-03 07:07:51 +00:00
}
2020-10-27 23:57:52 +00:00
}
}