mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 18: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
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Plugins.Contracts.Core.Metadata;
|
||||
using Lumina.Plugins.Contracts.Core.Plugins;
|
||||
using Lumina.Plugins.OpenLibrary.Common.Models.DTO.Settings;
|
||||
using Lumina.Plugins.OpenLibrary.Core;
|
||||
using Lumina.Plugins.OpenLibrary.Core.Api;
|
||||
using Lumina.Plugins.OpenLibrary.Core.Settings;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.OpenLibrary.Common.DependencyInjection;
|
||||
|
||||
/// <summary>
|
||||
/// Utility class for registering the services of the Open Library metadata provider into the Dependency Injection container.
|
||||
/// </summary>
|
||||
internal static class OpenLibraryServices
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers the services of the Open Library metadata 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 metadata.</param>
|
||||
/// <param name="settingsCallback">Action used to configure the <see cref="OpenLibrarySettingsDto"/>.</param>
|
||||
/// <returns>The updated <see cref="IServiceCollection"/>.</returns>
|
||||
internal static IServiceCollection AddOpenLibraryBookMetadataProvider(this IServiceCollection services, Guid pluginId, Action<OpenLibrarySettingsDto>? 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 =>
|
||||
{
|
||||
OpenLibrarySettingsDto defaults = new();
|
||||
settingsCallback?.Invoke(defaults);
|
||||
|
||||
IPluginSettingsStore? settingsStore = serviceProvider.GetService<IPluginSettingsStore>();
|
||||
return new OpenLibrarySettingsProvider(settingsStore, pluginId, defaults);
|
||||
});
|
||||
|
||||
services.AddHttpClient<OpenLibraryHttpClient>();
|
||||
|
||||
// Register the metadata provider as a keyed by pluginId transient service, so it can be resolved specifically among other IMetadataProvider implementations.
|
||||
services.AddKeyedTransient<IMetadataProvider, OpenLibraryBookMetadataProvider>(pluginId);
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a response for an author from the Open Library API.
|
||||
/// </summary>
|
||||
internal sealed record OpenLibraryAuthorResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the key of the author.
|
||||
/// </summary>
|
||||
[JsonPropertyName("key")]
|
||||
public string? Key { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the author.
|
||||
/// </summary>
|
||||
[JsonPropertyName("name")]
|
||||
public string? Name { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the personal name of the author.
|
||||
/// </summary>
|
||||
[JsonPropertyName("personal_name")]
|
||||
public string? PersonalName { get; init; }
|
||||
}
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a response for an edition from the Open Library API.
|
||||
/// </summary>
|
||||
internal sealed record OpenLibraryEditionResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the key of the edition.
|
||||
/// </summary>
|
||||
[JsonPropertyName("key")]
|
||||
public string? Key { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the title of the edition.
|
||||
/// </summary>
|
||||
[JsonPropertyName("title")]
|
||||
public string? Title { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the subtitle of the edition.
|
||||
/// </summary>
|
||||
[JsonPropertyName("subtitle")]
|
||||
public string? Subtitle { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the notes of the edition.
|
||||
/// </summary>
|
||||
[JsonPropertyName("notes")]
|
||||
public JsonElement Notes { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the publication date of the edition.
|
||||
/// </summary>
|
||||
[JsonPropertyName("publish_date")]
|
||||
public string? PublishDate { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the publishers of the edition.
|
||||
/// </summary>
|
||||
[JsonPropertyName("publishers")]
|
||||
public List<string> Publishers { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the MARC 21 country code of the publication place of the edition.
|
||||
/// </summary>
|
||||
[JsonPropertyName("publish_country")]
|
||||
public string? PublishCountry { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of pages of the edition.
|
||||
/// </summary>
|
||||
[JsonPropertyName("number_of_pages")]
|
||||
public int? NumberOfPages { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the physical format of the edition.
|
||||
/// </summary>
|
||||
[JsonPropertyName("physical_format")]
|
||||
public string? PhysicalFormat { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the edition.
|
||||
/// </summary>
|
||||
[JsonPropertyName("edition_name")]
|
||||
public string? EditionName { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the series the edition belongs to.
|
||||
/// </summary>
|
||||
[JsonPropertyName("series")]
|
||||
public List<string> Series { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the volume of the edition within its series.
|
||||
/// </summary>
|
||||
[JsonPropertyName("volume")]
|
||||
public string? Volume { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ISBN-10 identifiers of the edition.
|
||||
/// </summary>
|
||||
[JsonPropertyName("isbn_10")]
|
||||
public List<string> Isbn10 { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ISBN-13 identifiers of the edition.
|
||||
/// </summary>
|
||||
[JsonPropertyName("isbn_13")]
|
||||
public List<string> Isbn13 { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the LCCN identifiers of the edition.
|
||||
/// </summary>
|
||||
[JsonPropertyName("lccn")]
|
||||
public List<string> Lccn { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the OCLC numbers of the edition.
|
||||
/// </summary>
|
||||
[JsonPropertyName("oclc_numbers")]
|
||||
public List<string> OclcNumbers { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the external identifiers of the edition, keyed by identifier name.
|
||||
/// </summary>
|
||||
[JsonPropertyName("identifiers")]
|
||||
public JsonElement Identifiers { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the source records of the edition.
|
||||
/// </summary>
|
||||
[JsonPropertyName("source_records")]
|
||||
public List<string> SourceRecords { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the languages of the edition.
|
||||
/// </summary>
|
||||
[JsonPropertyName("languages")]
|
||||
public List<OpenLibraryKeyReferenceResponse> Languages { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the authors of the edition.
|
||||
/// </summary>
|
||||
[JsonPropertyName("authors")]
|
||||
public List<OpenLibraryKeyReferenceResponse> Authors { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the works the edition belongs to.
|
||||
/// </summary>
|
||||
[JsonPropertyName("works")]
|
||||
public List<OpenLibraryKeyReferenceResponse> Works { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the contributions of the edition.
|
||||
/// </summary>
|
||||
[JsonPropertyName("contributions")]
|
||||
public List<string> Contributions { get; init; } = [];
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a response for the editions of a work from the Open Library API.
|
||||
/// </summary>
|
||||
internal sealed record OpenLibraryEditionsResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the editions of the work.
|
||||
/// </summary>
|
||||
[JsonPropertyName("entries")]
|
||||
public List<OpenLibraryEditionResponse> Entries { get; init; } = [];
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a response for a reference to a resource of the Open Library API by its key.
|
||||
/// </summary>
|
||||
internal sealed record OpenLibraryKeyReferenceResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the key of the referenced resource.
|
||||
/// </summary>
|
||||
[JsonPropertyName("key")]
|
||||
public string? Key { get; init; }
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a response for the summary of the ratings of a work from the Open Library API.
|
||||
/// </summary>
|
||||
internal sealed record OpenLibraryRatingSummaryResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the average rating of the work.
|
||||
/// </summary>
|
||||
[JsonPropertyName("average")]
|
||||
public decimal? Average { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of ratings of the work.
|
||||
/// </summary>
|
||||
[JsonPropertyName("count")]
|
||||
public int? Count { get; init; }
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a response for the ratings of a work from the Open Library API.
|
||||
/// </summary>
|
||||
internal sealed record OpenLibraryRatingsResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the summary of the ratings of the work.
|
||||
/// </summary>
|
||||
[JsonPropertyName("summary")]
|
||||
public OpenLibraryRatingSummaryResponse? Summary { get; init; }
|
||||
}
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a response for a search document from the Open Library API.
|
||||
/// </summary>
|
||||
internal sealed record OpenLibrarySearchDocumentResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the key of the search document.
|
||||
/// </summary>
|
||||
[JsonPropertyName("key")]
|
||||
public string? Key { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the title of the search document.
|
||||
/// </summary>
|
||||
[JsonPropertyName("title")]
|
||||
public string? Title { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the author names of the search document.
|
||||
/// </summary>
|
||||
[JsonPropertyName("author_name")]
|
||||
public List<string> AuthorNames { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the author keys of the search document.
|
||||
/// </summary>
|
||||
[JsonPropertyName("author_key")]
|
||||
public List<string> AuthorKeys { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first publication year of the search document.
|
||||
/// </summary>
|
||||
[JsonPropertyName("first_publish_year")]
|
||||
public int? FirstPublishYear { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the edition keys of the search document.
|
||||
/// </summary>
|
||||
[JsonPropertyName("edition_key")]
|
||||
public List<string> EditionKeys { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ISBNs of the search document.
|
||||
/// </summary>
|
||||
[JsonPropertyName("isbn")]
|
||||
public List<string> Isbns { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the languages of the search document.
|
||||
/// </summary>
|
||||
[JsonPropertyName("language")]
|
||||
public List<string> Languages { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the publishers of the search document.
|
||||
/// </summary>
|
||||
[JsonPropertyName("publisher")]
|
||||
public List<string> Publishers { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the subjects of the search document.
|
||||
/// </summary>
|
||||
[JsonPropertyName("subject")]
|
||||
public List<string> Subjects { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the median number of pages of the search document.
|
||||
/// </summary>
|
||||
[JsonPropertyName("number_of_pages_median")]
|
||||
public int? NumberOfPagesMedian { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the average rating of the search document.
|
||||
/// </summary>
|
||||
[JsonPropertyName("ratings_average")]
|
||||
public decimal? RatingsAverage { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of ratings of the search document.
|
||||
/// </summary>
|
||||
[JsonPropertyName("ratings_count")]
|
||||
public int? RatingsCount { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Amazon identifiers of the search document.
|
||||
/// </summary>
|
||||
[JsonPropertyName("id_amazon")]
|
||||
public List<string> AmazonIds { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Goodreads identifiers of the search document.
|
||||
/// </summary>
|
||||
[JsonPropertyName("id_goodreads")]
|
||||
public List<string> GoodreadsIds { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Google identifiers of the search document.
|
||||
/// </summary>
|
||||
[JsonPropertyName("id_google")]
|
||||
public List<string> GoogleIds { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the LibraryThing identifiers of the search document.
|
||||
/// </summary>
|
||||
[JsonPropertyName("id_librarything")]
|
||||
public List<string> LibraryThingIds { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the LCCN identifiers of the search document.
|
||||
/// </summary>
|
||||
[JsonPropertyName("lccn")]
|
||||
public List<string> Lccn { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the OCLC identifiers of the search document.
|
||||
/// </summary>
|
||||
[JsonPropertyName("oclc")]
|
||||
public List<string> Oclc { get; init; } = [];
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a response for a search from the Open Library API.
|
||||
/// </summary>
|
||||
internal sealed record OpenLibrarySearchResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the documents that match the search.
|
||||
/// </summary>
|
||||
[JsonPropertyName("docs")]
|
||||
public List<OpenLibrarySearchDocumentResponse> Documents { get; init; } = [];
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a response for an author reference within a work from the Open Library API.
|
||||
/// </summary>
|
||||
internal sealed record OpenLibraryWorkAuthorResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the author of the work.
|
||||
/// </summary>
|
||||
[JsonPropertyName("author")]
|
||||
public OpenLibraryKeyReferenceResponse? Author { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the key of the author reference.
|
||||
/// </summary>
|
||||
[JsonPropertyName("key")]
|
||||
public string? Key { get; init; } // Older records can contain a direct key rather than an author wrapper.
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a response for a work from the Open Library API.
|
||||
/// </summary>
|
||||
internal sealed record OpenLibraryWorkResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the key of the work.
|
||||
/// </summary>
|
||||
[JsonPropertyName("key")]
|
||||
public string? Key { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the title of the work.
|
||||
/// </summary>
|
||||
[JsonPropertyName("title")]
|
||||
public string? Title { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the original title of the work.
|
||||
/// </summary>
|
||||
[JsonPropertyName("original_title")]
|
||||
public string? OriginalTitle { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the description of the work.
|
||||
/// </summary>
|
||||
[JsonPropertyName("description")]
|
||||
public JsonElement Description { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first publication date of the work.
|
||||
/// </summary>
|
||||
[JsonPropertyName("first_publish_date")]
|
||||
public string? FirstPublishDate { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the subjects of the work.
|
||||
/// </summary>
|
||||
[JsonPropertyName("subjects")]
|
||||
public List<string> Subjects { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the genres of the work.
|
||||
/// </summary>
|
||||
[JsonPropertyName("genres")]
|
||||
public List<string> Genres { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the authors of the work.
|
||||
/// </summary>
|
||||
[JsonPropertyName("authors")]
|
||||
public List<OpenLibraryWorkAuthorResponse> Authors { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the original languages of the work.
|
||||
/// </summary>
|
||||
[JsonPropertyName("original_languages")]
|
||||
public List<OpenLibraryKeyReferenceResponse> OriginalLanguages { get; init; } = [];
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Plugins.OpenLibrary.Common.Models.DTO.Settings;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the settings that configure the Open Library metadata plugin.
|
||||
/// </summary>
|
||||
internal sealed class OpenLibrarySettingsDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the user agent sent with every request to the Open Library API.
|
||||
/// </summary>
|
||||
public string UserAgent { get; set; } = "Lumina-OpenLibrary/1.0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the contact email sent with every request to the Open Library API.
|
||||
/// </summary>
|
||||
public string? ContactEmail { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum number of results returned by a single search.
|
||||
/// </summary>
|
||||
public int SearchResultLimit { get; set; } = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum number of editions fetched for a single work.
|
||||
/// </summary>
|
||||
public int WorkEditionLimit { get; set; } = 50;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum interval between consecutive requests to the Open Library API.
|
||||
/// </summary>
|
||||
public TimeSpan MinimumRequestInterval { get; set; } = TimeSpan.FromSeconds(1.1);
|
||||
}
|
||||
Reference in new issue
Block a user