migrate audiodb to plugin

This commit is contained in:
dkanada 2020-03-03 02:07:31 +09:00
parent 1c1484389a
commit 76e49a1eb7
8 changed files with 104 additions and 9 deletions

View File

@ -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
{

View File

@ -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<MusicAlbum, AlbumInfo>, IHasOrder
{

View File

@ -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
{

View File

@ -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<MusicArtist, ArtistInfo>, IHasOrder
{

View File

@ -0,0 +1,9 @@
using MediaBrowser.Model.Plugins;
namespace MediaBrowser.Providers.Plugins.AudioDb
{
public class PluginConfiguration : BasePluginConfiguration
{
public bool Enable { get; set; }
}
}

View File

@ -0,0 +1,51 @@
<!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>
<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);
Dashboard.hideLoadingMsg();
});
});
$('.configForm').on('submit', function (e) {
Dashboard.showLoadingMsg();
var form = this;
ApiClient.getPluginConfiguration(PluginConfig.pluginId).then(function (config) {
config.Enable = $('#enable', form).checked();
ApiClient.updatePluginConfiguration(PluginConfig.pluginId, config).then(Dashboard.processPluginConfigurationUpdateResult);
});
return false;
});
</script>
</div>
</body>
</html>

View File

@ -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}";
/// <inheritdoc />
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}";
/// <inheritdoc />
public bool Supports(IHasProviderIds item)
=> item is Audio || item is MusicAlbum;
public bool Supports(IHasProviderIds item) => item is Audio || item is MusicAlbum;
}
}

View 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"
};
}
}
}