#region ========================================================================= USING =====================================================================================
using Lumina.Plugins.Contracts.Core.Plugins;
using Lumina.Plugins.Contracts.Core.Plugins.Settings;
using Lumina.Plugins.OpenLibrary.Common.DependencyInjection;
using Lumina.Plugins.OpenLibrary.Core.Settings;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
#endregion
namespace Lumina.Plugins.OpenLibrary.Core;
///
/// Plugin that provides book metadata retrieval from Open Library.
///
public sealed class OpenLibraryPlugin : IPlugin, IPluginServiceRegistrator
{
///
/// The unique identifier of the plugin.
///
public static readonly Guid s_pluginId = new("08b17802-7f9c-4c4b-9d7f-b507bbed3e58");
///
/// Gets the unique identifier of the plugin.
///
public Guid Id => s_pluginId;
///
/// Gets the display name of the plugin.
///
public string Name => "Open Library Metadata";
///
/// Gets the author of the plugin.
///
public string Author => "Lumina";
///
/// Gets the version of the plugin.
///
public Version Version => new(1, 0, 0);
///
/// Gets the description of the plugin.
///
public string Description => "Retrieves book and edition metadata from Open Library.";
///
/// Gets the settings schema of the plugin.
///
/// The settings descriptors of the plugin.
public IReadOnlyList GetSettingsSchema()
{
return
[
new PluginSettingDescriptor(
Key: OpenLibrarySettingsKeys.CONTACT_EMAIL,
Label: "Contact Email",
Type: PluginSettingType.Text),
new PluginSettingDescriptor(
Key: OpenLibrarySettingsKeys.SEARCH_RESULT_LIMIT,
Label: "Search Result Limit",
Type: PluginSettingType.Number,
DefaultValue: "10"),
new PluginSettingDescriptor(
Key: OpenLibrarySettingsKeys.WORK_EDITION_LIMIT,
Label: "Work Edition Limit",
Type: PluginSettingType.Number,
DefaultValue: "50"),
new PluginSettingDescriptor(
Key: OpenLibrarySettingsKeys.MINIMUM_REQUEST_INTERVAL_SECONDS,
Label: "Minimum Request Interval (seconds)",
Type: PluginSettingType.Number,
DefaultValue: "1.1")
];
}
///
/// Registers the services required by the plugin.
///
/// The service collection to register the services into.
public void RegisterServices(IServiceCollection services)
{
services.AddOpenLibraryBookMetadataProvider(pluginId: Id);
}
}