From 76e49a1eb73077ce710591d46a0c7aa5d6d04812 Mon Sep 17 00:00:00 2001 From: dkanada Date: Tue, 3 Mar 2020 02:07:31 +0900 Subject: [PATCH 1/4] migrate audiodb to plugin --- .../AudioDb/AlbumImageProvider.cs} | 2 +- .../AudioDb/AlbumProvider.cs} | 3 +- .../AudioDb/ArtistImageProvider.cs} | 2 +- .../AudioDb/ArtistProvider.cs} | 3 +- .../Configuration/PluginConfiguration.cs | 9 ++++ .../Plugins/AudioDb/Configuration/config.html | 51 +++++++++++++++++++ .../AudioDb/ExternalIds.cs} | 8 ++- .../Plugins/AudioDb/Plugin.cs | 35 +++++++++++++ 8 files changed, 104 insertions(+), 9 deletions(-) rename MediaBrowser.Providers/{Music/AudioDbAlbumImageProvider.cs => Plugins/AudioDb/AlbumImageProvider.cs} (98%) rename MediaBrowser.Providers/{Music/AudioDbAlbumProvider.cs => Plugins/AudioDb/AlbumProvider.cs} (99%) rename MediaBrowser.Providers/{Music/AudioDbArtistImageProvider.cs => Plugins/AudioDb/ArtistImageProvider.cs} (98%) rename MediaBrowser.Providers/{Music/AudioDbArtistProvider.cs => Plugins/AudioDb/ArtistProvider.cs} (99%) create mode 100644 MediaBrowser.Providers/Plugins/AudioDb/Configuration/PluginConfiguration.cs create mode 100644 MediaBrowser.Providers/Plugins/AudioDb/Configuration/config.html rename MediaBrowser.Providers/{Music/AudioDbExternalIds.cs => Plugins/AudioDb/ExternalIds.cs} (88%) create mode 100644 MediaBrowser.Providers/Plugins/AudioDb/Plugin.cs diff --git a/MediaBrowser.Providers/Music/AudioDbAlbumImageProvider.cs b/MediaBrowser.Providers/Plugins/AudioDb/AlbumImageProvider.cs similarity index 98% rename from MediaBrowser.Providers/Music/AudioDbAlbumImageProvider.cs rename to MediaBrowser.Providers/Plugins/AudioDb/AlbumImageProvider.cs index 85a87630d7..85719fa51a 100644 --- a/MediaBrowser.Providers/Music/AudioDbAlbumImageProvider.cs +++ b/MediaBrowser.Providers/Plugins/AudioDb/AlbumImageProvider.cs @@ -10,7 +10,7 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.Providers; using MediaBrowser.Model.Serialization; -namespace MediaBrowser.Providers.Music +namespace MediaBrowser.Providers.Plugins.AudioDb { public class AudioDbAlbumImageProvider : IRemoteImageProvider, IHasOrder { diff --git a/MediaBrowser.Providers/Music/AudioDbAlbumProvider.cs b/MediaBrowser.Providers/Plugins/AudioDb/AlbumProvider.cs similarity index 99% rename from MediaBrowser.Providers/Music/AudioDbAlbumProvider.cs rename to MediaBrowser.Providers/Plugins/AudioDb/AlbumProvider.cs index 939c74c01c..7f9f8c628d 100644 --- a/MediaBrowser.Providers/Music/AudioDbAlbumProvider.cs +++ b/MediaBrowser.Providers/Plugins/AudioDb/AlbumProvider.cs @@ -16,8 +16,9 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; using MediaBrowser.Model.Providers; using MediaBrowser.Model.Serialization; +using MediaBrowser.Providers.Music; -namespace MediaBrowser.Providers.Music +namespace MediaBrowser.Providers.Plugins.AudioDb { public class AudioDbAlbumProvider : IRemoteMetadataProvider, IHasOrder { diff --git a/MediaBrowser.Providers/Music/AudioDbArtistImageProvider.cs b/MediaBrowser.Providers/Plugins/AudioDb/ArtistImageProvider.cs similarity index 98% rename from MediaBrowser.Providers/Music/AudioDbArtistImageProvider.cs rename to MediaBrowser.Providers/Plugins/AudioDb/ArtistImageProvider.cs index b9315744fd..51b0eacfc8 100644 --- a/MediaBrowser.Providers/Music/AudioDbArtistImageProvider.cs +++ b/MediaBrowser.Providers/Plugins/AudioDb/ArtistImageProvider.cs @@ -10,7 +10,7 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.Providers; using MediaBrowser.Model.Serialization; -namespace MediaBrowser.Providers.Music +namespace MediaBrowser.Providers.Plugins.AudioDb { public class AudioDbArtistImageProvider : IRemoteImageProvider, IHasOrder { diff --git a/MediaBrowser.Providers/Music/AudioDbArtistProvider.cs b/MediaBrowser.Providers/Plugins/AudioDb/ArtistProvider.cs similarity index 99% rename from MediaBrowser.Providers/Music/AudioDbArtistProvider.cs rename to MediaBrowser.Providers/Plugins/AudioDb/ArtistProvider.cs index e073a295b0..a51c107df3 100644 --- a/MediaBrowser.Providers/Music/AudioDbArtistProvider.cs +++ b/MediaBrowser.Providers/Plugins/AudioDb/ArtistProvider.cs @@ -15,8 +15,9 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; using MediaBrowser.Model.Providers; using MediaBrowser.Model.Serialization; +using MediaBrowser.Providers.Music; -namespace MediaBrowser.Providers.Music +namespace MediaBrowser.Providers.Plugins.AudioDb { public class AudioDbArtistProvider : IRemoteMetadataProvider, IHasOrder { diff --git a/MediaBrowser.Providers/Plugins/AudioDb/Configuration/PluginConfiguration.cs b/MediaBrowser.Providers/Plugins/AudioDb/Configuration/PluginConfiguration.cs new file mode 100644 index 0000000000..90790d26fc --- /dev/null +++ b/MediaBrowser.Providers/Plugins/AudioDb/Configuration/PluginConfiguration.cs @@ -0,0 +1,9 @@ +using MediaBrowser.Model.Plugins; + +namespace MediaBrowser.Providers.Plugins.AudioDb +{ + public class PluginConfiguration : BasePluginConfiguration + { + public bool Enable { get; set; } + } +} diff --git a/MediaBrowser.Providers/Plugins/AudioDb/Configuration/config.html b/MediaBrowser.Providers/Plugins/AudioDb/Configuration/config.html new file mode 100644 index 0000000000..56c32e13ea --- /dev/null +++ b/MediaBrowser.Providers/Plugins/AudioDb/Configuration/config.html @@ -0,0 +1,51 @@ + + + + AudioDB + + +
+
+
+
+ +
+
+ +
+
+
+
+ +
+ + diff --git a/MediaBrowser.Providers/Music/AudioDbExternalIds.cs b/MediaBrowser.Providers/Plugins/AudioDb/ExternalIds.cs similarity index 88% rename from MediaBrowser.Providers/Music/AudioDbExternalIds.cs rename to MediaBrowser.Providers/Plugins/AudioDb/ExternalIds.cs index c866d12de5..2d8cb431ca 100644 --- a/MediaBrowser.Providers/Music/AudioDbExternalIds.cs +++ b/MediaBrowser.Providers/Plugins/AudioDb/ExternalIds.cs @@ -2,7 +2,7 @@ using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; -namespace MediaBrowser.Providers.Music +namespace MediaBrowser.Providers.Plugins.AudioDb { public class AudioDbAlbumExternalId : IExternalId { @@ -16,8 +16,7 @@ namespace MediaBrowser.Providers.Music public string UrlFormatString => "https://www.theaudiodb.com/album/{0}"; /// - public bool Supports(IHasProviderIds item) - => item is MusicAlbum; + public bool Supports(IHasProviderIds item) => item is MusicAlbum; } public class AudioDbOtherAlbumExternalId : IExternalId @@ -62,7 +61,6 @@ namespace MediaBrowser.Providers.Music public string UrlFormatString => "https://www.theaudiodb.com/artist/{0}"; /// - public bool Supports(IHasProviderIds item) - => item is Audio || item is MusicAlbum; + public bool Supports(IHasProviderIds item) => item is Audio || item is MusicAlbum; } } diff --git a/MediaBrowser.Providers/Plugins/AudioDb/Plugin.cs b/MediaBrowser.Providers/Plugins/AudioDb/Plugin.cs new file mode 100644 index 0000000000..8532c4df3a --- /dev/null +++ b/MediaBrowser.Providers/Plugins/AudioDb/Plugin.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Plugins; +using MediaBrowser.Model.Plugins; +using MediaBrowser.Model.Serialization; + +namespace MediaBrowser.Providers.Plugins.AudioDb +{ + public class Plugin : BasePlugin, IHasWebPages + { + public static Plugin Instance { get; private set; } + + public override Guid Id => new Guid("a629c0da-fac5-4c7e-931a-7174223f14c8"); + + public override string Name => "AudioDB"; + + public override string Description => "Get artist and album metadata or images from AudioDB."; + + public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) + : base(applicationPaths, xmlSerializer) + { + Instance = this; + } + + public IEnumerable GetPages() + { + yield return new PluginPageInfo + { + Name = Name, + EmbeddedResourcePath = GetType().Namespace + ".Configuration.config.html" + }; + } + } +} From 26c778eb166ead97f32a736e22d99513f9784654 Mon Sep 17 00:00:00 2001 From: dkanada Date: Sun, 8 Mar 2020 12:10:25 +0900 Subject: [PATCH 2/4] implement option to disable audiodb for now --- .../Plugins/AudioDb/AlbumImageProvider.cs | 3 ++- .../Plugins/AudioDb/AlbumProvider.cs | 11 +++++++++++ .../Plugins/AudioDb/ArtistImageProvider.cs | 3 ++- .../Plugins/AudioDb/ArtistProvider.cs | 6 ++++++ .../AudioDb/Configuration/PluginConfiguration.cs | 2 ++ .../Plugins/AudioDb/Configuration/config.html | 4 ++++ 6 files changed, 27 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Providers/Plugins/AudioDb/AlbumImageProvider.cs b/MediaBrowser.Providers/Plugins/AudioDb/AlbumImageProvider.cs index 85719fa51a..dee2d59f0f 100644 --- a/MediaBrowser.Providers/Plugins/AudioDb/AlbumImageProvider.cs +++ b/MediaBrowser.Providers/Plugins/AudioDb/AlbumImageProvider.cs @@ -102,6 +102,7 @@ namespace MediaBrowser.Providers.Plugins.AudioDb } /// - public bool Supports(BaseItem item) => item is MusicAlbum; + public bool Supports(BaseItem item) + => Plugin.Instance.Configuration.Enable && item is MusicAlbum; } } diff --git a/MediaBrowser.Providers/Plugins/AudioDb/AlbumProvider.cs b/MediaBrowser.Providers/Plugins/AudioDb/AlbumProvider.cs index 7f9f8c628d..1a0e878719 100644 --- a/MediaBrowser.Providers/Plugins/AudioDb/AlbumProvider.cs +++ b/MediaBrowser.Providers/Plugins/AudioDb/AlbumProvider.cs @@ -55,6 +55,12 @@ namespace MediaBrowser.Providers.Plugins.AudioDb { var result = new MetadataResult(); + // TODO maybe remove when artist metadata can be disabled + if (!Plugin.Instance.Configuration.Enable) + { + return result; + } + var id = info.GetReleaseGroupId(); if (!string.IsNullOrWhiteSpace(id)) @@ -78,6 +84,11 @@ namespace MediaBrowser.Providers.Plugins.AudioDb private void ProcessResult(MusicAlbum item, Album result, string preferredLanguage) { + if (Plugin.Instance.Configuration.ReplaceAlbumName && !string.IsNullOrWhiteSpace(result.strAlbum)) + { + item.Album = result.strAlbum; + } + if (!string.IsNullOrWhiteSpace(result.strArtist)) { item.AlbumArtists = new string[] { result.strArtist }; diff --git a/MediaBrowser.Providers/Plugins/AudioDb/ArtistImageProvider.cs b/MediaBrowser.Providers/Plugins/AudioDb/ArtistImageProvider.cs index 51b0eacfc8..18afd5dd5c 100644 --- a/MediaBrowser.Providers/Plugins/AudioDb/ArtistImageProvider.cs +++ b/MediaBrowser.Providers/Plugins/AudioDb/ArtistImageProvider.cs @@ -143,6 +143,7 @@ namespace MediaBrowser.Providers.Plugins.AudioDb } /// - public bool Supports(BaseItem item) => item is MusicArtist; + public bool Supports(BaseItem item) + => Plugin.Instance.Configuration.Enable && item is MusicArtist; } } diff --git a/MediaBrowser.Providers/Plugins/AudioDb/ArtistProvider.cs b/MediaBrowser.Providers/Plugins/AudioDb/ArtistProvider.cs index a51c107df3..df0f3df8fa 100644 --- a/MediaBrowser.Providers/Plugins/AudioDb/ArtistProvider.cs +++ b/MediaBrowser.Providers/Plugins/AudioDb/ArtistProvider.cs @@ -56,6 +56,12 @@ namespace MediaBrowser.Providers.Plugins.AudioDb { var result = new MetadataResult(); + // TODO maybe remove when artist metadata can be disabled + if (!Plugin.Instance.Configuration.Enable) + { + return result; + } + var id = info.GetMusicBrainzArtistId(); if (!string.IsNullOrWhiteSpace(id)) diff --git a/MediaBrowser.Providers/Plugins/AudioDb/Configuration/PluginConfiguration.cs b/MediaBrowser.Providers/Plugins/AudioDb/Configuration/PluginConfiguration.cs index 90790d26fc..ad3c7eb4bd 100644 --- a/MediaBrowser.Providers/Plugins/AudioDb/Configuration/PluginConfiguration.cs +++ b/MediaBrowser.Providers/Plugins/AudioDb/Configuration/PluginConfiguration.cs @@ -5,5 +5,7 @@ namespace MediaBrowser.Providers.Plugins.AudioDb public class PluginConfiguration : BasePluginConfiguration { public bool Enable { get; set; } + + public bool ReplaceAlbumName { get; set; } } } diff --git a/MediaBrowser.Providers/Plugins/AudioDb/Configuration/config.html b/MediaBrowser.Providers/Plugins/AudioDb/Configuration/config.html index 56c32e13ea..c50dba71f7 100644 --- a/MediaBrowser.Providers/Plugins/AudioDb/Configuration/config.html +++ b/MediaBrowser.Providers/Plugins/AudioDb/Configuration/config.html @@ -12,6 +12,10 @@ Enable this provider for metadata searches on artists and albums. +
From acf1698d2b9277afea001555c2bb8e8d90f275ae Mon Sep 17 00:00:00 2001 From: dkanada Date: Sun, 8 Mar 2020 12:17:49 +0900 Subject: [PATCH 3/4] include audiodb config page in release --- MediaBrowser.Providers/MediaBrowser.Providers.csproj | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MediaBrowser.Providers/MediaBrowser.Providers.csproj b/MediaBrowser.Providers/MediaBrowser.Providers.csproj index 48c16b6433..dfe3eb2ef6 100644 --- a/MediaBrowser.Providers/MediaBrowser.Providers.csproj +++ b/MediaBrowser.Providers/MediaBrowser.Providers.csproj @@ -24,6 +24,11 @@ true + + + + + From f8b391538d9283879e962e0dbffed12dc6024a7d Mon Sep 17 00:00:00 2001 From: dkanada Date: Sun, 8 Mar 2020 12:19:38 +0900 Subject: [PATCH 4/4] update audiodb config page --- .../Plugins/AudioDb/Configuration/config.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Providers/Plugins/AudioDb/Configuration/config.html b/MediaBrowser.Providers/Plugins/AudioDb/Configuration/config.html index c50dba71f7..34494644d4 100644 --- a/MediaBrowser.Providers/Plugins/AudioDb/Configuration/config.html +++ b/MediaBrowser.Providers/Plugins/AudioDb/Configuration/config.html @@ -13,7 +13,7 @@ Enable this provider for metadata searches on artists and albums.
@@ -32,6 +32,7 @@ Dashboard.showLoadingMsg(); ApiClient.getPluginConfiguration(PluginConfig.pluginId).then(function (config) { $('#enable').checked(config.Enable); + $('#replaceAlbumName').checked(config.ReplaceAlbumName); Dashboard.hideLoadingMsg(); }); @@ -43,6 +44,7 @@ var form = this; ApiClient.getPluginConfiguration(PluginConfig.pluginId).then(function (config) { config.Enable = $('#enable', form).checked(); + config.ReplaceAlbumName = $('#replaceAlbumName', form).checked(); ApiClient.updatePluginConfiguration(PluginConfig.pluginId, config).then(Dashboard.processPluginConfigurationUpdateResult); });