using System;
using System.Collections.Generic;
using System.Threading;
using MediaBrowser.Controller.Entities;
namespace MediaBrowser.Controller.Library;
///
/// Provides similar item references from remote/external sources.
/// Returns lightweight references with ProviderIds that the manager resolves to library items.
///
public interface IRemoteSimilarItemsProvider : ISimilarItemsProvider
{
///
/// Determines whether the provider can handle items of the specified type.
///
/// The item type.
/// true if the provider handles this item type; otherwise false.
bool Supports(Type itemType);
///
/// Gets similar item references from an external source as an async stream.
///
/// The source item to find similar items for.
/// The query options (user, limit, exclusions).
/// Cancellation token.
/// An async enumerable of similar item references.
IAsyncEnumerable GetSimilarItemsAsync(
BaseItem item,
SimilarItemsQuery query,
CancellationToken cancellationToken);
}
///
/// 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.
///
/// The type of item this provider handles.
public interface IRemoteSimilarItemsProvider : IRemoteSimilarItemsProvider
where TItemType : BaseItem
{
///
/// Gets similar item references from an external source as an async stream.
///
/// The source item to find similar items for.
/// The query options (user, limit, exclusions).
/// Cancellation token.
/// An async enumerable of similar item references.
IAsyncEnumerable GetSimilarItemsAsync(
TItemType item,
SimilarItemsQuery query,
CancellationToken cancellationToken);
bool IRemoteSimilarItemsProvider.Supports(Type itemType)
=> typeof(TItemType).IsAssignableFrom(itemType);
IAsyncEnumerable IRemoteSimilarItemsProvider.GetSimilarItemsAsync(
BaseItem item,
SimilarItemsQuery query,
CancellationToken cancellationToken)
=> GetSimilarItemsAsync((TItemType)item, query, cancellationToken);
}