aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Library
diff options
context:
space:
mode:
authorShadowghost <Ghost_of_Stone@web.de>2026-05-13 00:58:03 +0200
committerShadowghost <Ghost_of_Stone@web.de>2026-05-13 00:58:33 +0200
commitb1b45199444e369b12844661f09d1cd0830d25f7 (patch)
tree8c49e54b9f07f30bfafe4f1268edacbe33811827 /MediaBrowser.Controller/Library
parent4ebce3907062ade1937440628eebd665440b338d (diff)
Apply review suggestions
Diffstat (limited to 'MediaBrowser.Controller/Library')
-rw-r--r--MediaBrowser.Controller/Library/ILocalSimilarItemsProvider.cs38
-rw-r--r--MediaBrowser.Controller/Library/IRemoteSimilarItemsProvider.cs38
2 files changed, 74 insertions, 2 deletions
diff --git a/MediaBrowser.Controller/Library/ILocalSimilarItemsProvider.cs b/MediaBrowser.Controller/Library/ILocalSimilarItemsProvider.cs
index 9bf0121f5f..b8e41ec810 100644
--- a/MediaBrowser.Controller/Library/ILocalSimilarItemsProvider.cs
+++ b/MediaBrowser.Controller/Library/ILocalSimilarItemsProvider.cs
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
@@ -6,11 +7,37 @@ using MediaBrowser.Controller.Entities;
namespace MediaBrowser.Controller.Library;
/// <summary>
+/// Provides similar items from the local library.
+/// Returns fully resolved BaseItems directly - no additional resolution needed.
+/// </summary>
+public interface ILocalSimilarItemsProvider : ISimilarItemsProvider
+{
+ /// <summary>
+ /// Determines whether the provider can handle items of the specified type.
+ /// </summary>
+ /// <param name="itemType">The item type.</param>
+ /// <returns><c>true</c> if the provider handles this item type; otherwise <c>false</c>.</returns>
+ bool Supports(Type itemType);
+
+ /// <summary>
+ /// Gets similar items from the local library.
+ /// </summary>
+ /// <param name="item">The source item to find similar items for.</param>
+ /// <param name="query">The query options (user, limit, exclusions, etc.).</param>
+ /// <param name="cancellationToken">Cancellation token.</param>
+ /// <returns>The list of similar items from the library.</returns>
+ Task<IReadOnlyList<BaseItem>> GetSimilarItemsAsync(
+ BaseItem item,
+ SimilarItemsQuery query,
+ CancellationToken cancellationToken);
+}
+
+/// <summary>
/// Provides similar items from the local library for a specific item type.
/// Returns fully resolved BaseItems directly - no additional resolution needed.
/// </summary>
/// <typeparam name="TItemType">The type of item this provider handles.</typeparam>
-public interface ILocalSimilarItemsProvider<TItemType> : ISimilarItemsProvider
+public interface ILocalSimilarItemsProvider<TItemType> : ILocalSimilarItemsProvider
where TItemType : BaseItem
{
/// <summary>
@@ -24,4 +51,13 @@ public interface ILocalSimilarItemsProvider<TItemType> : ISimilarItemsProvider
TItemType item,
SimilarItemsQuery query,
CancellationToken cancellationToken);
+
+ bool ILocalSimilarItemsProvider.Supports(Type itemType)
+ => typeof(TItemType).IsAssignableFrom(itemType);
+
+ Task<IReadOnlyList<BaseItem>> ILocalSimilarItemsProvider.GetSimilarItemsAsync(
+ BaseItem item,
+ SimilarItemsQuery query,
+ CancellationToken cancellationToken)
+ => GetSimilarItemsAsync((TItemType)item, query, cancellationToken);
}
diff --git a/MediaBrowser.Controller/Library/IRemoteSimilarItemsProvider.cs b/MediaBrowser.Controller/Library/IRemoteSimilarItemsProvider.cs
index a77b6628d9..3803e51769 100644
--- a/MediaBrowser.Controller/Library/IRemoteSimilarItemsProvider.cs
+++ b/MediaBrowser.Controller/Library/IRemoteSimilarItemsProvider.cs
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
using System.Threading;
using MediaBrowser.Controller.Entities;
@@ -5,11 +6,37 @@ using MediaBrowser.Controller.Entities;
namespace MediaBrowser.Controller.Library;
/// <summary>
+/// Provides similar item references from remote/external sources.
+/// Returns lightweight references with ProviderIds that the manager resolves to library items.
+/// </summary>
+public interface IRemoteSimilarItemsProvider : ISimilarItemsProvider
+{
+ /// <summary>
+ /// Determines whether the provider can handle items of the specified type.
+ /// </summary>
+ /// <param name="itemType">The item type.</param>
+ /// <returns><c>true</c> if the provider handles this item type; otherwise <c>false</c>.</returns>
+ bool Supports(Type itemType);
+
+ /// <summary>
+ /// Gets similar item references from an external source as an async stream.
+ /// </summary>
+ /// <param name="item">The source item to find similar items for.</param>
+ /// <param name="query">The query options (user, limit, exclusions).</param>
+ /// <param name="cancellationToken">Cancellation token.</param>
+ /// <returns>An async enumerable of similar item references.</returns>
+ IAsyncEnumerable<SimilarItemReference> GetSimilarItemsAsync(
+ BaseItem item,
+ SimilarItemsQuery query,
+ CancellationToken cancellationToken);
+}
+
+/// <summary>
/// Provides similar item references from remote/external sources for a specific item type.
/// Returns lightweight references with ProviderIds that the manager resolves to library items.
/// </summary>
/// <typeparam name="TItemType">The type of item this provider handles.</typeparam>
-public interface IRemoteSimilarItemsProvider<TItemType> : ISimilarItemsProvider
+public interface IRemoteSimilarItemsProvider<TItemType> : IRemoteSimilarItemsProvider
where TItemType : BaseItem
{
/// <summary>
@@ -23,4 +50,13 @@ public interface IRemoteSimilarItemsProvider<TItemType> : ISimilarItemsProvider
TItemType item,
SimilarItemsQuery query,
CancellationToken cancellationToken);
+
+ bool IRemoteSimilarItemsProvider.Supports(Type itemType)
+ => typeof(TItemType).IsAssignableFrom(itemType);
+
+ IAsyncEnumerable<SimilarItemReference> IRemoteSimilarItemsProvider.GetSimilarItemsAsync(
+ BaseItem item,
+ SimilarItemsQuery query,
+ CancellationToken cancellationToken)
+ => GetSimilarItemsAsync((TItemType)item, query, cancellationToken);
}