mirror of
https://github.com/metatube-community/jellyfin-plugin-metatube.git
synced 2026-05-05 01:22:09 +08:00
Feature: support plugin option API on Emby 4.8.x (#278)
This commit is contained in:
@@ -1,81 +1,106 @@
|
||||
using Jellyfin.Plugin.MetaTube.Helpers;
|
||||
using Jellyfin.Plugin.MetaTube.Translation;
|
||||
#if __EMBY__
|
||||
using System.ComponentModel;
|
||||
using Emby.Web.GenericEdit;
|
||||
using MediaBrowser.Model.Attributes;
|
||||
|
||||
#else
|
||||
using MediaBrowser.Model.Plugins;
|
||||
#endif
|
||||
|
||||
namespace Jellyfin.Plugin.MetaTube.Configuration;
|
||||
|
||||
#if __EMBY__
|
||||
public class PluginConfiguration : EditableOptionsBase
|
||||
{
|
||||
public override string EditorTitle => Plugin.Instance.Name;
|
||||
#else
|
||||
public class PluginConfiguration : BasePluginConfiguration
|
||||
{
|
||||
#region Image
|
||||
#endif
|
||||
|
||||
public double PrimaryImageRatio { get; set; } = -1;
|
||||
|
||||
public int DefaultImageQuality { get; set; } = 90;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Badge
|
||||
|
||||
public bool EnableBadges { get; set; } = false;
|
||||
|
||||
public string BadgeUrl { get; set; } = "zimu.png";
|
||||
|
||||
#endregion
|
||||
|
||||
#region General
|
||||
|
||||
public string Server { get; set; } = "https://api.metatube.internal";
|
||||
#if __EMBY__
|
||||
[DisplayName("Server")]
|
||||
[Description("Full url of the MetaTube Server, HTTPS protocol is recommended.")]
|
||||
[Required]
|
||||
#endif
|
||||
public string Server { get; set; } = string.Empty;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Token")]
|
||||
[Description("Access token for the MetaTube Server, or blank if no token is set by the backend.")]
|
||||
#endif
|
||||
public string Token { get; set; } = string.Empty;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Enable collections")]
|
||||
[Description("Automatically create collections by series.")]
|
||||
#endif
|
||||
public bool EnableCollections { get; set; } = false;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Enable directors")]
|
||||
[Description("Add directors to corresponding video metadata.")]
|
||||
#endif
|
||||
public bool EnableDirectors { get; set; } = true;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Enable ratings")]
|
||||
[Description("Display community ratings from the original website.")]
|
||||
#endif
|
||||
public bool EnableRatings { get; set; } = true;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Enable trailers")]
|
||||
[Description("Generate online video trailers in strm format.")]
|
||||
#endif
|
||||
public bool EnableTrailers { get; set; } = false;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Enable real actor names")]
|
||||
[Description("Search and replace with real actor names from AVBASE.")]
|
||||
#endif
|
||||
public bool EnableRealActorNames { get; set; } = false;
|
||||
|
||||
#endregion
|
||||
#if __EMBY__
|
||||
[DisplayName("Enable badges")]
|
||||
[Description("Add Chinese subtitle badges to primary images.")]
|
||||
#endif
|
||||
public bool EnableBadges { get; set; } = false;
|
||||
|
||||
#region Template
|
||||
#if __EMBY__
|
||||
[DisplayName("Badge url")]
|
||||
[Description("Custom badge url, PNG format is recommended. (default: zimu.png)")]
|
||||
#endif
|
||||
public string BadgeUrl { get; set; } = "zimu.png";
|
||||
|
||||
public bool EnableTemplate { get; set; } = false;
|
||||
#if __EMBY__
|
||||
[DisplayName("Primary image ratio")]
|
||||
[Description("Aspect ratio for primary images, set a negative value to use the default.")]
|
||||
#endif
|
||||
public double PrimaryImageRatio { get; set; } = -1;
|
||||
|
||||
public string NameTemplate { get; set; } = DefaultNameTemplate;
|
||||
|
||||
public string TaglineTemplate { get; set; } = DefaultTaglineTemplate;
|
||||
|
||||
public static string DefaultNameTemplate => "{number} {title}";
|
||||
|
||||
public static string DefaultTaglineTemplate => "配信開始日 {date}";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Translation
|
||||
|
||||
public TranslationMode TranslationMode { get; set; } = TranslationMode.Disabled;
|
||||
|
||||
public TranslationEngine TranslationEngine { get; set; } = TranslationEngine.Baidu;
|
||||
|
||||
public string BaiduAppId { get; set; } = string.Empty;
|
||||
|
||||
public string BaiduAppKey { get; set; } = string.Empty;
|
||||
|
||||
public string GoogleApiKey { get; set; } = string.Empty;
|
||||
|
||||
public string DeepLApiKey { get; set; } = string.Empty;
|
||||
|
||||
public string OpenAiApiKey { get; set; } = string.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Provider
|
||||
#if __EMBY__
|
||||
[DisplayName("Default image quality")]
|
||||
[Description("Default compression quality for JPEG images, set between 0 and 100. (default: 90)")]
|
||||
[MinValue(0)]
|
||||
[MaxValue(100)]
|
||||
[Required]
|
||||
#endif
|
||||
public int DefaultImageQuality { get; set; } = 90;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Enable movie provider filter")]
|
||||
[Description("Filter and reorder search results from movie providers.")]
|
||||
#endif
|
||||
public bool EnableMovieProviderFilter { get; set; } = false;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Movie provider filter")]
|
||||
[Description(
|
||||
"Provider names are case-insensitive, with decreasing precedence from left to right, separated by commas.")]
|
||||
#endif
|
||||
public string RawMovieProviderFilter
|
||||
{
|
||||
get => _movieProviderFilter?.Any() == true ? string.Join(',', _movieProviderFilter) : string.Empty;
|
||||
@@ -90,12 +115,76 @@ public class PluginConfiguration : BasePluginConfiguration
|
||||
|
||||
private List<string> _movieProviderFilter;
|
||||
|
||||
#endregion
|
||||
#if __EMBY__
|
||||
[DisplayName("Enable template")]
|
||||
#endif
|
||||
public bool EnableTemplate { get; set; } = false;
|
||||
|
||||
#region Substitution
|
||||
#if __EMBY__
|
||||
[DisplayName("Name template")]
|
||||
#endif
|
||||
public string NameTemplate { get; set; } = DefaultNameTemplate;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Tagline template")]
|
||||
#endif
|
||||
public string TaglineTemplate { get; set; } = DefaultTaglineTemplate;
|
||||
|
||||
public static string DefaultNameTemplate => "{number} {title}";
|
||||
|
||||
public static string DefaultTaglineTemplate => "配信開始日 {date}";
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Translation mode")]
|
||||
#endif
|
||||
public TranslationMode TranslationMode { get; set; } = TranslationMode.Disabled;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Translation engine")]
|
||||
#endif
|
||||
public TranslationEngine TranslationEngine { get; set; } = TranslationEngine.Baidu;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Baidu app id")]
|
||||
[VisibleCondition(nameof(TranslationEngine), ValueCondition.IsEqual, TranslationEngine.Baidu)]
|
||||
#endif
|
||||
public string BaiduAppId { get; set; } = string.Empty;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Baidu app key")]
|
||||
[VisibleCondition(nameof(TranslationEngine), ValueCondition.IsEqual, TranslationEngine.Baidu)]
|
||||
#endif
|
||||
public string BaiduAppKey { get; set; } = string.Empty;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Google api key")]
|
||||
[VisibleCondition(nameof(TranslationEngine), ValueCondition.IsEqual, TranslationEngine.Google)]
|
||||
#endif
|
||||
public string GoogleApiKey { get; set; } = string.Empty;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("DeepL api key")]
|
||||
[VisibleCondition(nameof(TranslationEngine), ValueCondition.IsEqual, TranslationEngine.DeepL)]
|
||||
#endif
|
||||
public string DeepLApiKey { get; set; } = string.Empty;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("OpenAI api key")]
|
||||
[VisibleCondition(nameof(TranslationEngine), ValueCondition.IsEqual, TranslationEngine.OpenAi)]
|
||||
#endif
|
||||
public string OpenAiApiKey { get; set; } = string.Empty;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Enable title substitution")]
|
||||
#endif
|
||||
public bool EnableTitleSubstitution { get; set; } = false;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Title substitution table")]
|
||||
[Description(
|
||||
"One record per line, separated by equal signs. Leave the target substring blank to delete the source substring.")]
|
||||
[EditMultiline(5)]
|
||||
#endif
|
||||
public string TitleRawSubstitutionTable
|
||||
{
|
||||
get => _titleSubstitutionTable?.ToString();
|
||||
@@ -109,8 +198,17 @@ public class PluginConfiguration : BasePluginConfiguration
|
||||
|
||||
private SubstitutionTable _titleSubstitutionTable;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Enable actor substitution")]
|
||||
#endif
|
||||
public bool EnableActorSubstitution { get; set; } = false;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Actor substitution table")]
|
||||
[Description(
|
||||
"One record per line, separated by equal signs. Leave the target actor blank to delete the source actor.")]
|
||||
[EditMultiline(5)]
|
||||
#endif
|
||||
public string ActorRawSubstitutionTable
|
||||
{
|
||||
get => _actorSubstitutionTable?.ToString();
|
||||
@@ -124,8 +222,17 @@ public class PluginConfiguration : BasePluginConfiguration
|
||||
|
||||
private SubstitutionTable _actorSubstitutionTable;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Enable genre substitution")]
|
||||
#endif
|
||||
public bool EnableGenreSubstitution { get; set; } = false;
|
||||
|
||||
#if __EMBY__
|
||||
[DisplayName("Title substitution table")]
|
||||
[Description(
|
||||
"One record per line, separated by equal signs. Leave the target genre blank to delete the source genre.")]
|
||||
[EditMultiline(5)]
|
||||
#endif
|
||||
public string GenreRawSubstitutionTable
|
||||
{
|
||||
get => _genreSubstitutionTable?.ToString();
|
||||
@@ -138,6 +245,4 @@ public class PluginConfiguration : BasePluginConfiguration
|
||||
}
|
||||
|
||||
private SubstitutionTable _genreSubstitutionTable;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -71,7 +71,7 @@
|
||||
<input id="chkEnableRealActorNames" is="emby-checkbox" name="chkEnableRealActorNames" type="checkbox"/>
|
||||
<span>Enable real actor names</span>
|
||||
</label>
|
||||
<div class="fieldDescription checkboxFieldDescription">Search and replace with real actor names from AVBASE (AVWIKI).</div>
|
||||
<div class="fieldDescription checkboxFieldDescription">Search and replace with real actor names from AVBASE.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -99,13 +99,13 @@
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="txtPrimaryImageRatio">Primary image ratio:</label>
|
||||
<input id="txtPrimaryImageRatio" is="emby-input" name="txtPrimaryImageRatio" step="any" type="number"/>
|
||||
<div class="fieldDescription">Aspect ratio for primary images, set a negtive value to use the default.</div>
|
||||
<div class="fieldDescription">Aspect ratio for primary images, set a negative value to use the default.</div>
|
||||
</div>
|
||||
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel inputLabelUnfocused" for="txtDefaultImageQuality">Default image quality:</label>
|
||||
<input id="txtDefaultImageQuality" is="emby-input" max="100" min="0" name="txtDefaultImageQuality" step="1" type="number"/>
|
||||
<div class="fieldDescription">Default compression quality for JEPG images, set between 0 and 100. (default: 90)</div>
|
||||
<div class="fieldDescription">Default compression quality for JPEG images, set between 0 and 100. (default: 90)</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -34,10 +34,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)'=='Debug.Emby' or '$(Configuration)'=='Release.Emby'">
|
||||
<PackageReference Include="MediaBrowser.Server.Core" Version="4.7.1"/>
|
||||
<PackageReference Include="MediaBrowser.Server.Core" Version="4.8.0.80"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ItemGroup Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">
|
||||
<None Remove="Configuration\configPage.html"/>
|
||||
<EmbeddedResource Include="Configuration\configPage.html"/>
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,25 +1,34 @@
|
||||
using Jellyfin.Plugin.MetaTube.Configuration;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Plugins;
|
||||
#if __EMBY__
|
||||
using MediaBrowser.Common;
|
||||
using MediaBrowser.Controller.Plugins;
|
||||
using MediaBrowser.Model.Drawing;
|
||||
|
||||
#else
|
||||
using MediaBrowser.Model.Plugins;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
#if __EMBY__
|
||||
using MediaBrowser.Model.Drawing;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
#endif
|
||||
|
||||
namespace Jellyfin.Plugin.MetaTube;
|
||||
|
||||
#if __EMBY__
|
||||
public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages, IHasThumbImage
|
||||
public class Plugin : BasePluginSimpleUI<PluginConfiguration>, IHasThumbImage
|
||||
{
|
||||
public Plugin(IApplicationHost applicationHost) : base(applicationHost)
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
#else
|
||||
public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
||||
#endif
|
||||
{
|
||||
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) : base(applicationPaths,
|
||||
xmlSerializer)
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
#endif
|
||||
|
||||
public override string Name => "MetaTube";
|
||||
|
||||
@@ -29,6 +38,7 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
||||
|
||||
public static Plugin Instance { get; private set; }
|
||||
|
||||
#if !__EMBY__
|
||||
public IEnumerable<PluginPageInfo> GetPages()
|
||||
{
|
||||
return new[]
|
||||
@@ -40,8 +50,11 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __EMBY__
|
||||
public PluginConfiguration Configuration => GetOptions();
|
||||
|
||||
public Stream GetThumbImage()
|
||||
{
|
||||
return GetType().Assembly.GetManifestResourceStream($"{GetType().Namespace}.thumb.png");
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Jellyfin.Plugin.MetaTube.Translation;
|
||||
|
||||
public enum TranslationEngine
|
||||
{
|
||||
[Description("Baidu")]
|
||||
Baidu,
|
||||
|
||||
[Description("Google")]
|
||||
Google,
|
||||
|
||||
[Description("Google (Free)")]
|
||||
GoogleFree,
|
||||
|
||||
[Description("DeepL (Free)")]
|
||||
DeepL,
|
||||
|
||||
[Description("OpenAI")]
|
||||
OpenAi
|
||||
}
|
||||
@@ -1,9 +1,18 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Jellyfin.Plugin.MetaTube.Translation;
|
||||
|
||||
public enum TranslationMode
|
||||
{
|
||||
[Description("Disabled")]
|
||||
Disabled,
|
||||
|
||||
[Description("Title")]
|
||||
Title,
|
||||
|
||||
[Description("Summary")]
|
||||
Summary,
|
||||
|
||||
[Description("Title and Summary")]
|
||||
Both
|
||||
}
|
||||
@@ -45,7 +45,7 @@ MetaTube Plugin for Jellyfin/Emby.
|
||||
## Platforms
|
||||
|
||||
[](https://jellyfin.org/)
|
||||
[](https://emby.media/)
|
||||
[](https://emby.media/)
|
||||
|
||||
_NOTE: This project will only support stable versions._
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
## 平台
|
||||
|
||||
[](https://jellyfin.org/)
|
||||
[](https://emby.media/)
|
||||
[](https://emby.media/)
|
||||
|
||||
_注意:本项目仅支持 Jellyfin/Emby 稳定版。_
|
||||
|
||||
|
||||
Reference in New Issue
Block a user