mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 15:11:10 +00:00
Renames project paths from Lumina to Nemera
This commit is contained in:
1 parent
ce6fddb4c9
commit
0f659a4877
6450 files changed
No files matched your search
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Plugins.Contracts.Core.Metadata;
|
||||
using Lumina.Plugins.Contracts.Core.Plugins;
|
||||
using Lumina.Plugins.CoverArtArchive.Common.Models.DTO.Settings;
|
||||
using Lumina.Plugins.CoverArtArchive.Core;
|
||||
using Lumina.Plugins.CoverArtArchive.Core.Api;
|
||||
using Lumina.Plugins.CoverArtArchive.Core.Settings;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.CoverArtArchive.Common.DependencyInjection;
|
||||
|
||||
/// <summary>
|
||||
/// Utility class for registering the services of the Cover Art Archive artwork provider into the Dependency Injection container.
|
||||
/// </summary>
|
||||
internal static class CoverArtArchiveServices
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers the services of the Cover Art Archive artwork provider into the Dependency Injection container.
|
||||
/// </summary>
|
||||
/// <param name="services">The service collection to add the services to.</param>
|
||||
/// <param name="pluginId">The unique identifier of the plugin that provides the artwork.</param>
|
||||
/// <param name="settingsCallback">Action used to configure the <see cref="CoverArtArchiveSettingsDto"/>.</param>
|
||||
/// <returns>The updated <see cref="IServiceCollection"/>.</returns>
|
||||
internal static IServiceCollection AddCoverArtArchiveArtworkProvider(this IServiceCollection services, Guid pluginId, Action<CoverArtArchiveSettingsDto>? settingsCallback = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(services);
|
||||
|
||||
// Build the runtime settings provider per scope, overlaying the settings persisted by the host over the defaults and the optional callback.
|
||||
services.TryAddScoped(serviceProvider =>
|
||||
{
|
||||
CoverArtArchiveSettingsDto defaults = new();
|
||||
settingsCallback?.Invoke(defaults);
|
||||
|
||||
IPluginSettingsStore? settingsStore = serviceProvider.GetService<IPluginSettingsStore>();
|
||||
return new CoverArtArchiveSettingsProvider(settingsStore, pluginId, defaults);
|
||||
});
|
||||
|
||||
// The throttle must be process-wide, because the Cover Art Archive API enforces its request policy across all callers, not per scope.
|
||||
services.TryAddSingleton<CoverArtArchiveRequestThrottle>();
|
||||
|
||||
// The response cache is process-wide, so that an entity shared by many items, like the release group shared by the releases of an album,
|
||||
// is fetched only once during a run.
|
||||
services.TryAddSingleton<CoverArtArchiveResponseCache>();
|
||||
|
||||
// The client follows the redirects of the Cover Art Archive itself, confined to the hosts the archive may delegate its responses to, so it opts out of the
|
||||
// host redirect handling. The host still validates and pins the address of every request and confirms that it is public.
|
||||
services.AddHttpClient<CoverArtArchiveHttpClient>();
|
||||
|
||||
// Register the artwork provider as a keyed by pluginId transient service, so it can be resolved specifically among other IArtworkProvider implementations.
|
||||
services.AddKeyedTransient<IArtworkProvider, CoverArtArchiveAlbumArtworkProvider>(pluginId);
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.CoverArtArchive.Common.Models.Contracts.Responses;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a response for the artwork of a release or a release group from the Cover Art Archive API.
|
||||
/// </summary>
|
||||
internal sealed record CoverArtArchiveArtworkResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the images of the artwork. It is nullable because the deserializer writes a JSON null over the initializer, and may also contain null elements.
|
||||
/// </summary>
|
||||
[JsonPropertyName("images")]
|
||||
public List<CoverArtArchiveImageResponse?>? Images { get; init; }
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.CoverArtArchive.Common.Models.Contracts.Responses;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a response for a single image of the artwork of a release or a release group from the Cover Art Archive API.
|
||||
/// </summary>
|
||||
internal sealed record CoverArtArchiveImageResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the URL of the full size image.
|
||||
/// </summary>
|
||||
[JsonPropertyName("image")]
|
||||
public string? Image { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the URL of the thumbnail of the image.
|
||||
/// </summary>
|
||||
[JsonPropertyName("thumbnail")]
|
||||
public string? Thumbnail { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the types of the image, like "Front", "Back", "Booklet", "Medium", "Tray", "Spine" or "Poster".
|
||||
/// It is nullable because the deserializer writes a JSON null over the initializer, and may also contain null elements.
|
||||
/// </summary>
|
||||
[JsonPropertyName("types")]
|
||||
public List<string?>? Types { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the image is the front cover.
|
||||
/// </summary>
|
||||
[JsonPropertyName("front")]
|
||||
public bool IsFront { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the image is the back cover.
|
||||
/// </summary>
|
||||
[JsonPropertyName("back")]
|
||||
public bool IsBack { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the optional comment describing the image.
|
||||
/// </summary>
|
||||
[JsonPropertyName("comment")]
|
||||
public string? Comment { get; init; }
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.CoverArtArchive.Common.Models.DTO.Settings;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the settings that configure the Cover Art Archive artwork plugin.
|
||||
/// </summary>
|
||||
internal sealed class CoverArtArchiveSettingsDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the user agent sent with every request to the Cover Art Archive API.
|
||||
/// </summary>
|
||||
public string UserAgent { get; set; } = "Lumina-CoverArtArchive/1.0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the contact email sent with every request to the Cover Art Archive API.
|
||||
/// The MetaBrainz services expect a meaningful user agent that carries a way to contact its author.
|
||||
/// </summary>
|
||||
public string? ContactEmail { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum interval between consecutive requests to the Cover Art Archive API, so that the public service is not overwhelmed.
|
||||
/// </summary>
|
||||
public TimeSpan MinimumRequestInterval { get; set; } = TimeSpan.FromSeconds(1.0);
|
||||
}
|
||||
Reference in new issue
Block a user