|
|
|
@ -4,7 +4,6 @@ using System.Linq;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Xml;
|
|
|
|
|
using Jellyfin.Extensions;
|
|
|
|
|
using MediaBrowser.Controller.Entities.Audio;
|
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
@ -14,6 +13,7 @@ using MediaBrowser.Providers.Music;
|
|
|
|
|
using MetaBrainz.MusicBrainz;
|
|
|
|
|
using MetaBrainz.MusicBrainz.Interfaces.Entities;
|
|
|
|
|
using MetaBrainz.MusicBrainz.Interfaces.Searches;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Providers.Plugins.MusicBrainz;
|
|
|
|
|
|
|
|
|
@ -22,16 +22,36 @@ namespace MediaBrowser.Providers.Plugins.MusicBrainz;
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class MusicBrainzArtistProvider : IRemoteMetadataProvider<MusicArtist, ArtistInfo>, IDisposable
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger<MusicBrainzArtistProvider> _logger;
|
|
|
|
|
private readonly Query _musicBrainzQuery;
|
|
|
|
|
private readonly string _musicBrainzDefaultUri = "https://musicbrainz.org";
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes a new instance of the <see cref="MusicBrainzArtistProvider"/> class.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public MusicBrainzArtistProvider()
|
|
|
|
|
/// <param name="logger">The logger.</param>
|
|
|
|
|
public MusicBrainzArtistProvider(ILogger<MusicBrainzArtistProvider> logger)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
|
|
|
|
|
MusicBrainz.Plugin.Instance!.ConfigurationChanged += (_, _) =>
|
|
|
|
|
{
|
|
|
|
|
Query.DefaultServer = MusicBrainz.Plugin.Instance.Configuration.Server;
|
|
|
|
|
if (Uri.TryCreate(MusicBrainz.Plugin.Instance.Configuration.Server, UriKind.Absolute, out var server))
|
|
|
|
|
{
|
|
|
|
|
Query.DefaultServer = server.Host;
|
|
|
|
|
Query.DefaultPort = server.Port;
|
|
|
|
|
Query.DefaultUrlScheme = server.Scheme;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Fallback to official server
|
|
|
|
|
_logger.LogWarning("Invalid MusicBrainz server specified, falling back to official server");
|
|
|
|
|
var defaultServer = new Uri(_musicBrainzDefaultUri);
|
|
|
|
|
Query.DefaultServer = defaultServer.Host;
|
|
|
|
|
Query.DefaultPort = defaultServer.Port;
|
|
|
|
|
Query.DefaultUrlScheme = defaultServer.Scheme;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Query.DelayBetweenRequests = MusicBrainz.Plugin.Instance.Configuration.RateLimit;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|