diff --git a/Jellyfin.Plugin.MetaTube/Configuration/PluginConfiguration.cs b/Jellyfin.Plugin.MetaTube/Configuration/PluginConfiguration.cs index 0377c73..8f78412 100644 --- a/Jellyfin.Plugin.MetaTube/Configuration/PluginConfiguration.cs +++ b/Jellyfin.Plugin.MetaTube/Configuration/PluginConfiguration.cs @@ -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 _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 } \ No newline at end of file diff --git a/Jellyfin.Plugin.MetaTube/Configuration/configPage.html b/Jellyfin.Plugin.MetaTube/Configuration/configPage.html index a72e61a..3d10b37 100644 --- a/Jellyfin.Plugin.MetaTube/Configuration/configPage.html +++ b/Jellyfin.Plugin.MetaTube/Configuration/configPage.html @@ -71,7 +71,7 @@ Enable real actor names -
Search and replace with real actor names from AVBASE (AVWIKI).
+
Search and replace with real actor names from AVBASE.
@@ -99,13 +99,13 @@
-
Aspect ratio for primary images, set a negtive value to use the default.
+
Aspect ratio for primary images, set a negative value to use the default.
-
Default compression quality for JEPG images, set between 0 and 100. (default: 90)
+
Default compression quality for JPEG images, set between 0 and 100. (default: 90)
diff --git a/Jellyfin.Plugin.MetaTube/Jellyfin.Plugin.MetaTube.csproj b/Jellyfin.Plugin.MetaTube/Jellyfin.Plugin.MetaTube.csproj index 2b8eb54..c5608f6 100644 --- a/Jellyfin.Plugin.MetaTube/Jellyfin.Plugin.MetaTube.csproj +++ b/Jellyfin.Plugin.MetaTube/Jellyfin.Plugin.MetaTube.csproj @@ -34,10 +34,10 @@ - + - + diff --git a/Jellyfin.Plugin.MetaTube/Plugin.cs b/Jellyfin.Plugin.MetaTube/Plugin.cs index 4701e4d..d6a3734 100644 --- a/Jellyfin.Plugin.MetaTube/Plugin.cs +++ b/Jellyfin.Plugin.MetaTube/Plugin.cs @@ -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, IHasWebPages, IHasThumbImage +public class Plugin : BasePluginSimpleUI, IHasThumbImage +{ + public Plugin(IApplicationHost applicationHost) : base(applicationHost) + { + Instance = this; + } #else public class Plugin : BasePlugin, 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, IHasWebPages public static Plugin Instance { get; private set; } +#if !__EMBY__ public IEnumerable GetPages() { return new[] @@ -40,8 +50,11 @@ public class Plugin : BasePlugin, IHasWebPages } }; } +#endif #if __EMBY__ + public PluginConfiguration Configuration => GetOptions(); + public Stream GetThumbImage() { return GetType().Assembly.GetManifestResourceStream($"{GetType().Namespace}.thumb.png"); diff --git a/Jellyfin.Plugin.MetaTube/Translation/TranslationEngine.cs b/Jellyfin.Plugin.MetaTube/Translation/TranslationEngine.cs index df6b1f0..15f7b5e 100644 --- a/Jellyfin.Plugin.MetaTube/Translation/TranslationEngine.cs +++ b/Jellyfin.Plugin.MetaTube/Translation/TranslationEngine.cs @@ -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 } \ No newline at end of file diff --git a/Jellyfin.Plugin.MetaTube/Translation/TranslationMode.cs b/Jellyfin.Plugin.MetaTube/Translation/TranslationMode.cs index 401f7a1..67cbb1f 100644 --- a/Jellyfin.Plugin.MetaTube/Translation/TranslationMode.cs +++ b/Jellyfin.Plugin.MetaTube/Translation/TranslationMode.cs @@ -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 } \ No newline at end of file diff --git a/README.md b/README.md index 7845e8a..24f450d 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ MetaTube Plugin for Jellyfin/Emby. ## Platforms [![Jellyfin](https://img.shields.io/static/v1?color=%2300A4DC&style=for-the-badge&label=Jellyfin&logo=jellyfin&message=10.8.x)](https://jellyfin.org/) -[![Emby](https://img.shields.io/static/v1?color=%2352B54B&style=for-the-badge&label=Emby&logo=emby&message=4.7.x)](https://emby.media/) +[![Emby](https://img.shields.io/static/v1?color=%2352B54B&style=for-the-badge&label=Emby&logo=emby&message=4.8.x)](https://emby.media/) _NOTE: This project will only support stable versions._ diff --git a/README_ZH.md b/README_ZH.md index 0dd2f54..6dbfaf5 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -45,7 +45,7 @@ ## 平台 [![Jellyfin](https://img.shields.io/static/v1?color=%2300A4DC&style=for-the-badge&label=Jellyfin&logo=jellyfin&message=10.8.x)](https://jellyfin.org/) -[![Emby](https://img.shields.io/static/v1?color=%2352B54B&style=for-the-badge&label=Emby&logo=emby&message=4.7.x)](https://emby.media/) +[![Emby](https://img.shields.io/static/v1?color=%2352B54B&style=for-the-badge&label=Emby&logo=emby&message=4.8.x)](https://emby.media/) _注意:本项目仅支持 Jellyfin/Emby 稳定版。_