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