mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18:21:10 +00:00
Adds the media library artwork aggregation services, enrichers, and their provider contracts
This commit is contained in:
1 parent
00376c8313
commit
9e118864c3
33 files changed
+4621
-1118
No files matched your search
@@ -29,10 +29,10 @@ public interface IArtworkProvider
|
||||
bool RequiresWebAccess { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the artwork of the media item described by <paramref name="lookup"/>.
|
||||
/// Gets the artworks of the media item described by <paramref name="lookup"/>.
|
||||
/// </summary>
|
||||
/// <param name="lookup">The lookup describing the media item to get the artwork for.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The artwork of the media item, or <see langword="null"/> when no artwork was found.</returns>
|
||||
Task<ArtworkDto?> GetArtworkAsync(MetadataLookupDto lookup, CancellationToken cancellationToken);
|
||||
/// <returns>The artworks of the media item, or an empty collection when no artwork was found.</returns>
|
||||
Task<IReadOnlyList<ArtworkDto>> GetArtworkAsync(MetadataLookupDto lookup, CancellationToken cancellationToken);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
@@ -14,21 +15,21 @@ public interface IArtworkProvider<TLookup> : IArtworkProvider
|
||||
where TLookup : MetadataLookupDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the artwork of the media item described by <paramref name="lookup"/>.
|
||||
/// Gets the artworks of the media item described by <paramref name="lookup"/>.
|
||||
/// </summary>
|
||||
/// <param name="lookup">The lookup describing the media item to get the artwork for.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The artwork of the media item, or <see langword="null"/> when no artwork was found.</returns>
|
||||
Task<ArtworkDto?> GetArtworkAsync(TLookup lookup, CancellationToken cancellationToken);
|
||||
/// <returns>The artworks of the media item, or an empty collection when no artwork was found.</returns>
|
||||
Task<IReadOnlyList<ArtworkDto>> GetArtworkAsync(TLookup lookup, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the artwork of the media item described by <paramref name="lookup"/>.
|
||||
/// Gets the artworks of the media item described by <paramref name="lookup"/>.
|
||||
/// </summary>
|
||||
/// <param name="lookup">The lookup describing the media item to get the artwork for.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The artwork of the media item, or <see langword="null"/> when no artwork was found or the lookup is of another runtime type.</returns>
|
||||
async Task<ArtworkDto?> IArtworkProvider.GetArtworkAsync(MetadataLookupDto lookup, CancellationToken cancellationToken)
|
||||
/// <returns>The artworks of the media item, or an empty collection when no artwork was found or the lookup is of another runtime type.</returns>
|
||||
async Task<IReadOnlyList<ArtworkDto>> IArtworkProvider.GetArtworkAsync(MetadataLookupDto lookup, CancellationToken cancellationToken)
|
||||
{
|
||||
return lookup is TLookup typedLookup ? await GetArtworkAsync(typedLookup, cancellationToken).ConfigureAwait(false) : null;
|
||||
return lookup is TLookup typedLookup ? await GetArtworkAsync(typedLookup, cancellationToken).ConfigureAwait(false) : [];
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -23,6 +24,11 @@ public interface IMetadataProvider
|
||||
/// </summary>
|
||||
IReadOnlyList<LibraryType> SupportedLibraryTypes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the metadata lookup this provider accepts, used to select the provider that matches a given lookup.
|
||||
/// </summary>
|
||||
Type LookupType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this metadata provider requires access to the web to retrieve metadata.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -32,15 +33,20 @@ public interface IMetadataProvider<TLookup, TMetadata> : IMetadataProvider
|
||||
/// <returns>The metadata of the media item, or <see langword="null"/> when no metadata was found.</returns>
|
||||
Task<TMetadata?> GetMetadataAsync(TLookup lookup, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the metadata lookup this provider accepts.
|
||||
/// </summary>
|
||||
Type IMetadataProvider.LookupType => typeof(TLookup);
|
||||
|
||||
/// <summary>
|
||||
/// Searches for the metadata of the media item described by <paramref name="lookup"/>.
|
||||
/// </summary>
|
||||
/// <param name="lookup">The lookup describing the media item to search for.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The collection of metadata candidates found for the media item.</returns>
|
||||
/// <returns>The collection of metadata candidates found for the media item, or an empty collection when the lookup is of another runtime type.</returns>
|
||||
async Task<IReadOnlyList<MetadataDto>> IMetadataProvider.GetSearchResultsAsync(MetadataLookupDto lookup, CancellationToken cancellationToken)
|
||||
{
|
||||
return await GetSearchResultsAsync((TLookup)lookup, cancellationToken).ConfigureAwait(false);
|
||||
return lookup is TLookup typedLookup ? await GetSearchResultsAsync(typedLookup, cancellationToken).ConfigureAwait(false) : [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -48,9 +54,9 @@ public interface IMetadataProvider<TLookup, TMetadata> : IMetadataProvider
|
||||
/// </summary>
|
||||
/// <param name="lookup">The lookup describing the media item to get the metadata for.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The metadata of the media item, or <see langword="null"/> when no metadata was found.</returns>
|
||||
/// <returns>The metadata of the media item, or <see langword="null"/> when no metadata was found or the lookup is of another runtime type.</returns>
|
||||
async Task<MetadataDto?> IMetadataProvider.GetMetadataAsync(MetadataLookupDto lookup, CancellationToken cancellationToken)
|
||||
{
|
||||
return await GetMetadataAsync((TLookup)lookup, cancellationToken).ConfigureAwait(false);
|
||||
return lookup is TLookup typedLookup ? await GetMetadataAsync(typedLookup, cancellationToken).ConfigureAwait(false) : null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user