Pass TypeOptions instead of full LibraryOptions
This commit is contained in:
parent
d5e2c2fb5e
commit
a7c009e2eb
|
@ -35,7 +35,7 @@ namespace MediaBrowser.Controller.BaseItemManager
|
||||||
public SemaphoreSlim MetadataRefreshThrottler { get; private set; }
|
public SemaphoreSlim MetadataRefreshThrottler { get; private set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool IsMetadataFetcherEnabled(BaseItem baseItem, LibraryOptions libraryOptions, string name)
|
public bool IsMetadataFetcherEnabled(BaseItem baseItem, TypeOptions? libraryTypeOptions, string name)
|
||||||
{
|
{
|
||||||
if (baseItem is Channel)
|
if (baseItem is Channel)
|
||||||
{
|
{
|
||||||
|
@ -49,10 +49,9 @@ namespace MediaBrowser.Controller.BaseItemManager
|
||||||
return !baseItem.EnableMediaSourceDisplay;
|
return !baseItem.EnableMediaSourceDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
var typeOptions = libraryOptions.GetTypeOptions(baseItem.GetType().Name);
|
if (libraryTypeOptions != null)
|
||||||
if (typeOptions != null)
|
|
||||||
{
|
{
|
||||||
return typeOptions.MetadataFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase);
|
return libraryTypeOptions.MetadataFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
var itemConfig = _serverConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, baseItem.GetType().Name, StringComparison.OrdinalIgnoreCase));
|
var itemConfig = _serverConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, baseItem.GetType().Name, StringComparison.OrdinalIgnoreCase));
|
||||||
|
@ -61,7 +60,7 @@ namespace MediaBrowser.Controller.BaseItemManager
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool IsImageFetcherEnabled(BaseItem baseItem, LibraryOptions libraryOptions, string name)
|
public bool IsImageFetcherEnabled(BaseItem baseItem, TypeOptions? libraryTypeOptions, string name)
|
||||||
{
|
{
|
||||||
if (baseItem is Channel)
|
if (baseItem is Channel)
|
||||||
{
|
{
|
||||||
|
@ -75,10 +74,9 @@ namespace MediaBrowser.Controller.BaseItemManager
|
||||||
return !baseItem.EnableMediaSourceDisplay;
|
return !baseItem.EnableMediaSourceDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
var typeOptions = libraryOptions.GetTypeOptions(baseItem.GetType().Name);
|
if (libraryTypeOptions != null)
|
||||||
if (typeOptions != null)
|
|
||||||
{
|
{
|
||||||
return typeOptions.ImageFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase);
|
return libraryTypeOptions.ImageFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
var itemConfig = _serverConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, baseItem.GetType().Name, StringComparison.OrdinalIgnoreCase));
|
var itemConfig = _serverConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, baseItem.GetType().Name, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
|
@ -18,18 +18,18 @@ namespace MediaBrowser.Controller.BaseItemManager
|
||||||
/// Is metadata fetcher enabled.
|
/// Is metadata fetcher enabled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="baseItem">The base item.</param>
|
/// <param name="baseItem">The base item.</param>
|
||||||
/// <param name="libraryOptions">The library options.</param>
|
/// <param name="libraryTypeOptions">The type options for <c>baseItem</c> from the library (if defined).</param>
|
||||||
/// <param name="name">The metadata fetcher name.</param>
|
/// <param name="name">The metadata fetcher name.</param>
|
||||||
/// <returns><c>true</c> if metadata fetcher is enabled, else false.</returns>
|
/// <returns><c>true</c> if metadata fetcher is enabled, else false.</returns>
|
||||||
bool IsMetadataFetcherEnabled(BaseItem baseItem, LibraryOptions libraryOptions, string name);
|
bool IsMetadataFetcherEnabled(BaseItem baseItem, TypeOptions? libraryTypeOptions, string name);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Is image fetcher enabled.
|
/// Is image fetcher enabled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="baseItem">The base item.</param>
|
/// <param name="baseItem">The base item.</param>
|
||||||
/// <param name="libraryOptions">The library options.</param>
|
/// <param name="libraryTypeOptions">The type options for <c>baseItem</c> from the library (if defined).</param>
|
||||||
/// <param name="name">The image fetcher name.</param>
|
/// <param name="name">The image fetcher name.</param>
|
||||||
/// <returns><c>true</c> if image fetcher is enabled, else false.</returns>
|
/// <returns><c>true</c> if image fetcher is enabled, else false.</returns>
|
||||||
bool IsImageFetcherEnabled(BaseItem baseItem, LibraryOptions libraryOptions, string name);
|
bool IsImageFetcherEnabled(BaseItem baseItem, TypeOptions? libraryTypeOptions, string name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,7 +321,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
var typeOptions = libraryOptions.GetTypeOptions(item.GetType().Name);
|
var typeOptions = libraryOptions.GetTypeOptions(item.GetType().Name);
|
||||||
var fetcherOrder = typeOptions?.ImageFetcherOrder ?? options.ImageFetcherOrder;
|
var fetcherOrder = typeOptions?.ImageFetcherOrder ?? options.ImageFetcherOrder;
|
||||||
|
|
||||||
return _imageProviders.Where(i => CanRefreshImages(i, item, libraryOptions, refreshOptions, includeDisabled))
|
return _imageProviders.Where(i => CanRefreshImages(i, item, typeOptions, refreshOptions, includeDisabled))
|
||||||
.OrderBy(i => GetConfiguredOrder(fetcherOrder, i.Name))
|
.OrderBy(i => GetConfiguredOrder(fetcherOrder, i.Name))
|
||||||
.ThenBy(GetDefaultOrder);
|
.ThenBy(GetDefaultOrder);
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
var metadataFetcherOrder = typeOptions?.MetadataFetcherOrder ?? globalMetadataOptions.MetadataFetcherOrder;
|
var metadataFetcherOrder = typeOptions?.MetadataFetcherOrder ?? globalMetadataOptions.MetadataFetcherOrder;
|
||||||
|
|
||||||
return _metadataProviders.OfType<IMetadataProvider<T>>()
|
return _metadataProviders.OfType<IMetadataProvider<T>>()
|
||||||
.Where(i => CanRefreshMetadata(i, item, libraryOptions, includeDisabled, forceEnableInternetMetadata))
|
.Where(i => CanRefreshMetadata(i, item, typeOptions, includeDisabled, forceEnableInternetMetadata))
|
||||||
.OrderBy(i =>
|
.OrderBy(i =>
|
||||||
{
|
{
|
||||||
// local and remote providers will be interleaved in the final order
|
// local and remote providers will be interleaved in the final order
|
||||||
|
@ -361,7 +361,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
private bool CanRefreshMetadata(
|
private bool CanRefreshMetadata(
|
||||||
IMetadataProvider provider,
|
IMetadataProvider provider,
|
||||||
BaseItem item,
|
BaseItem item,
|
||||||
LibraryOptions libraryOptions,
|
TypeOptions? libraryTypeOptions,
|
||||||
bool includeDisabled,
|
bool includeDisabled,
|
||||||
bool forceEnableInternetMetadata)
|
bool forceEnableInternetMetadata)
|
||||||
{
|
{
|
||||||
|
@ -375,7 +375,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
|
|
||||||
if (provider is IRemoteMetadataProvider)
|
if (provider is IRemoteMetadataProvider)
|
||||||
{
|
{
|
||||||
if (!forceEnableInternetMetadata && !_baseItemManager.IsMetadataFetcherEnabled(item, libraryOptions, provider.Name))
|
if (!forceEnableInternetMetadata && !_baseItemManager.IsMetadataFetcherEnabled(item, libraryTypeOptions, provider.Name))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -402,7 +402,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
private bool CanRefreshImages(
|
private bool CanRefreshImages(
|
||||||
IImageProvider provider,
|
IImageProvider provider,
|
||||||
BaseItem item,
|
BaseItem item,
|
||||||
LibraryOptions libraryOptions,
|
TypeOptions? libraryTypeOptions,
|
||||||
ImageRefreshOptions refreshOptions,
|
ImageRefreshOptions refreshOptions,
|
||||||
bool includeDisabled)
|
bool includeDisabled)
|
||||||
{
|
{
|
||||||
|
@ -419,7 +419,7 @@ namespace MediaBrowser.Providers.Manager
|
||||||
|
|
||||||
if (provider is IRemoteImageProvider || provider is IDynamicImageProvider)
|
if (provider is IRemoteImageProvider || provider is IDynamicImageProvider)
|
||||||
{
|
{
|
||||||
if (!_baseItemManager.IsImageFetcherEnabled(item, libraryOptions, provider.Name))
|
if (!_baseItemManager.IsImageFetcherEnabled(item, libraryTypeOptions, provider.Name))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,17 +20,13 @@ namespace Jellyfin.Controller.Tests
|
||||||
{
|
{
|
||||||
BaseItem item = (BaseItem)Activator.CreateInstance(itemType)!;
|
BaseItem item = (BaseItem)Activator.CreateInstance(itemType)!;
|
||||||
|
|
||||||
var libraryOptions = new LibraryOptions
|
var libraryTypeOptions = itemType == typeof(Book)
|
||||||
{
|
? new TypeOptions
|
||||||
TypeOptions = new[]
|
|
||||||
{
|
{
|
||||||
new TypeOptions
|
Type = "Book",
|
||||||
{
|
MetadataFetchers = new[] { "LibraryEnabled" }
|
||||||
Type = "Book",
|
|
||||||
MetadataFetchers = new[] { "LibraryEnabled" }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
: null;
|
||||||
|
|
||||||
var serverConfiguration = new ServerConfiguration();
|
var serverConfiguration = new ServerConfiguration();
|
||||||
foreach (var typeConfig in serverConfiguration.MetadataOptions)
|
foreach (var typeConfig in serverConfiguration.MetadataOptions)
|
||||||
|
@ -43,7 +39,7 @@ namespace Jellyfin.Controller.Tests
|
||||||
.Returns(serverConfiguration);
|
.Returns(serverConfiguration);
|
||||||
|
|
||||||
var baseItemManager = new BaseItemManager(serverConfigurationManager.Object);
|
var baseItemManager = new BaseItemManager(serverConfigurationManager.Object);
|
||||||
var actual = baseItemManager.IsMetadataFetcherEnabled(item, libraryOptions, fetcherName);
|
var actual = baseItemManager.IsMetadataFetcherEnabled(item, libraryTypeOptions, fetcherName);
|
||||||
|
|
||||||
Assert.Equal(expected, actual);
|
Assert.Equal(expected, actual);
|
||||||
}
|
}
|
||||||
|
@ -57,17 +53,13 @@ namespace Jellyfin.Controller.Tests
|
||||||
{
|
{
|
||||||
BaseItem item = (BaseItem)Activator.CreateInstance(itemType)!;
|
BaseItem item = (BaseItem)Activator.CreateInstance(itemType)!;
|
||||||
|
|
||||||
var libraryOptions = new LibraryOptions
|
var libraryTypeOptions = itemType == typeof(Book)
|
||||||
{
|
? new TypeOptions
|
||||||
TypeOptions = new[]
|
|
||||||
{
|
{
|
||||||
new TypeOptions
|
Type = "Book",
|
||||||
{
|
ImageFetchers = new[] { "LibraryEnabled" }
|
||||||
Type = "Book",
|
|
||||||
ImageFetchers = new[] { "LibraryEnabled" }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
: null;
|
||||||
|
|
||||||
var serverConfiguration = new ServerConfiguration();
|
var serverConfiguration = new ServerConfiguration();
|
||||||
foreach (var typeConfig in serverConfiguration.MetadataOptions)
|
foreach (var typeConfig in serverConfiguration.MetadataOptions)
|
||||||
|
@ -80,7 +72,7 @@ namespace Jellyfin.Controller.Tests
|
||||||
.Returns(serverConfiguration);
|
.Returns(serverConfiguration);
|
||||||
|
|
||||||
var baseItemManager = new BaseItemManager(serverConfigurationManager.Object);
|
var baseItemManager = new BaseItemManager(serverConfigurationManager.Object);
|
||||||
var actual = baseItemManager.IsImageFetcherEnabled(item, libraryOptions, fetcherName);
|
var actual = baseItemManager.IsImageFetcherEnabled(item, libraryTypeOptions, fetcherName);
|
||||||
|
|
||||||
Assert.Equal(expected, actual);
|
Assert.Equal(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ namespace Jellyfin.Providers.Tests.Manager
|
||||||
};
|
};
|
||||||
|
|
||||||
var baseItemManager = new Mock<IBaseItemManager>(MockBehavior.Strict);
|
var baseItemManager = new Mock<IBaseItemManager>(MockBehavior.Strict);
|
||||||
baseItemManager.Setup(i => i.IsImageFetcherEnabled(item, It.IsAny<LibraryOptions>(), providerName))
|
baseItemManager.Setup(i => i.IsImageFetcherEnabled(item, It.IsAny<TypeOptions>(), providerName))
|
||||||
.Returns(baseItemEnabled);
|
.Returns(baseItemEnabled);
|
||||||
|
|
||||||
using var providerManager = GetProviderManager(baseItemManager: baseItemManager.Object);
|
using var providerManager = GetProviderManager(baseItemManager: baseItemManager.Object);
|
||||||
|
@ -219,7 +219,7 @@ namespace Jellyfin.Providers.Tests.Manager
|
||||||
metadataFetcherOrder: serverRemoteOrder?.Select(nameProvider).ToArray());
|
metadataFetcherOrder: serverRemoteOrder?.Select(nameProvider).ToArray());
|
||||||
|
|
||||||
var baseItemManager = new Mock<IBaseItemManager>(MockBehavior.Strict);
|
var baseItemManager = new Mock<IBaseItemManager>(MockBehavior.Strict);
|
||||||
baseItemManager.Setup(i => i.IsMetadataFetcherEnabled(item, It.IsAny<LibraryOptions>(), It.IsAny<string>()))
|
baseItemManager.Setup(i => i.IsMetadataFetcherEnabled(item, It.IsAny<TypeOptions>(), It.IsAny<string>()))
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
|
|
||||||
using var providerManager = GetProviderManager(serverConfiguration: serverConfiguration, baseItemManager: baseItemManager.Object);
|
using var providerManager = GetProviderManager(serverConfiguration: serverConfiguration, baseItemManager: baseItemManager.Object);
|
||||||
|
@ -302,7 +302,7 @@ namespace Jellyfin.Providers.Tests.Manager
|
||||||
var provider = MockIMetadataProviderMapper<MetadataTestItem, MetadataTestItemInfo>(providerType.Name, providerName, forced: providerForced);
|
var provider = MockIMetadataProviderMapper<MetadataTestItem, MetadataTestItemInfo>(providerType.Name, providerName, forced: providerForced);
|
||||||
|
|
||||||
var baseItemManager = new Mock<IBaseItemManager>(MockBehavior.Strict);
|
var baseItemManager = new Mock<IBaseItemManager>(MockBehavior.Strict);
|
||||||
baseItemManager.Setup(i => i.IsMetadataFetcherEnabled(item, It.IsAny<LibraryOptions>(), providerName))
|
baseItemManager.Setup(i => i.IsMetadataFetcherEnabled(item, It.IsAny<TypeOptions>(), providerName))
|
||||||
.Returns(baseItemEnabled);
|
.Returns(baseItemEnabled);
|
||||||
|
|
||||||
using var providerManager = GetProviderManager(baseItemManager: baseItemManager.Object);
|
using var providerManager = GetProviderManager(baseItemManager: baseItemManager.Object);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user