2020-12-02 19:51:53 -07:00
|
|
|
using System;
|
2021-06-19 09:02:33 -07:00
|
|
|
using Jellyfin.Extensions;
|
2020-10-27 16:57:52 -07:00
|
|
|
using MediaBrowser.Controller.Channels;
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
|
|
|
using MediaBrowser.Controller.Entities;
|
2023-06-21 20:01:47 -07:00
|
|
|
using MediaBrowser.Controller.Library;
|
2020-10-27 16:57:52 -07: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 />
|
2021-12-18 13:40:27 -07:00
|
|
|
public bool IsMetadataFetcherEnabled(BaseItem baseItem, TypeOptions? libraryTypeOptions, string name)
|
2020-10-27 16:57:52 -07:00
|
|
|
{
|
|
|
|
if (baseItem is Channel)
|
|
|
|
{
|
2020-11-08 06:42:54 -07:00
|
|
|
// Hack alert.
|
2020-10-27 16:57:52 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (baseItem.SourceType == SourceType.Channel)
|
|
|
|
{
|
2020-11-08 06:42:49 -07:00
|
|
|
// Hack alert.
|
2020-10-27 16:57:52 -07:00
|
|
|
return !baseItem.EnableMediaSourceDisplay;
|
|
|
|
}
|
|
|
|
|
2022-12-05 07:01:13 -07:00
|
|
|
if (libraryTypeOptions is not null)
|
2020-10-27 16:57:52 -07:00
|
|
|
{
|
2023-06-21 20:01:47 -07:00
|
|
|
return libraryTypeOptions.MetadataFetchers.Contains(name, StringComparison.OrdinalIgnoreCase);
|
2020-10-27 16:57:52 -07:00
|
|
|
}
|
|
|
|
|
2023-06-21 20:01:47 -07:00
|
|
|
var itemConfig = _serverConfigurationManager.GetMetadataOptionsForType(baseItem.GetType().Name);
|
|
|
|
return itemConfig is null || !itemConfig.DisabledMetadataFetchers.Contains(name, StringComparison.OrdinalIgnoreCase);
|
2020-10-27 16:57:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2021-12-18 13:40:27 -07:00
|
|
|
public bool IsImageFetcherEnabled(BaseItem baseItem, TypeOptions? libraryTypeOptions, string name)
|
2020-10-27 16:57:52 -07:00
|
|
|
{
|
|
|
|
if (baseItem is Channel)
|
|
|
|
{
|
2020-11-08 06:42:40 -07:00
|
|
|
// Hack alert.
|
2020-10-27 16:57:52 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (baseItem.SourceType == SourceType.Channel)
|
|
|
|
{
|
2020-11-08 06:42:33 -07:00
|
|
|
// Hack alert.
|
2020-10-27 16:57:52 -07:00
|
|
|
return !baseItem.EnableMediaSourceDisplay;
|
|
|
|
}
|
|
|
|
|
2022-12-05 07:01:13 -07:00
|
|
|
if (libraryTypeOptions is not null)
|
2020-10-27 16:57:52 -07:00
|
|
|
{
|
2023-06-21 20:01:47 -07:00
|
|
|
return libraryTypeOptions.ImageFetchers.Contains(name, StringComparison.OrdinalIgnoreCase);
|
2020-12-03 00:07:51 -07:00
|
|
|
}
|
|
|
|
|
2023-06-21 20:01:47 -07:00
|
|
|
var itemConfig = _serverConfigurationManager.GetMetadataOptionsForType(baseItem.GetType().Name);
|
|
|
|
return itemConfig is null || !itemConfig.DisabledImageFetchers.Contains(name, StringComparison.OrdinalIgnoreCase);
|
2020-12-03 00:07:51 -07:00
|
|
|
}
|
2020-10-27 16:57:52 -07:00
|
|
|
}
|
2020-11-08 06:42:33 -07:00
|
|
|
}
|