Skip to content

Commit

Permalink
Fix metadata saver check
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadowghost committed Jun 4, 2024
1 parent 4714b3a commit 262f7dd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
8 changes: 8 additions & 0 deletions MediaBrowser.Controller/Providers/IProviderManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ void AddParts(
IEnumerable<IMetadataProvider<T>> GetMetadataProviders<T>(BaseItem item, LibraryOptions libraryOptions)
where T : BaseItem;

/// <summary>
/// Gets the metadata savers for the provided item.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="libraryOptions">The library options.</param>
/// <returns>The metadata providers.</returns>
IEnumerable<IMetadataSaver> GetMetadataSavers(BaseItem item, LibraryOptions libraryOptions);

/// <summary>
/// Gets all metadata plugins.
/// </summary>
Expand Down
8 changes: 5 additions & 3 deletions MediaBrowser.Providers/Manager/MetadataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ public virtual async Task<ItemUpdateType> RefreshMetadata(BaseItem item, Metadat

id.IsAutomated = refreshOptions.IsAutomated;

var result = await RefreshWithProviders(metadataResult, id, refreshOptions, providers, ImageProvider, cancellationToken).ConfigureAwait(false);
var hasMetadataSavers = ProviderManager.GetMetadataSavers(item, libraryOptions).Any();
var result = await RefreshWithProviders(metadataResult, id, refreshOptions, providers, ImageProvider, hasMetadataSavers, cancellationToken).ConfigureAwait(false);

updateType |= result.UpdateType;
if (result.Failures > 0)
Expand Down Expand Up @@ -639,6 +640,7 @@ protected virtual async Task<RefreshResult> RefreshWithProviders(
MetadataRefreshOptions options,
ICollection<IMetadataProvider> providers,
ItemImageProvider imageService,
bool isSavingMetadata,
CancellationToken cancellationToken)
{
var refreshResult = new RefreshResult
Expand Down Expand Up @@ -670,8 +672,8 @@ protected virtual async Task<RefreshResult> RefreshWithProviders(

var foundImageTypes = new List<ImageType>();

// Do not execute local providers if we are identifying or replacing with NFO saving enabled
if (options.SearchResult is null && !(item.IsSaveLocalMetadataEnabled() && options.ReplaceAllMetadata))
// Do not execute local providers if we are identifying or replacing with local metadata saving enabled
if (options.SearchResult is null && !(isSavingMetadata && options.ReplaceAllMetadata))
{
foreach (var provider in providers.OfType<ILocalMetadataProvider<TItemType>>())
{
Expand Down
6 changes: 6 additions & 0 deletions MediaBrowser.Providers/Manager/ProviderManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,12 @@ public IEnumerable<IMetadataProvider<T>> GetMetadataProviders<T>(BaseItem item,
return GetMetadataProvidersInternal<T>(item, libraryOptions, globalMetadataOptions, false, false);
}

/// <inheritdoc />
public IEnumerable<IMetadataSaver> GetMetadataSavers(BaseItem item, LibraryOptions libraryOptions)
{
return _savers.Where(i => IsSaverEnabledForItem(i, item, libraryOptions, ItemUpdateType.MetadataEdit, false));
}

private IEnumerable<IMetadataProvider<T>> GetMetadataProvidersInternal<T>(BaseItem item, LibraryOptions libraryOptions, MetadataOptions globalMetadataOptions, bool includeDisabled, bool forceEnableInternetMetadata)
where T : BaseItem
{
Expand Down

0 comments on commit 262f7dd

Please sign in to comment.