2020-06-19 18:24:13 +00:00
|
|
|
using System;
|
2020-02-22 06:04:52 +00:00
|
|
|
using System.Collections.Generic;
|
2022-04-07 10:15:25 +00:00
|
|
|
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;
|
2022-04-07 10:15:25 +00:00
|
|
|
using MediaBrowser.Providers.Plugins.MusicBrainz.Configuration;
|
|
|
|
using MetaBrainz.MusicBrainz;
|
|
|
|
|
|
|
|
namespace MediaBrowser.Providers.Plugins.MusicBrainz;
|
2020-02-22 06:04:52 +00:00
|
|
|
|
2022-04-07 10:15:25 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Plugin instance.
|
|
|
|
/// </summary>
|
|
|
|
public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
2020-02-22 06:04:52 +00:00
|
|
|
{
|
2022-04-07 10:15:25 +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)
|
2022-04-07 10:15:25 +00:00
|
|
|
: base(applicationPaths, xmlSerializer)
|
2020-02-22 06:04:52 +00:00
|
|
|
{
|
2022-04-07 10:15:25 +00:00
|
|
|
Instance = this;
|
2021-07-23 00:33:19 +00:00
|
|
|
|
2022-04-07 10:15:25 +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})"));
|
2022-04-07 10:15:25 +00:00
|
|
|
Query.DelayBetweenRequests = Instance.Configuration.RateLimit;
|
|
|
|
Query.DefaultServer = Instance.Configuration.Server;
|
|
|
|
}
|
2021-06-27 00:00:17 +00:00
|
|
|
|
2022-04-07 10:15:25 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Gets the current plugin instance.
|
|
|
|
/// </summary>
|
|
|
|
public static Plugin? Instance { get; private set; }
|
2020-02-27 16:43:57 +00:00
|
|
|
|
2022-04-07 10:15:25 +00:00
|
|
|
/// <inheritdoc />
|
|
|
|
public override Guid Id => new Guid("8c95c4d2-e50c-4fb0-a4f3-6c06ff0f9a1a");
|
2020-02-27 16:43:57 +00:00
|
|
|
|
2022-04-07 10:15:25 +00:00
|
|
|
/// <inheritdoc />
|
|
|
|
public override string Name => "MusicBrainz";
|
2020-02-27 16:43:57 +00:00
|
|
|
|
2022-04-07 10:15:25 +00:00
|
|
|
/// <inheritdoc />
|
|
|
|
public override string Description => "Get artist and album metadata from any MusicBrainz server.";
|
2020-02-27 16:43:57 +00:00
|
|
|
|
2022-04-07 10:15:25 +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
|
|
|
|
2022-04-07 10:15:25 +00:00
|
|
|
/// <inheritdoc />
|
|
|
|
public IEnumerable<PluginPageInfo> GetPages()
|
|
|
|
{
|
|
|
|
yield return new PluginPageInfo
|
2020-02-22 06:04:52 +00:00
|
|
|
{
|
2022-04-07 10:15:25 +00:00
|
|
|
Name = Name,
|
|
|
|
EmbeddedResourcePath = GetType().Namespace + ".Configuration.config.html"
|
|
|
|
};
|
2020-02-22 06:04:52 +00:00
|
|
|
}
|
|
|
|
}
|