mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-05 21:37:10 -04:00
Merge pull request #2536 from dkanada/audiodb
Migrate AudioDB to use plugin interface
This commit is contained in:
commit
623c0b6daa
@ -24,6 +24,11 @@
|
|||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="Plugins\AudioDb\Configuration\config.html" />
|
||||||
|
<EmbeddedResource Include="Plugins\AudioDb\Configuration\config.html" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="Plugins\MusicBrainz\Configuration\config.html" />
|
<None Remove="Plugins\MusicBrainz\Configuration\config.html" />
|
||||||
<EmbeddedResource Include="Plugins\MusicBrainz\Configuration\config.html" />
|
<EmbeddedResource Include="Plugins\MusicBrainz\Configuration\config.html" />
|
||||||
|
@ -10,7 +10,7 @@ using MediaBrowser.Model.Entities;
|
|||||||
using MediaBrowser.Model.Providers;
|
using MediaBrowser.Model.Providers;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.Music
|
namespace MediaBrowser.Providers.Plugins.AudioDb
|
||||||
{
|
{
|
||||||
public class AudioDbAlbumImageProvider : IRemoteImageProvider, IHasOrder
|
public class AudioDbAlbumImageProvider : IRemoteImageProvider, IHasOrder
|
||||||
{
|
{
|
||||||
@ -102,6 +102,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool Supports(BaseItem item) => item is MusicAlbum;
|
public bool Supports(BaseItem item)
|
||||||
|
=> Plugin.Instance.Configuration.Enable && item is MusicAlbum;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,8 +16,9 @@ using MediaBrowser.Model.Entities;
|
|||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Providers;
|
using MediaBrowser.Model.Providers;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
|
using MediaBrowser.Providers.Music;
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.Music
|
namespace MediaBrowser.Providers.Plugins.AudioDb
|
||||||
{
|
{
|
||||||
public class AudioDbAlbumProvider : IRemoteMetadataProvider<MusicAlbum, AlbumInfo>, IHasOrder
|
public class AudioDbAlbumProvider : IRemoteMetadataProvider<MusicAlbum, AlbumInfo>, IHasOrder
|
||||||
{
|
{
|
||||||
@ -54,6 +55,12 @@ namespace MediaBrowser.Providers.Music
|
|||||||
{
|
{
|
||||||
var result = new MetadataResult<MusicAlbum>();
|
var result = new MetadataResult<MusicAlbum>();
|
||||||
|
|
||||||
|
// TODO maybe remove when artist metadata can be disabled
|
||||||
|
if (!Plugin.Instance.Configuration.Enable)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
var id = info.GetReleaseGroupId();
|
var id = info.GetReleaseGroupId();
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(id))
|
if (!string.IsNullOrWhiteSpace(id))
|
||||||
@ -77,6 +84,11 @@ namespace MediaBrowser.Providers.Music
|
|||||||
|
|
||||||
private void ProcessResult(MusicAlbum item, Album result, string preferredLanguage)
|
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))
|
if (!string.IsNullOrWhiteSpace(result.strArtist))
|
||||||
{
|
{
|
||||||
item.AlbumArtists = new string[] { result.strArtist };
|
item.AlbumArtists = new string[] { result.strArtist };
|
@ -10,7 +10,7 @@ using MediaBrowser.Model.Entities;
|
|||||||
using MediaBrowser.Model.Providers;
|
using MediaBrowser.Model.Providers;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.Music
|
namespace MediaBrowser.Providers.Plugins.AudioDb
|
||||||
{
|
{
|
||||||
public class AudioDbArtistImageProvider : IRemoteImageProvider, IHasOrder
|
public class AudioDbArtistImageProvider : IRemoteImageProvider, IHasOrder
|
||||||
{
|
{
|
||||||
@ -143,6 +143,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool Supports(BaseItem item) => item is MusicArtist;
|
public bool Supports(BaseItem item)
|
||||||
|
=> Plugin.Instance.Configuration.Enable && item is MusicArtist;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,8 +15,9 @@ using MediaBrowser.Model.Entities;
|
|||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Providers;
|
using MediaBrowser.Model.Providers;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
|
using MediaBrowser.Providers.Music;
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.Music
|
namespace MediaBrowser.Providers.Plugins.AudioDb
|
||||||
{
|
{
|
||||||
public class AudioDbArtistProvider : IRemoteMetadataProvider<MusicArtist, ArtistInfo>, IHasOrder
|
public class AudioDbArtistProvider : IRemoteMetadataProvider<MusicArtist, ArtistInfo>, IHasOrder
|
||||||
{
|
{
|
||||||
@ -55,6 +56,12 @@ namespace MediaBrowser.Providers.Music
|
|||||||
{
|
{
|
||||||
var result = new MetadataResult<MusicArtist>();
|
var result = new MetadataResult<MusicArtist>();
|
||||||
|
|
||||||
|
// TODO maybe remove when artist metadata can be disabled
|
||||||
|
if (!Plugin.Instance.Configuration.Enable)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
var id = info.GetMusicBrainzArtistId();
|
var id = info.GetMusicBrainzArtistId();
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(id))
|
if (!string.IsNullOrWhiteSpace(id))
|
@ -0,0 +1,11 @@
|
|||||||
|
using MediaBrowser.Model.Plugins;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Providers.Plugins.AudioDb
|
||||||
|
{
|
||||||
|
public class PluginConfiguration : BasePluginConfiguration
|
||||||
|
{
|
||||||
|
public bool Enable { get; set; }
|
||||||
|
|
||||||
|
public bool ReplaceAlbumName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>AudioDB</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div data-role="page" class="page type-interior pluginConfigurationPage configPage" data-require="emby-input,emby-button,emby-checkbox">
|
||||||
|
<div data-role="content">
|
||||||
|
<div class="content-primary">
|
||||||
|
<form class="configForm">
|
||||||
|
<label class="checkboxContainer">
|
||||||
|
<input is="emby-checkbox" type="checkbox" id="enable" />
|
||||||
|
<span>Enable this provider for metadata searches on artists and albums.</span>
|
||||||
|
</label>
|
||||||
|
<label class="checkboxContainer">
|
||||||
|
<input is="emby-checkbox" type="checkbox" id="replaceAlbumName" />
|
||||||
|
<span>When an album is found during a metadata search, replace the name with the value on the server.</span>
|
||||||
|
</label>
|
||||||
|
<br />
|
||||||
|
<div>
|
||||||
|
<button is="emby-button" type="submit" class="raised button-submit block"><span>Save</span></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var PluginConfig = {
|
||||||
|
pluginId: "a629c0da-fac5-4c7e-931a-7174223f14c8"
|
||||||
|
};
|
||||||
|
|
||||||
|
$('.configPage').on('pageshow', function () {
|
||||||
|
Dashboard.showLoadingMsg();
|
||||||
|
ApiClient.getPluginConfiguration(PluginConfig.pluginId).then(function (config) {
|
||||||
|
$('#enable').checked(config.Enable);
|
||||||
|
$('#replaceAlbumName').checked(config.ReplaceAlbumName);
|
||||||
|
|
||||||
|
Dashboard.hideLoadingMsg();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.configForm').on('submit', function (e) {
|
||||||
|
Dashboard.showLoadingMsg();
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -2,7 +2,7 @@ using MediaBrowser.Controller.Entities.Audio;
|
|||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.Music
|
namespace MediaBrowser.Providers.Plugins.AudioDb
|
||||||
{
|
{
|
||||||
public class AudioDbAlbumExternalId : IExternalId
|
public class AudioDbAlbumExternalId : IExternalId
|
||||||
{
|
{
|
||||||
@ -16,8 +16,7 @@ namespace MediaBrowser.Providers.Music
|
|||||||
public string UrlFormatString => "https://www.theaudiodb.com/album/{0}";
|
public string UrlFormatString => "https://www.theaudiodb.com/album/{0}";
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool Supports(IHasProviderIds item)
|
public bool Supports(IHasProviderIds item) => item is MusicAlbum;
|
||||||
=> item is MusicAlbum;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AudioDbOtherAlbumExternalId : IExternalId
|
public class AudioDbOtherAlbumExternalId : IExternalId
|
||||||
@ -62,7 +61,6 @@ namespace MediaBrowser.Providers.Music
|
|||||||
public string UrlFormatString => "https://www.theaudiodb.com/artist/{0}";
|
public string UrlFormatString => "https://www.theaudiodb.com/artist/{0}";
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool Supports(IHasProviderIds item)
|
public bool Supports(IHasProviderIds item) => item is Audio || item is MusicAlbum;
|
||||||
=> item is Audio || item is MusicAlbum;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
35
MediaBrowser.Providers/Plugins/AudioDb/Plugin.cs
Normal file
35
MediaBrowser.Providers/Plugins/AudioDb/Plugin.cs
Normal file
@ -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<PluginConfiguration>, 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<PluginPageInfo> GetPages()
|
||||||
|
{
|
||||||
|
yield return new PluginPageInfo
|
||||||
|
{
|
||||||
|
Name = Name,
|
||||||
|
EmbeddedResourcePath = GetType().Namespace + ".Configuration.config.html"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user