#region ========================================================================= USING =====================================================================================
using Lumina.Domain.SharedKernel.Common.Enums.Plugins;
using Lumina.Plugins.Contracts.Common.Models.DTO.Settings;
using Lumina.Plugins.Contracts.Core.Plugins;
using Lumina.Plugins.MusicBrainz.Common.DependencyInjection;
using Lumina.Plugins.MusicBrainz.Core.Settings;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
#endregion
namespace Lumina.Plugins.MusicBrainz.Core;
///
/// Plugin that provides music metadata retrieval from MusicBrainz.
///
public sealed class MusicBrainzPlugin : IPlugin, IPluginServiceRegistrator
{
///
/// The unique identifier of the plugin.
///
public static readonly Guid s_pluginId = new("f4c1a7de-3b52-4e6a-9d21-8c7e5b04a1f3");
///
/// Gets the unique identifier of the plugin.
///
public Guid Id => s_pluginId;
///
/// Gets the display name of the plugin.
///
public string Name => "MusicBrainz 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 artist, album and track metadata from MusicBrainz.";
///
/// Gets the settings schema of the plugin.
///
/// The settings descriptors of the plugin.
public IReadOnlyList GetSettingsSchema()
{
return
[
new PluginSettingDescriptorDto(
Key: MusicBrainzSettingsKeys.BASE_URL,
Label: "Base URL",
Type: PluginSettingType.Text,
DefaultValue: "https://musicbrainz.org/ws/2/"),
new PluginSettingDescriptorDto(
Key: MusicBrainzSettingsKeys.DOES_ALLOW_PRIVATE_BASE_URL,
Label: "Allow LAN/Private Base URL",
Type: PluginSettingType.Boolean,
DefaultValue: "false"),
new PluginSettingDescriptorDto(
Key: MusicBrainzSettingsKeys.CONTACT_EMAIL,
Label: "Contact Email",
Type: PluginSettingType.Text),
new PluginSettingDescriptorDto(
Key: MusicBrainzSettingsKeys.SEARCH_RESULT_LIMIT,
Label: "Search Result Limit",
Type: PluginSettingType.Number,
DefaultValue: "10"),
new PluginSettingDescriptorDto(
Key: MusicBrainzSettingsKeys.RELEASE_LOOKUP_LIMIT,
Label: "Release Lookup Limit",
Type: PluginSettingType.Number,
DefaultValue: "25"),
new PluginSettingDescriptorDto(
Key: MusicBrainzSettingsKeys.MINIMUM_REQUEST_INTERVAL_SECONDS,
Label: "Minimum Request Interval (seconds)",
Type: PluginSettingType.Number,
DefaultValue: "1.0")
];
}
///
/// Registers the services required by the plugin.
///
/// The service collection to register the services into.
public void RegisterServices(IServiceCollection services)
{
services.AddMusicBrainzMetadataProviders(pluginId: Id);
}
}