jellyfin/MediaBrowser.Providers/Plugins/MusicBrainz/Plugin.cs

65 lines
2.4 KiB
C#
Raw Normal View History

using System;
2020-02-22 06:04:52 +00:00
using System.Collections.Generic;
using System.Net.Http.Headers;
2022-04-27 11:44:49 +00:00
using MediaBrowser.Common;
2020-02-22 06:04:52 +00:00
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Model.Plugins;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Providers.Plugins.MusicBrainz.Configuration;
using MetaBrainz.MusicBrainz;
namespace MediaBrowser.Providers.Plugins.MusicBrainz;
2020-02-22 06:04:52 +00:00
/// <summary>
/// Plugin instance.
/// </summary>
public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
2020-02-22 06:04:52 +00:00
{
/// <summary>
/// Initializes a new instance of the <see cref="Plugin"/> class.
/// </summary>
/// <param name="applicationPaths">Instance of the <see cref="IApplicationPaths"/> interface.</param>
/// <param name="xmlSerializer">Instance of the <see cref="IXmlSerializer"/> interface.</param>
2022-04-27 11:44:49 +00:00
/// <param name="applicationHost">Instance of the <see cref="IApplicationHost"/> interface.</param>
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer, IApplicationHost applicationHost)
: base(applicationPaths, xmlSerializer)
2020-02-22 06:04:52 +00:00
{
Instance = this;
2021-07-23 00:33:19 +00:00
// TODO: Change this to "JellyfinMusicBrainzPlugin" once we take it out of the server repo.
2022-04-27 11:44:49 +00:00
Query.DefaultUserAgent.Add(new ProductInfoHeaderValue(applicationHost.Name.Replace(' ', '-'), applicationHost.ApplicationVersionString));
Query.DefaultUserAgent.Add(new ProductInfoHeaderValue($"({applicationHost.ApplicationUserAgentAddress})"));
Query.DelayBetweenRequests = Instance.Configuration.RateLimit;
Query.DefaultServer = Instance.Configuration.Server;
}
/// <summary>
/// Gets the current plugin instance.
/// </summary>
public static Plugin? Instance { get; private set; }
2020-02-27 16:43:57 +00:00
/// <inheritdoc />
public override Guid Id => new Guid("8c95c4d2-e50c-4fb0-a4f3-6c06ff0f9a1a");
2020-02-27 16:43:57 +00:00
/// <inheritdoc />
public override string Name => "MusicBrainz";
2020-02-27 16:43:57 +00:00
/// <inheritdoc />
public override string Description => "Get artist and album metadata from any MusicBrainz server.";
2020-02-27 16:43:57 +00:00
/// <inheritdoc />
// TODO remove when plugin removed from server.
public override string ConfigurationFileName => "Jellyfin.Plugin.MusicBrainz.xml";
2020-07-22 14:19:26 +00:00
/// <inheritdoc />
public IEnumerable<PluginPageInfo> GetPages()
{
yield return new PluginPageInfo
2020-02-22 06:04:52 +00:00
{
Name = Name,
EmbeddedResourcePath = GetType().Namespace + ".Configuration.config.html"
};
2020-02-22 06:04:52 +00:00
}
}